http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/protocol/api/src/main/java/org/apache/oodt/cas/protocol/verify/BasicProtocolVerifier.java ---------------------------------------------------------------------- diff --git a/protocol/api/src/main/java/org/apache/oodt/cas/protocol/verify/BasicProtocolVerifier.java b/protocol/api/src/main/java/org/apache/oodt/cas/protocol/verify/BasicProtocolVerifier.java deleted file mode 100644 index b276d14..0000000 --- a/protocol/api/src/main/java/org/apache/oodt/cas/protocol/verify/BasicProtocolVerifier.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * 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.oodt.cas.protocol.verify; - -//JDK imports -import java.net.URI; -import java.util.Map; -import java.util.logging.Level; -import java.util.logging.Logger; - -//OODT imports -import org.apache.oodt.cas.protocol.Protocol; -import org.apache.oodt.cas.protocol.ProtocolFile; -import org.apache.oodt.cas.protocol.auth.Authentication; -import org.apache.oodt.cas.protocol.exceptions.ProtocolException; - -/** - * {@link ProtocolVerifier} which performs basic verification of a given {@link Protocol} to - * a given site. It check that {@link Protocol} can connect to the site, cd to a directory, - * cd back to HOME directory, and able to perform an ls and pwd. - * - * @author bfoster - */ -public class BasicProtocolVerifier implements ProtocolVerifier { - - private static final Logger LOG = Logger.getLogger(BasicProtocolVerifier.class.getName()); - - private Map<URI, ProtocolFile> uriTestCdMap; - - public BasicProtocolVerifier(Map<URI, ProtocolFile> uriTestCdMap) { - this.uriTestCdMap = uriTestCdMap; - } - - public boolean verify(Protocol protocol, URI site, Authentication auth) { - try { - LOG.log(Level.INFO, "Testing protocol " - + protocol.getClass().getCanonicalName() - + " . . . this may take a few minutes . . ."); - - // Test connectivity - protocol.connect(site.getHost(), auth); - - // Test ls, cd, and pwd - protocol.cdHome(); - ProtocolFile home = protocol.pwd(); - protocol.ls(); - if (uriTestCdMap.containsKey(site)) { - protocol.cd(uriTestCdMap.get(site)); - } else { - protocol.cdHome(); - } - protocol.cdHome(); - - // Verify again at home directory - if (home == null || !home.equals(protocol.pwd())) { - throw new ProtocolException( - "Home directory not the same after cd"); - } - } catch (Exception e) { - LOG.log(Level.SEVERE, "Protocol " - + protocol.getClass().getCanonicalName() - + " failed compatibility test : " + e.getMessage(), e); - return false; - } finally { - try { protocol.close(); } catch (Exception ignored) {} - } - return true; - } - -}
http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/protocol/api/src/main/java/org/apache/oodt/cas/protocol/verify/BasicProtocolVerifierFactory.java ---------------------------------------------------------------------- diff --git a/protocol/api/src/main/java/org/apache/oodt/cas/protocol/verify/BasicProtocolVerifierFactory.java b/protocol/api/src/main/java/org/apache/oodt/cas/protocol/verify/BasicProtocolVerifierFactory.java deleted file mode 100644 index e4646fc..0000000 --- a/protocol/api/src/main/java/org/apache/oodt/cas/protocol/verify/BasicProtocolVerifierFactory.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * 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.oodt.cas.protocol.verify; - -//JDK imports -import java.net.URI; -import java.util.concurrent.ConcurrentHashMap; -import java.util.Map; - -//OODT imports -import org.apache.oodt.cas.protocol.ProtocolFile; - -/** - * {@link ProtocolVerifierFactory} which creates {@link BasicProtocolVerifier}. - * - * @author bfoster - */ -public class BasicProtocolVerifierFactory implements ProtocolVerifierFactory { - - private Map<URI, ProtocolFile> testCdMap; - - public ProtocolVerifier newInstance() { - if (testCdMap != null) { - return new BasicProtocolVerifier(testCdMap); - } else { - return new BasicProtocolVerifier(new ConcurrentHashMap<URI, ProtocolFile>()); - } - } - - public void setTestCdMap(Map<URI, ProtocolFile> testCdMap) { - this.testCdMap = testCdMap; - } -} http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/protocol/api/src/main/java/org/apache/oodt/cas/protocol/verify/ProtocolVerifier.java ---------------------------------------------------------------------- diff --git a/protocol/api/src/main/java/org/apache/oodt/cas/protocol/verify/ProtocolVerifier.java b/protocol/api/src/main/java/org/apache/oodt/cas/protocol/verify/ProtocolVerifier.java deleted file mode 100644 index 6463006..0000000 --- a/protocol/api/src/main/java/org/apache/oodt/cas/protocol/verify/ProtocolVerifier.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * 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.oodt.cas.protocol.verify; - -//JDK imports -import java.net.URI; - -//OODT imports -import org.apache.oodt.cas.protocol.Protocol; -import org.apache.oodt.cas.protocol.auth.Authentication; - -/** - * Interface for verifying {@link Protocol}s can connect to sites. - * - * @author bfoster - */ -public interface ProtocolVerifier { - - boolean verify(Protocol protocol, URI site, Authentication auth); - -} http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/protocol/api/src/main/java/org/apache/oodt/cas/protocol/verify/ProtocolVerifierFactory.java ---------------------------------------------------------------------- diff --git a/protocol/api/src/main/java/org/apache/oodt/cas/protocol/verify/ProtocolVerifierFactory.java b/protocol/api/src/main/java/org/apache/oodt/cas/protocol/verify/ProtocolVerifierFactory.java deleted file mode 100644 index 3d257a3..0000000 --- a/protocol/api/src/main/java/org/apache/oodt/cas/protocol/verify/ProtocolVerifierFactory.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * 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.oodt.cas.protocol.verify; - -/** - * Factory for creating {@link ProtocolVerifier}s - * - * @author bfoster - */ -public interface ProtocolVerifierFactory { - - ProtocolVerifier newInstance(); - -} http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/protocol/api/src/main/resources/policy/cmd-line-actions.xml ---------------------------------------------------------------------- diff --git a/protocol/api/src/main/resources/policy/cmd-line-actions.xml b/protocol/api/src/main/resources/policy/cmd-line-actions.xml deleted file mode 100644 index 90487bf..0000000 --- a/protocol/api/src/main/resources/policy/cmd-line-actions.xml +++ /dev/null @@ -1,42 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - 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. ---> -<!-- - Author: bfoster - Description: ProtocolManager Configuration ---> -<beans xmlns="http://www.springframework.org/schema/beans" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" - xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"> - - <bean id="Download" class="org.apache.oodt.cas.protocol.cli.action.DownloadCliAction"> - <property name="description" value="Downloads a file" /> - </bean> - <bean id="GetSupportedFactories" class="org.apache.oodt.cas.protocol.cli.action.GetSupportedFactoriesCliAction"> - <property name="description" value="Prints out list of supported ProtocolFactory(s)" /> - </bean> - <bean id="CrossProtocolTransfer" class="org.apache.oodt.cas.protocol.cli.action.CrossProtocolTransferCliAction"> - <property name="description" value="Transfers a file across 2 different protocols" /> - <property name="verifierFactory" ref="BasicVerifier" /> - </bean> - <bean id="DeleteEmptyDirectories" class="org.apache.oodt.cas.protocol.cli.action.DeleteEmptyDirectoriesCliAction"> - <property name="description" value="Deletes empty directories from a given site" /> - <property name="verifierFactory" ref="BasicVerifier" /> - </bean> - - <bean id="BasicVerifier" class="org.apache.oodt.cas.protocol.verify.BasicProtocolVerifierFactory" /> -</beans> http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/protocol/api/src/main/resources/policy/cmd-line-options.xml ---------------------------------------------------------------------- diff --git a/protocol/api/src/main/resources/policy/cmd-line-options.xml b/protocol/api/src/main/resources/policy/cmd-line-options.xml deleted file mode 100644 index 66eaa9c..0000000 --- a/protocol/api/src/main/resources/policy/cmd-line-options.xml +++ /dev/null @@ -1,166 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - 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. ---> -<!-- Author: bfoster Description: ProtocolManager Configuration --> -<beans xmlns="http://www.springframework.org/schema/beans" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" - xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"> - - <bean id="user" class="org.apache.oodt.cas.cli.option.AdvancedCmdLineOption"> - <property name="shortOption" value="u" /> - <property name="longOption" value="user" /> - <property name="description" value="Username for authentication" /> - <property name="hasArgs" value="true" /> - <property name="argsDescription" value="username" /> - <property name="requirementRules"> - <list> - <bean class="org.apache.oodt.cas.cli.option.require.ActionDependencyRule" - p:actionName="Download" p:relation="OPTIONAL" /> - </list> - </property> - <property name="handler"> - <bean class="org.apache.oodt.cas.cli.option.handler.ApplyToActionHandler"> - <property name="applyToActions"> - <list> - <bean class="org.apache.oodt.cas.cli.option.handler.ApplyToAction" - p:actionName="Download" /> - </list> - </property> - </bean> - </property> - </bean> - - <bean id="pass" class="org.apache.oodt.cas.cli.option.AdvancedCmdLineOption"> - <property name="shortOption" value="p" /> - <property name="longOption" value="pass" /> - <property name="description" value="Password for authentication" /> - <property name="hasArgs" value="true" /> - <property name="argsDescription" value="password" /> - <property name="requirementRules"> - <list> - <bean class="org.apache.oodt.cas.cli.option.require.ActionDependencyRule" - p:actionName="Download" p:relation="OPTIONAL" /> - </list> - </property> - <property name="handler"> - <bean class="org.apache.oodt.cas.cli.option.handler.ApplyToActionHandler"> - <property name="applyToActions"> - <list> - <bean class="org.apache.oodt.cas.cli.option.handler.ApplyToAction" - p:actionName="Download" /> - </list> - </property> - </bean> - </property> - </bean> - - <bean id="url" class="org.apache.oodt.cas.cli.option.AdvancedCmdLineOption"> - <property name="shortOption" value="url" /> - <property name="longOption" value="url" /> - <property name="description" value="URL to download" /> - <property name="hasArgs" value="true" /> - <property name="argsDescription" value="URL" /> - <property name="requirementRules"> - <list> - <bean class="org.apache.oodt.cas.cli.option.require.ActionDependencyRule" - p:actionName="Download" p:relation="REQUIRED" /> - </list> - </property> - <property name="handler"> - <bean class="org.apache.oodt.cas.cli.option.handler.ApplyToActionHandler"> - <property name="applyToActions"> - <list> - <bean class="org.apache.oodt.cas.cli.option.handler.ApplyToAction" - p:actionName="Download" /> - </list> - </property> - </bean> - </property> - </bean> - - <bean id="fromUrl" class="org.apache.oodt.cas.cli.option.AdvancedCmdLineOption"> - <property name="shortOption" value="fu" /> - <property name="longOption" value="fromUrl" /> - <property name="description" value="URL to get file" /> - <property name="hasArgs" value="true" /> - <property name="argsDescription" value="URL" /> - <property name="requirementRules"> - <list> - <bean class="org.apache.oodt.cas.cli.option.require.ActionDependencyRule" - p:actionName="CrossProtocolTransfer" p:relation="REQUIRED" /> - </list> - </property> - <property name="handler"> - <bean class="org.apache.oodt.cas.cli.option.handler.ApplyToActionHandler"> - <property name="applyToActions"> - <list> - <bean class="org.apache.oodt.cas.cli.option.handler.ApplyToAction" - p:actionName="CrossProtocolTransfer" p:methodName="setFromUri" /> - </list> - </property> - </bean> - </property> - </bean> - - <bean id="toUrl" class="org.apache.oodt.cas.cli.option.AdvancedCmdLineOption"> - <property name="shortOption" value="tu" /> - <property name="longOption" value="toUrl" /> - <property name="description" value="URL to send file" /> - <property name="hasArgs" value="true" /> - <property name="argsDescription" value="URL" /> - <property name="requirementRules"> - <list> - <bean class="org.apache.oodt.cas.cli.option.require.ActionDependencyRule" - p:actionName="CrossProtocolTransfer" p:relation="REQUIRED" /> - </list> - </property> - <property name="handler"> - <bean class="org.apache.oodt.cas.cli.option.handler.ApplyToActionHandler"> - <property name="applyToActions"> - <list> - <bean class="org.apache.oodt.cas.cli.option.handler.ApplyToAction" - p:actionName="CrossProtocolTransfer" p:methodName="setToUri" /> - </list> - </property> - </bean> - </property> - </bean> - - <bean id="directoriesRegex" class="org.apache.oodt.cas.cli.option.AdvancedCmdLineOption"> - <property name="shortOption" value="dr" /> - <property name="longOption" value="dirsRegex" /> - <property name="description" value="Directory regex of directories to delete" /> - <property name="hasArgs" value="true" /> - <property name="argsDescription" value="URL" /> - <property name="requirementRules"> - <list> - <bean class="org.apache.oodt.cas.cli.option.require.ActionDependencyRule" - p:actionName="DeleteEmptyDirectories" p:relation="REQUIRED" /> - </list> - </property> - <property name="handler"> - <bean class="org.apache.oodt.cas.cli.option.handler.ApplyToActionHandler"> - <property name="applyToActions"> - <list> - <bean class="org.apache.oodt.cas.cli.option.handler.ApplyToAction" - p:actionName="DeleteEmptyDirectories" p:methodName="setDirectoryRegex" /> - </list> - </property> - </bean> - </property> - </bean> -</beans> http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/protocol/api/src/main/resources/policy/protocol-config.xml ---------------------------------------------------------------------- diff --git a/protocol/api/src/main/resources/policy/protocol-config.xml b/protocol/api/src/main/resources/policy/protocol-config.xml deleted file mode 100644 index 0142004..0000000 --- a/protocol/api/src/main/resources/policy/protocol-config.xml +++ /dev/null @@ -1,31 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - 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. ---> -<!-- - - Author: bfoster - Description: ProtocolManager Configuration - ---> -<beans xmlns="http://www.springframework.org/schema/beans" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xmlns:p="http://www.springframework.org/schema/p" - xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"> - - <import resource="classpath*:/org/apache/oodt/cas/protocol/**/*-protocol-config.xml"/> - -</beans> http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/protocol/api/src/test/java/org/apache/oodt/cas/protocol/MockProtocol.java ---------------------------------------------------------------------- diff --git a/protocol/api/src/test/java/org/apache/oodt/cas/protocol/MockProtocol.java b/protocol/api/src/test/java/org/apache/oodt/cas/protocol/MockProtocol.java deleted file mode 100644 index 4677a77..0000000 --- a/protocol/api/src/test/java/org/apache/oodt/cas/protocol/MockProtocol.java +++ /dev/null @@ -1,130 +0,0 @@ -/* - * 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.oodt.cas.protocol; - -//JDK imports -import java.io.File; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -//OODT imports -import org.apache.oodt.cas.protocol.auth.Authentication; -import org.apache.oodt.cas.protocol.exceptions.ProtocolException; -import org.apache.oodt.cas.protocol.util.ProtocolFileFilter; - -/** - * Mock {@link Protocol} for testing - * - * @author bfoster - */ -public class MockProtocol implements Protocol { - - private boolean connected; - private ProtocolFile cwd; - private String factoryId; - - private List<ProtocolFile> deletedFiles; - private List<ProtocolFile> putFiles; - private List<ProtocolFile> getFiles; - private int timesConnected; - - public MockProtocol(String factoryId) { - connected = false; - this.factoryId = factoryId; - deletedFiles = new ArrayList<ProtocolFile>(); - putFiles = new ArrayList<ProtocolFile>(); - getFiles = new ArrayList<ProtocolFile>(); - timesConnected = 0; - } - - public String getFactoryId() { - return factoryId; - } - - public void connect(String host, Authentication authentication) - throws ProtocolException { - connected = true; - deletedFiles.clear(); - putFiles.clear(); - getFiles.clear(); - timesConnected++; - } - - public int getTimesConnected() { - return timesConnected; - } - - public void close() throws ProtocolException { - connected = false; - } - - public boolean connected() { - return connected; - } - - public void cd(ProtocolFile file) throws ProtocolException { - cwd = file; - } - - public void cdHome() throws ProtocolException { - cwd = new ProtocolFile("", true); - } - - public void cdRoot() throws ProtocolException { - cwd = new ProtocolFile("/", true); - } - - public void get(ProtocolFile fromFile, File toFile) - throws ProtocolException { - getFiles.add(fromFile); - } - - public List<ProtocolFile> getGetFiles() { - return getFiles; - } - - public void put(File fromFile, ProtocolFile toFile) - throws ProtocolException { - putFiles.add(toFile); - } - - public List<ProtocolFile> getPutFiles() { - return putFiles; - } - - public ProtocolFile pwd() throws ProtocolException { - return cwd; - } - - public List<ProtocolFile> ls() throws ProtocolException { - return Collections.emptyList(); - } - - public List<ProtocolFile> ls(ProtocolFileFilter filter) throws ProtocolException { - return Collections.emptyList(); - } - - public void delete(ProtocolFile file) throws ProtocolException { - deletedFiles.add(file); - } - - public List<ProtocolFile> getDeletedFiles() { - return deletedFiles; - } - -} http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/protocol/api/src/test/java/org/apache/oodt/cas/protocol/MockProtocolFactory.java ---------------------------------------------------------------------- diff --git a/protocol/api/src/test/java/org/apache/oodt/cas/protocol/MockProtocolFactory.java b/protocol/api/src/test/java/org/apache/oodt/cas/protocol/MockProtocolFactory.java deleted file mode 100644 index ee80362..0000000 --- a/protocol/api/src/test/java/org/apache/oodt/cas/protocol/MockProtocolFactory.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * 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.oodt.cas.protocol; - -//OODT imports -import org.apache.oodt.commons.spring.SpringSetIdInjectionType; - -/** - * Mock {@link ProtocolFactory} for testing - * - * @author bfoster - */ -public class MockProtocolFactory implements ProtocolFactory, SpringSetIdInjectionType { - - private String schema; - private String id; - - public MockProtocol newInstance() { - return new MockProtocol(id); - } - - public String getSchema() { - return schema; - } - - public void setSchema(String schema) { - this.schema = schema; - } - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } -} http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/protocol/api/src/test/java/org/apache/oodt/cas/protocol/TestProtocolFile.java ---------------------------------------------------------------------- diff --git a/protocol/api/src/test/java/org/apache/oodt/cas/protocol/TestProtocolFile.java b/protocol/api/src/test/java/org/apache/oodt/cas/protocol/TestProtocolFile.java deleted file mode 100644 index 0d7cdeb..0000000 --- a/protocol/api/src/test/java/org/apache/oodt/cas/protocol/TestProtocolFile.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * 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.oodt.cas.protocol; - -//JDK imports - -//JUnit imports -import junit.framework.TestCase; - -/** - * Test class for {@link ProtocolFile} - * - * @author bfoster - */ -public class TestProtocolFile extends TestCase { - - public void testInitialState() { - String filePath = ProtocolFile.SEPARATOR + "path" + ProtocolFile.SEPARATOR + "to" + ProtocolFile.SEPARATOR + "file"; - ProtocolFile pFile = new ProtocolFile(filePath, false); - assertEquals(filePath, pFile.getPath()); - assertEquals("file", pFile.getName()); - assertFalse(pFile.isDir()); - assertFalse(pFile.isRelative()); - - // Test Parent file - String parentPath = ProtocolFile.SEPARATOR + "path" + ProtocolFile.SEPARATOR + "to"; - assertEquals(parentPath, pFile.getParent().getPath()); - assertEquals("to", pFile.getParent().getName()); - assertTrue(pFile.getParent().isDir()); - assertFalse(pFile.getParent().isRelative()); - } - - public void testEquals() { - assertEquals(new ProtocolFile("/test/directory", true), new ProtocolFile( - new ProtocolFile("/test", true), "directory", true)); - assertEquals(new ProtocolFile(new ProtocolFile("/", true), "repo", true), new ProtocolFile("/repo", true)); - assertEquals(new ProtocolFile(new ProtocolFile("/", true), "", true), new ProtocolFile("/", true)); - } -} http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/protocol/api/src/test/java/org/apache/oodt/cas/protocol/auth/TestBasicAuthentication.java ---------------------------------------------------------------------- diff --git a/protocol/api/src/test/java/org/apache/oodt/cas/protocol/auth/TestBasicAuthentication.java b/protocol/api/src/test/java/org/apache/oodt/cas/protocol/auth/TestBasicAuthentication.java deleted file mode 100644 index ab40e7f..0000000 --- a/protocol/api/src/test/java/org/apache/oodt/cas/protocol/auth/TestBasicAuthentication.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * 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.oodt.cas.protocol.auth; - -//JUnit imports -import junit.framework.TestCase; - -/** - * Test class for {@link BasicAuthentication} - * - * @author bfoster - */ -public class TestBasicAuthentication extends TestCase { - - public void testInitialState() { - BasicAuthentication auth = new BasicAuthentication("user", "pass"); - assertEquals("user", auth.getUser()); - assertEquals("pass", auth.getPass()); - } - - public void testNullCase() { - try { - new BasicAuthentication(null, "pass"); - fail("Should have thrown IllegalArgumentException"); - }catch (IllegalArgumentException ignored) {} - try { - new BasicAuthentication("user", null); - fail("Should have thrown IllegalArgumentException"); - }catch (IllegalArgumentException ignored) {} - try { - new BasicAuthentication(null, null); - fail("Should have thrown IllegalArgumentException"); - }catch (IllegalArgumentException ignored) {} - } -} http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/protocol/api/src/test/java/org/apache/oodt/cas/protocol/auth/TestNoAuthentication.java ---------------------------------------------------------------------- diff --git a/protocol/api/src/test/java/org/apache/oodt/cas/protocol/auth/TestNoAuthentication.java b/protocol/api/src/test/java/org/apache/oodt/cas/protocol/auth/TestNoAuthentication.java deleted file mode 100644 index 51195e4..0000000 --- a/protocol/api/src/test/java/org/apache/oodt/cas/protocol/auth/TestNoAuthentication.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * 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.oodt.cas.protocol.auth; - -//JUnit imports -import junit.framework.TestCase; - -/** - * Test class for {@link NoAuthentication}. - * - * @author bfoster - */ -public class TestNoAuthentication extends TestCase { - - public void testInitialState() { - NoAuthentication auth = new NoAuthentication(); - assertEquals("", auth.getUser()); - assertEquals("", auth.getPass()); - } - -} http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/protocol/api/src/test/java/org/apache/oodt/cas/protocol/cli/action/MockProtocolCliAction.java ---------------------------------------------------------------------- diff --git a/protocol/api/src/test/java/org/apache/oodt/cas/protocol/cli/action/MockProtocolCliAction.java b/protocol/api/src/test/java/org/apache/oodt/cas/protocol/cli/action/MockProtocolCliAction.java deleted file mode 100644 index 351fc62..0000000 --- a/protocol/api/src/test/java/org/apache/oodt/cas/protocol/cli/action/MockProtocolCliAction.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * 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.oodt.cas.protocol.cli.action; - -//OODT imports -import org.apache.oodt.cas.cli.exception.CmdLineActionException; - -/** - * Mock class for {@ProtocolAction}. - * - * @author bfoster (Brian Foster) - */ -public class MockProtocolCliAction extends ProtocolCliAction { - - @Override - public void execute(ActionMessagePrinter printer) - throws CmdLineActionException { - } -} http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/protocol/api/src/test/java/org/apache/oodt/cas/protocol/cli/action/TestBasicVerifyCliAction.java ---------------------------------------------------------------------- diff --git a/protocol/api/src/test/java/org/apache/oodt/cas/protocol/cli/action/TestBasicVerifyCliAction.java b/protocol/api/src/test/java/org/apache/oodt/cas/protocol/cli/action/TestBasicVerifyCliAction.java deleted file mode 100644 index c46671f..0000000 --- a/protocol/api/src/test/java/org/apache/oodt/cas/protocol/cli/action/TestBasicVerifyCliAction.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * 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.oodt.cas.protocol.cli.action; - -//JDK imports -import java.net.URI; - -//JUnit imports -import junit.framework.TestCase; - -//OODT imports -import org.apache.oodt.cas.cli.action.CmdLineAction.ActionMessagePrinter; -import org.apache.oodt.cas.protocol.Protocol; -import org.apache.oodt.cas.protocol.auth.Authentication; -import org.apache.oodt.cas.protocol.config.MockSpringProtocolConfig; -import org.apache.oodt.cas.protocol.system.ProtocolManager; -import org.apache.oodt.cas.protocol.verify.ProtocolVerifier; - -/** - * Test class for {@link BasicVerifyCliAction} - * - * @author bfoster (Brian Foster) - */ -public class TestBasicVerifyCliAction extends TestCase { - - public void testVerification() throws Exception { - BasicVerifyCliAction bva = new BasicVerifyCliAction(); - bva.setSite("http://localhost"); - bva.setVerifier(new ProtocolVerifier() { - public boolean verify(Protocol protocol, URI site, - Authentication auth) { - return auth != null && site.toString().equals("http://localhost"); - } - }); - bva.setProtocolManager(new ProtocolManager(new MockSpringProtocolConfig())); - bva.execute(new ActionMessagePrinter()); - assertTrue(bva.getLastVerificationResults()); - } -} http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/protocol/api/src/test/java/org/apache/oodt/cas/protocol/cli/action/TestDownloadCliAction.java ---------------------------------------------------------------------- diff --git a/protocol/api/src/test/java/org/apache/oodt/cas/protocol/cli/action/TestDownloadCliAction.java b/protocol/api/src/test/java/org/apache/oodt/cas/protocol/cli/action/TestDownloadCliAction.java deleted file mode 100644 index 21dae0e..0000000 --- a/protocol/api/src/test/java/org/apache/oodt/cas/protocol/cli/action/TestDownloadCliAction.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * 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.oodt.cas.protocol.cli.action; - -//JDK imports -import java.net.URISyntaxException; - -//OODT imports -import org.apache.oodt.cas.cli.action.CmdLineAction.ActionMessagePrinter; -import org.apache.oodt.cas.protocol.MockProtocol; -import org.apache.oodt.cas.protocol.Protocol; -import org.apache.oodt.cas.protocol.ProtocolFile; -import org.apache.oodt.cas.protocol.config.MockSpringProtocolConfig; -import org.apache.oodt.cas.protocol.system.ProtocolManager; - -//JUnit imports -import junit.framework.TestCase; - -/** - * Test class for {@link DownloadCliAction}. - * - * @author bfoster (Brian Foster) - */ -public class TestDownloadCliAction extends TestCase { - - private ProtocolManager pm; - - @Override - public void setUp() { - pm = new ProtocolManager(new MockSpringProtocolConfig()); - } - - public void testCreateProtocol() throws URISyntaxException { - DownloadCliAction da = new DownloadCliAction(); - da.setUrl("http://localhost/some/file"); - Protocol protocol = da.createProtocol(pm); - assertNotNull(protocol); - assertTrue(protocol instanceof MockProtocol); - assertEquals("http1", ((MockProtocol) protocol).getFactoryId()); - } - - public void testCreateProtocolFile() throws URISyntaxException { - DownloadCliAction da = new DownloadCliAction(); - da.setUrl("http://localhost/some/file"); - ProtocolFile file = da.createProtocolFile(); - assertNotNull(file); - assertEquals("/some/file", file.getPath()); - assertFalse(file.isRelative()); - assertFalse(file.isDir()); - } - - public void testFileDownload() throws Exception { - DownloadCliAction da = new DownloadCliAction(); - da.setUrl("http://localhost/some/file"); - da.setProtocolManager(pm); - da.execute(new ActionMessagePrinter()); - assertNotNull(da.getUsedProtocol()); - assertTrue(da.getUsedProtocol() instanceof MockProtocol); - assertEquals(1, ((MockProtocol) da.getUsedProtocol()).getGetFiles().size()); - assertEquals("/some/file", ((MockProtocol) da.getUsedProtocol()).getGetFiles().get(0).getPath()); - } -} http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/protocol/api/src/test/java/org/apache/oodt/cas/protocol/cli/action/TestProtocolCliAction.java ---------------------------------------------------------------------- diff --git a/protocol/api/src/test/java/org/apache/oodt/cas/protocol/cli/action/TestProtocolCliAction.java b/protocol/api/src/test/java/org/apache/oodt/cas/protocol/cli/action/TestProtocolCliAction.java deleted file mode 100644 index ab88c45..0000000 --- a/protocol/api/src/test/java/org/apache/oodt/cas/protocol/cli/action/TestProtocolCliAction.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * 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.oodt.cas.protocol.cli.action; - -//JDK imports -import java.net.URISyntaxException; - -//JUnit imports -import junit.framework.TestCase; - -/** - * Test class for {@link ProtocolCliAction}. - * - * @author bfoster (Brian Foster) - */ -public class TestProtocolCliAction extends TestCase { - - public void testInitialState() throws URISyntaxException { - MockProtocolCliAction action = new MockProtocolCliAction(); - action.setUser("user"); - action.setPass("pass"); - action.setSite("http://some-site"); - assertEquals("user", action.getAuthentication().getUser()); - assertEquals("pass", action.getAuthentication().getPass()); - assertEquals("http://some-site", action.getSite().toString()); - } -} http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/protocol/api/src/test/java/org/apache/oodt/cas/protocol/config/MockSpringProtocolConfig.java ---------------------------------------------------------------------- diff --git a/protocol/api/src/test/java/org/apache/oodt/cas/protocol/config/MockSpringProtocolConfig.java b/protocol/api/src/test/java/org/apache/oodt/cas/protocol/config/MockSpringProtocolConfig.java deleted file mode 100644 index e4c7ceb..0000000 --- a/protocol/api/src/test/java/org/apache/oodt/cas/protocol/config/MockSpringProtocolConfig.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * 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.oodt.cas.protocol.config; - -import java.util.List; -import java.util.Map; - -import org.apache.oodt.cas.protocol.ProtocolFactory; - -/** - * Mock {@link SpringProtocolConfig} - * - * @author bfoster - */ -public class MockSpringProtocolConfig extends SpringProtocolConfig { - - private static final String CONFIG_FILE = "src/test/resources/test-protocol-config.xml"; - - public MockSpringProtocolConfig() { - super(CONFIG_FILE); - } - - public String getConfigFile() { - return CONFIG_FILE; - } - - public Map<String, List<ProtocolFactory>> getFactoryMap() { - return factoryMap; - } -} http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/protocol/api/src/test/java/org/apache/oodt/cas/protocol/system/TestProtocolManager.java ---------------------------------------------------------------------- diff --git a/protocol/api/src/test/java/org/apache/oodt/cas/protocol/system/TestProtocolManager.java b/protocol/api/src/test/java/org/apache/oodt/cas/protocol/system/TestProtocolManager.java deleted file mode 100644 index b6184ad..0000000 --- a/protocol/api/src/test/java/org/apache/oodt/cas/protocol/system/TestProtocolManager.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * 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.oodt.cas.protocol.system; - -//JDK imports -import java.net.URI; -import java.net.URISyntaxException; - -//OODT imports -import org.apache.oodt.cas.protocol.MockProtocol; -import org.apache.oodt.cas.protocol.Protocol; -import org.apache.oodt.cas.protocol.auth.Authentication; -import org.apache.oodt.cas.protocol.auth.NoAuthentication; -import org.apache.oodt.cas.protocol.config.MockSpringProtocolConfig; -import org.apache.oodt.cas.protocol.verify.ProtocolVerifier; - -//JUnit imports -import junit.framework.TestCase; - -/** - * Test class for {@link ProtocolManager}. - * - * @author bfoster - */ -public class TestProtocolManager extends TestCase { - - private ProtocolManager protocolManager; - - @Override - public void setUp() { - protocolManager = new ProtocolManager(new MockSpringProtocolConfig()); - } - - public void testInitialState() { - assertNotNull(protocolManager.getConfig()); - } - - public void testProtocolFactoryMapping() throws URISyntaxException { - Protocol protocol = protocolManager.getProtocolBySite(new URI("ftp://localhost"), new NoAuthentication(), null); - assertNotNull(protocol); - assertTrue(protocol instanceof MockProtocol); - MockProtocol mockProtocol = (MockProtocol) protocol; - assertEquals("ftp1", mockProtocol.getFactoryId()); - - //test that ftp1 was memorized and is returned again even though a Verifier was supplied this time that would return ftp3 - protocol = protocolManager.getProtocolBySite(new URI("ftp://localhost"), new NoAuthentication(), new ProtocolVerifier() { - public boolean verify(Protocol protocol, URI site, - Authentication auth) { - if (protocol instanceof MockProtocol) { - MockProtocol mockProtocol = (MockProtocol) protocol; - return mockProtocol.getFactoryId().equals("ftp3"); - } else { - return false; - } - } - }); - assertNotNull(protocol); - assertTrue(protocol instanceof MockProtocol); - mockProtocol = (MockProtocol) protocol; - assertEquals("ftp1", mockProtocol.getFactoryId()); - - } - - public void testVerifier() throws URISyntaxException { - Protocol protocol = protocolManager.getProtocolBySite(new URI("ftp://localhost"), new NoAuthentication(), new ProtocolVerifier() { - public boolean verify(Protocol protocol, URI site, - Authentication auth) { - if (protocol instanceof MockProtocol) { - MockProtocol mockProtocol = (MockProtocol) protocol; - return mockProtocol.getFactoryId().equals("ftp3"); - } else { - return false; - } - } - }); - assertTrue(protocol instanceof MockProtocol); - MockProtocol mockProtocol = (MockProtocol) protocol; - assertEquals("ftp3", mockProtocol.getFactoryId()); - } - -} http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/protocol/api/src/test/resources/test-protocol-config.xml ---------------------------------------------------------------------- diff --git a/protocol/api/src/test/resources/test-protocol-config.xml b/protocol/api/src/test/resources/test-protocol-config.xml deleted file mode 100644 index ef84b73..0000000 --- a/protocol/api/src/test/resources/test-protocol-config.xml +++ /dev/null @@ -1,53 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - 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. ---> -<!-- - - Author: bfoster - Description: ProtocolManager Configuration - ---> -<beans xmlns="http://www.springframework.org/schema/beans" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xmlns:p="http://www.springframework.org/schema/p" - xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"> - - <bean class="org.apache.oodt.commons.spring.postprocessor.SetIdBeanPostProcessor"/> - - <!-- list ProtocolFactories here --> - <bean id="ftp1" class="org.apache.oodt.cas.protocol.MockProtocolFactory"> - <property name="schema" value="ftp"/> - </bean> - <bean id="ftp2" class="org.apache.oodt.cas.protocol.MockProtocolFactory"> - <property name="schema" value="ftp"/> - </bean> - <bean id="ftp3" class="org.apache.oodt.cas.protocol.MockProtocolFactory"> - <property name="schema" value="ftp"/> - </bean> - - <bean id="sftp1" class="org.apache.oodt.cas.protocol.MockProtocolFactory"> - <property name="schema" value="sftp"/> - </bean> - <bean id="sftp2" class="org.apache.oodt.cas.protocol.MockProtocolFactory"> - <property name="schema" value="sftp"/> - </bean> - - <bean id="http1" class="org.apache.oodt.cas.protocol.MockProtocolFactory"> - <property name="schema" value="http"/> - </bean> - -</beans> http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/protocol/ftp/.gitignore ---------------------------------------------------------------------- diff --git a/protocol/ftp/.gitignore b/protocol/ftp/.gitignore deleted file mode 100644 index b54523f..0000000 --- a/protocol/ftp/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/maven-eclipse.xml http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/protocol/ftp/pom.xml ---------------------------------------------------------------------- diff --git a/protocol/ftp/pom.xml b/protocol/ftp/pom.xml deleted file mode 100644 index 7c500d5..0000000 --- a/protocol/ftp/pom.xml +++ /dev/null @@ -1,122 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- 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. --> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> - - <modelVersion>4.0.0</modelVersion> - <parent> - <groupId>org.apache.oodt</groupId> - <artifactId>oodt-core</artifactId> - <version>1.1-SNAPSHOT</version> - <relativePath>../../core/pom.xml</relativePath> - </parent> - <artifactId>cas-protocol-ftp</artifactId> - <name>CAS Protocol FTP Implementation</name> - <!-- All dependencies should be listed in core/pom.xml and be ordered alphabetically by package and artifact. - Once the dependency is in the core pom, it can then be used in other modules without the version tags. - For example, within core/pom.xml: - - <dependency> - <groupId>com.amazonaws</groupId> - <artifactId>aws-java-sdk</artifactId> - <version>1.7.4</version> - </dependency> - - Elsewhere in the platform: - <dependency> - <groupId>com.amazonaws</groupId> - <artifactId>aws-java-sdk</artifactId> - </dependency> - - Where possible the same dependency version should be used across the whole platform but if required the version - can be overridden in a specific pom and should have a comment explaing why the version has been overridden - --> - <dependencies> - <dependency> - <groupId>commons-net</groupId> - <artifactId>commons-net</artifactId> - <version>1.4.0</version> - </dependency> - <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.apache.ftpserver</groupId> - <artifactId>ftpserver-core</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.apache.oodt</groupId> - <artifactId>cas-protocol-api</artifactId> - <version>${project.parent.version}</version> - </dependency> - <dependency> - <groupId>org.jglobus</groupId> - <artifactId>gss</artifactId> - </dependency> - <dependency> - <groupId>org.jglobus</groupId> - <artifactId>JGlobus-GridFTP</artifactId> - </dependency> - <dependency> - <groupId>org.mockito</groupId> - <artifactId>mockito-all</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.slf4j</groupId> - <artifactId>slf4j-log4j12</artifactId> - <scope>test</scope> - </dependency> - </dependencies> - <build> - <resources> - <resource> - <targetPath>org/apache/oodt/cas/protocol/ftp</targetPath> - <directory>${basedir}/src/main/resources/policy</directory> - <includes> - <include>ftp-protocol-config.xml</include> - </includes> - </resource> - </resources> - </build> - <profiles> - <profile> - <id>audit</id> - <activation> - <activeByDefault>false</activeByDefault> - </activation> - <build> - <plugins> - <plugin> - <groupId>org.codehaus.mojo</groupId> - <artifactId>rat-maven-plugin</artifactId> - <configuration> - <excludes> - <exclude>**/resources/examples/**/*</exclude> - </excludes> - </configuration> - <executions> - <execution> - <goals> - <goal>check</goal> - </goals> - <phase>verify</phase> - </execution> - </executions> - </plugin> - </plugins> - </build> - </profile> - </profiles> -</project> http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/protocol/ftp/src/main/java/org/apache/oodt/cas/protocol/ftp/CogJGlobusFtpProtocol.java ---------------------------------------------------------------------- diff --git a/protocol/ftp/src/main/java/org/apache/oodt/cas/protocol/ftp/CogJGlobusFtpProtocol.java b/protocol/ftp/src/main/java/org/apache/oodt/cas/protocol/ftp/CogJGlobusFtpProtocol.java deleted file mode 100644 index 3da3636..0000000 --- a/protocol/ftp/src/main/java/org/apache/oodt/cas/protocol/ftp/CogJGlobusFtpProtocol.java +++ /dev/null @@ -1,226 +0,0 @@ -/* - * 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.oodt.cas.protocol.ftp; - -//OODT imports -import org.apache.oodt.cas.protocol.Protocol; -import org.apache.oodt.cas.protocol.ProtocolFile; -import org.apache.oodt.cas.protocol.auth.Authentication; -import org.apache.oodt.cas.protocol.exceptions.ProtocolException; -import org.apache.oodt.cas.protocol.util.ProtocolFileFilter; - -//Globus imports -import org.globus.ftp.FTPClient; -import org.globus.ftp.FileInfo; - -//JDK imports -import java.io.File; -import java.util.List; -import java.util.Vector; - -/** - * FTP implementation of a {@link Protocol} - * - * @author bfoster - */ -public class CogJGlobusFtpProtocol implements Protocol { - - public static final int PORT = 21; - private FTPClient ftp; - private boolean isConnected; - private int port; - private String homeDir; - - public CogJGlobusFtpProtocol() { - this(PORT); - } - - public CogJGlobusFtpProtocol(int port) { - this.port = port; - } - - public void cd(ProtocolFile file) throws ProtocolException { - try { - ftp.changeDir(file.getPath()); - } catch (Exception e) { - throw new ProtocolException("Failed to cd to " + file + " : " - + e.getMessage()); - } - } - - public void cdRoot() throws ProtocolException { - cd(new ProtocolFile(ProtocolFile.SEPARATOR, true)); - } - - public void cdHome() throws ProtocolException { - cd(new ProtocolFile(homeDir, true)); - } - - public void connect(String host, Authentication auth) throws ProtocolException { - try { - ftp = new FTPClient(host, port); - } catch (Exception e) { - throw new ProtocolException("Failed to connect to: " + host + " : " - + e.getMessage(), e); - } - isConnected = true; - - try { - ftp.authorize(auth.getUser(), auth.getPass()); - ftp.setActive(ftp.setLocalPassive()); - homeDir = ftp.getCurrentDir(); - } catch (Exception e) { - throw new ProtocolException("Failed to login to: " + host + " : " - + e.getMessage(), e); - } - } - - public void close() throws ProtocolException { - try { - ftp.close(); - isConnected = false; - } catch (Exception e) { - throw new ProtocolException("Error disconnecting from " - + ftp.getHost() + " : " + e.getMessage()); - } - } - - public void get(ProtocolFile fromFile, File toFile) - throws ProtocolException { - try { - ftp.setActive(ftp.setLocalPassive()); - ftp.get(fromFile.getPath(), toFile); - } catch (Exception e) { - throw new ProtocolException("Failed to download: " + fromFile.getName() - + " : " + e.getMessage()); - } - } - - public void put(File fromFile, ProtocolFile toFile) throws ProtocolException { - try { - ftp.put(fromFile, toFile.getPath(), false); - }catch (Exception e) { - throw new ProtocolException("Failed to put file '" + fromFile + "' : " + e.getMessage(), e); - } - } - - /** - * SetActive - * Sets the FTP Active Protocol - * Package protected so we can test the non FTP server parts of the codebase. - * @throws ProtocolException - */ - protected void setActive() throws ProtocolException { - try { - ftp.setActive(ftp.setLocalPassive()); - } catch (Exception e) { - throw new ProtocolException("Failed to set ftp active : " - + e.getMessage()); - } - } - - /** - * ftpList - * Gets a file list from the FTP Server - * Package protected so we can test the non server portion of the code. - * @param filter - * @param modifier - * @return - */ - protected Vector ftpList(String filter, String modifier) throws ProtocolException { - try { - return ftp.list(filter, modifier); - } catch (Exception e) { - throw new ProtocolException("Failed to get list of files : " - + e.getMessage()); - } - - } - public List<ProtocolFile> ls() throws ProtocolException { - try { - setActive(); - @SuppressWarnings("unchecked") - Vector<FileInfo> fileList = (Vector<FileInfo>) ftpList("*", null); - Vector<ProtocolFile> returnList = new Vector<ProtocolFile>(); - for (FileInfo file : fileList) { - returnList.add(new ProtocolFile(this.pwd(), file.getName(), file.isDirectory())); - } - return returnList; - } catch (Exception e) { - throw new ProtocolException("Failed to get list of files : " - + e.getMessage()); - } - } - - public List<ProtocolFile> ls(ProtocolFileFilter filter) throws ProtocolException { - try { - ftp.setActive(ftp.setLocalPassive()); - @SuppressWarnings("unchecked") - Vector<FileInfo> fileList = (Vector<FileInfo>) ftp.list("*", null); - Vector<ProtocolFile> returnList = new Vector<ProtocolFile>(); - for (FileInfo file : fileList) { - ProtocolFile pFile = new ProtocolFile(this.pwd(), file.getName(), file.isDirectory()); - if (filter.accept(pFile)) { - returnList.add(pFile); - } - } - return returnList; - } catch (Exception e) { - throw new ProtocolException("Failed to get list of files : " - + e.getMessage()); - } - } - - /** - * Returns the current Directory. - * Package protected so we can test the non ftp parts of the codebase. - * @return - * @throws ProtocolException - */ - protected String getCurentDir() throws ProtocolException { - try { - return ftp.getCurrentDir(); - } catch (Exception e) { - throw new ProtocolException("Failed to get current directory : " - + e.getMessage()); - } - - - } - - public ProtocolFile pwd() throws ProtocolException { - try { - return new ProtocolFile(getCurentDir(), true); - } catch (Exception e) { - throw new ProtocolException("Failed to pwd : " + e.getMessage()); - } - } - - public boolean connected() { - return isConnected; - } - - public void delete(ProtocolFile file) throws ProtocolException { - try { - ftp.deleteFile(file.getPath()); - } catch (Exception e) { - throw new ProtocolException("Failed to download file '" - + file.getPath() + "' : " + e.getMessage(), e); - } - } - -} http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/protocol/ftp/src/main/java/org/apache/oodt/cas/protocol/ftp/CogJGlobusFtpProtocolFactory.java ---------------------------------------------------------------------- diff --git a/protocol/ftp/src/main/java/org/apache/oodt/cas/protocol/ftp/CogJGlobusFtpProtocolFactory.java b/protocol/ftp/src/main/java/org/apache/oodt/cas/protocol/ftp/CogJGlobusFtpProtocolFactory.java deleted file mode 100644 index 9b96981..0000000 --- a/protocol/ftp/src/main/java/org/apache/oodt/cas/protocol/ftp/CogJGlobusFtpProtocolFactory.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * 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.oodt.cas.protocol.ftp; - -//OODT imports -import org.apache.oodt.cas.protocol.ProtocolFactory; - -/** - * Factory for creating {@link CogJGlobusFtpProtocol}s - * - * @author bfoster - * @version $Revision$ - * - */ -public class CogJGlobusFtpProtocolFactory implements ProtocolFactory { - - public CogJGlobusFtpProtocol newInstance() { - return new CogJGlobusFtpProtocol(); - } - - public String getSchema() { - return "ftp"; - } - -} http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/protocol/ftp/src/main/java/org/apache/oodt/cas/protocol/ftp/CommonsNetFtpProtocol.java ---------------------------------------------------------------------- diff --git a/protocol/ftp/src/main/java/org/apache/oodt/cas/protocol/ftp/CommonsNetFtpProtocol.java b/protocol/ftp/src/main/java/org/apache/oodt/cas/protocol/ftp/CommonsNetFtpProtocol.java deleted file mode 100644 index 06663e1..0000000 --- a/protocol/ftp/src/main/java/org/apache/oodt/cas/protocol/ftp/CommonsNetFtpProtocol.java +++ /dev/null @@ -1,246 +0,0 @@ -/* - * 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.oodt.cas.protocol.ftp; - -//JDK imports -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.OutputStream; -import java.util.LinkedList; -import java.util.List; - -//APACHE imports -import org.apache.commons.net.ftp.FTPClient; -import org.apache.commons.net.ftp.FTPFile; -import org.apache.oodt.cas.protocol.Protocol; -import org.apache.oodt.cas.protocol.ProtocolFile; -import org.apache.oodt.cas.protocol.auth.Authentication; -import org.apache.oodt.cas.protocol.exceptions.ProtocolException; -import org.apache.oodt.cas.protocol.util.ProtocolFileFilter; - -/** - * This class is responsible for FTP transfers. It is built as a wrapper around - * Apache's FTPClient class in order to connect it into the Crawler's Protocol - * infrastructure. - * - * @author bfoster - * - */ -public class CommonsNetFtpProtocol implements Protocol { - - private final FTPClient ftp; - private String homeDir; - - /** - * Creates a new FtpClient - */ - public CommonsNetFtpProtocol() { - ftp = new FTPClient(); - } - - /** - * {@inheritDoc} - */ - public void connect(String host, Authentication auth) - throws ProtocolException { - // server cannot be null - if (host == null) { - throw new ProtocolException("Tried to connect to server == NULL"); - } - - try { - ftp.connect(host); - ftp.enterLocalPassiveMode(); - } catch (Exception e) { - throw new ProtocolException("Failed to connect to server : " - + e.getMessage()); - } - - try { - // try logging in - if (!ftp.login(auth.getUser(), auth.getPass())) { - throw new ProtocolException("Failed logging into host " + host - + " as user " + auth.getUser()); - } - - // set file type to binary - ftp.setFileType(FTPClient.BINARY_FILE_TYPE); - - homeDir = ftp.printWorkingDirectory(); - } catch (Exception e) { - // login failed - throw new ProtocolException("Exception thrown while logging into host " - + host + " as user " + auth.getUser()); - } - } - - /** - * {@inheritDoc} - */ - public ProtocolFile pwd() throws ProtocolException { - try { - return new ProtocolFile(ftp.printWorkingDirectory(), true); - } catch (Exception e) { - throw new ProtocolException("Failed to pwd : " + e.getMessage()); - } - } - - public List<ProtocolFile> ls() throws ProtocolException { - try { - String path = this.pwd().getPath(); - FTPFile[] files = ftp.listFiles(); - List<ProtocolFile> returnFiles = new LinkedList<ProtocolFile>(); - for (FTPFile file : files) { - if (file == null) { - continue; - } - returnFiles.add(new ProtocolFile(path + "/" + file.getName(), file - .isDirectory())); - } - return returnFiles; - } catch (Exception e) { - throw new ProtocolException("Failed to get file list : " + e.getMessage()); - } - } - - /** - * {@inheritDoc} - */ - public List<ProtocolFile> ls(ProtocolFileFilter filter) - throws ProtocolException { - try { - FTPFile[] files = ftp.listFiles(); - List<ProtocolFile> returnFiles = new LinkedList<ProtocolFile>(); - for (FTPFile file : files) { - if (file == null) { - continue; - } - String path = this.pwd().getPath(); - ProtocolFile pFile = new ProtocolFile(path + "/" + file.getName(), file - .isDirectory()); - if (filter.accept(pFile)) { - returnFiles.add(pFile); - } - } - return returnFiles; - } catch (Exception e) { - throw new ProtocolException("Failed to get file list : " + e.getMessage()); - } - } - - /** - * {@inheritDoc} - */ - public void get(ProtocolFile fromFile, File toFile) throws ProtocolException { - // file or toLocalFile cannot be null - if (fromFile == null || toFile == null) { - throw new ProtocolException( - "Can't download file -> ProtocolFile == null || toLocalFile == null"); - } - - // download file - OutputStream os = null; - try { - os = new FileOutputStream(toFile); - if (!ftp.retrieveFile(fromFile.getName(), os)) { - throw new ProtocolException("Failed to download file " - + fromFile.getName()); - } - } catch (Exception e) { - // download failed - toFile.delete(); - throw new ProtocolException("FAILED to download: " + fromFile.getName() - + " : " + e.getMessage(), e); - } finally { - // close output stream - if (os != null) { - try { - os.close(); - } catch (Exception e) { - toFile.delete(); - throw new ProtocolException("Failed to close outputstream : " - + e.getMessage(), e); - } - } - } - } - - /** - * {@inheritDoc} - */ - public void put(File fromFile, ProtocolFile toFile) throws ProtocolException { - try { - ftp.storeFile(toFile.getPath(), new FileInputStream(fromFile)); - } catch (Exception e) { - throw new ProtocolException("Failed to put file '" + fromFile + "' : " - + e.getMessage(), e); - } - } - - /** - * {@inheritDoc} - */ - public void cd(ProtocolFile file) throws ProtocolException { - try { - if (!ftp.changeWorkingDirectory(file.getPath())) { - throw new Exception("Directory change method returned false"); - } - } catch (Exception e) { - throw new ProtocolException("Failed to cd to " + file.getPath() + " : " - + e.getMessage()); - } - } - - public void cdRoot() throws ProtocolException { - cd(new ProtocolFile(ProtocolFile.SEPARATOR, true)); - } - - public void cdHome() throws ProtocolException { - cd(new ProtocolFile(homeDir, true)); - } - - /** - * {@inheritDoc} - */ - public void close() throws ProtocolException { - try { - ftp.disconnect(); - } catch (Exception e) { - throw new ProtocolException("Failed to disconnect from server"); - } - } - - /** - * {@inheritDoc} - */ - public boolean connected() { - return ftp.isConnected(); - } - - /** - * {@inheritDoc} - */ - public void delete(ProtocolFile file) throws ProtocolException { - try { - ftp.deleteFile(file.getPath()); - } catch (Exception e) { - throw new ProtocolException("Failed to delete file '" + file.getPath() - + "' : " + e.getMessage(), e); - } - } -} http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/protocol/ftp/src/main/java/org/apache/oodt/cas/protocol/ftp/CommonsNetFtpProtocolFactory.java ---------------------------------------------------------------------- diff --git a/protocol/ftp/src/main/java/org/apache/oodt/cas/protocol/ftp/CommonsNetFtpProtocolFactory.java b/protocol/ftp/src/main/java/org/apache/oodt/cas/protocol/ftp/CommonsNetFtpProtocolFactory.java deleted file mode 100644 index 90cbd42..0000000 --- a/protocol/ftp/src/main/java/org/apache/oodt/cas/protocol/ftp/CommonsNetFtpProtocolFactory.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * 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.oodt.cas.protocol.ftp; - -//OODT imports -import org.apache.oodt.cas.protocol.ProtocolFactory; - -/** - * Constructs new {@link CommonsNetFtpProtocol}s. - * - * @author bfoster - * @version $Revision$ - */ -public class CommonsNetFtpProtocolFactory implements ProtocolFactory { - - public CommonsNetFtpProtocol newInstance() { - return new CommonsNetFtpProtocol(); - } - - public String getSchema() { - return "ftp"; - } - -} http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/protocol/ftp/src/main/resources/policy/ftp-protocol-config.xml ---------------------------------------------------------------------- diff --git a/protocol/ftp/src/main/resources/policy/ftp-protocol-config.xml b/protocol/ftp/src/main/resources/policy/ftp-protocol-config.xml deleted file mode 100644 index 65b4ec4..0000000 --- a/protocol/ftp/src/main/resources/policy/ftp-protocol-config.xml +++ /dev/null @@ -1,32 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - 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. ---> -<!-- - - Author: bfoster - Description: ProtocolManager Configuration - ---> -<beans xmlns="http://www.springframework.org/schema/beans" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xmlns:p="http://www.springframework.org/schema/p" - xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"> - - <bean class="org.apache.oodt.cas.protocol.ftp.CogJGlobusFtpProtocolFactory"/> - <bean class="org.apache.oodt.cas.protocol.ftp.CommonsNetFtpProtocolFactory"/> - -</beans> http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/protocol/ftp/src/test/java/org/apache/oodt/cas/protocol/ftp/TestCogJGlobusFtpProtocol.java ---------------------------------------------------------------------- diff --git a/protocol/ftp/src/test/java/org/apache/oodt/cas/protocol/ftp/TestCogJGlobusFtpProtocol.java b/protocol/ftp/src/test/java/org/apache/oodt/cas/protocol/ftp/TestCogJGlobusFtpProtocol.java deleted file mode 100644 index 379276f..0000000 --- a/protocol/ftp/src/test/java/org/apache/oodt/cas/protocol/ftp/TestCogJGlobusFtpProtocol.java +++ /dev/null @@ -1,137 +0,0 @@ -/* - * 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.oodt.cas.protocol.ftp; - -//JUnit imports -import java.io.File; -import java.util.List; -import java.util.Vector; - -//APACHE imports -import org.apache.ftpserver.ConnectionConfigFactory; -import org.apache.ftpserver.DataConnectionConfigurationFactory; -import org.apache.ftpserver.FtpServer; -import org.apache.ftpserver.FtpServerFactory; -import org.apache.ftpserver.listener.ListenerFactory; -import org.apache.ftpserver.usermanager.ClearTextPasswordEncryptor; -import org.apache.ftpserver.usermanager.PropertiesUserManagerFactory; - -//OODT imports -import org.apache.oodt.cas.protocol.ProtocolFile; -import org.apache.oodt.cas.protocol.auth.BasicAuthentication; -import org.apache.oodt.cas.protocol.exceptions.ProtocolException; - -//JUnit imports -import junit.framework.TestCase; -import org.globus.ftp.FileInfo; -import org.mockito.Mockito; -import org.mockito.invocation.InvocationOnMock; -import org.mockito.stubbing.Answer; - -import static org.mockito.Mockito.spy; - -/** - * Test class for {@link CogJGlobusFtpProtocol}. - * - * @author bfoster - */ -public class TestCogJGlobusFtpProtocol extends TestCase { - - private static final int PORT = 9000; - private FtpServer server; - private static final File USERS_FILE = new File("src/test/resources/users.properties"); - - @Override - public void setUp() throws Exception { - assertTrue(USERS_FILE.getAbsolutePath() + " must exist", - USERS_FILE.exists()); - - FtpServerFactory serverFactory = new FtpServerFactory(); - - serverFactory.setConnectionConfig(new ConnectionConfigFactory() - .createConnectionConfig()); - - ListenerFactory listenerFactory = new ListenerFactory(); - - listenerFactory.setPort(PORT); - - listenerFactory - .setDataConnectionConfiguration(new DataConnectionConfigurationFactory() - .createDataConnectionConfiguration()); - - serverFactory.addListener("default", listenerFactory.createListener()); - - PropertiesUserManagerFactory umFactory = new PropertiesUserManagerFactory(); - umFactory.setPasswordEncryptor(new ClearTextPasswordEncryptor()); - umFactory.setFile(USERS_FILE); - - serverFactory.setUserManager(umFactory.createUserManager()); - - server = serverFactory.createServer(); - //server.start(); - } - - @Override - public void tearDown() { - server.stop(); - } - - public void testLSandCDandPWD() throws ProtocolException { - - CogJGlobusFtpProtocol ftpProtocol = spy(new CogJGlobusFtpProtocol(PORT)); - BasicAuthentication auth = new BasicAuthentication("anonymous", "password"); - - /** Mocking server responses to prevent server failure **/ - - Mockito.doReturn("test/resources").when(ftpProtocol).getCurentDir(); - - Vector<FileInfo> vector = new Vector<FileInfo>(); - FileInfo file = new FileInfo(); - file.setName("users.properties"); - byte b = 1; - file.setFileType(b); - vector.add(file); - - Mockito.doAnswer(new Answer() { - public Object answer(InvocationOnMock invocation) { - return null; - }}).when(ftpProtocol).setActive(); - - Mockito.doReturn(vector).when(ftpProtocol).ftpList("*", null); - - Mockito.doAnswer(new Answer() { - public Object answer(InvocationOnMock invocation) { - return null; - }}).when(ftpProtocol).connect("localhost", auth); - - Mockito.doAnswer(new Answer() { - public Object answer(InvocationOnMock invocation) { - return null; - }}).when(ftpProtocol).cd(new ProtocolFile("test/resources", true)); - - - - ftpProtocol.connect("localhost", auth); - - - ftpProtocol.cd(new ProtocolFile("test/resources", true)); - - List<ProtocolFile> lsResults = ftpProtocol.ls(); - assertTrue(lsResults.contains(new ProtocolFile(ftpProtocol.pwd(), "users.properties", false))); - } - -} http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/protocol/ftp/src/test/resources/users.properties ---------------------------------------------------------------------- diff --git a/protocol/ftp/src/test/resources/users.properties b/protocol/ftp/src/test/resources/users.properties deleted file mode 100644 index c4ace0b..0000000 --- a/protocol/ftp/src/test/resources/users.properties +++ /dev/null @@ -1,26 +0,0 @@ -# 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. - -ftpserver.user.anonymous.userpassword= -ftpserver.user.anonymous.maxloginperip=2 -ftpserver.user.anonymous.uploadrate=4800 -ftpserver.user.anonymous.writepermission=false -ftpserver.user.anonymous.maxloginnumber=20 -ftpserver.user.anonymous.enableflag=true -ftpserver.user.anonymous.homedirectory=src -ftpserver.user.anonymous.idletime=300 -ftpserver.user.anonymous.downloadrate=4800 http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/protocol/http/.gitignore ---------------------------------------------------------------------- diff --git a/protocol/http/.gitignore b/protocol/http/.gitignore deleted file mode 100644 index b54523f..0000000 --- a/protocol/http/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/maven-eclipse.xml
