Author: bfoster
Date: Fri May 27 21:41:07 2011
New Revision: 1128471

URL: http://svn.apache.org/viewvc?rev=1128471&view=rev
Log:

- unit-tests

-------------

OODT-194

Added:
    oodt/branches/cas-protocol-api/src/main/assembly/
    oodt/branches/cas-protocol-api/src/main/assembly/assembly.xml   (with props)
    
oodt/branches/cas-protocol-api/src/main/resources/policy/protocol-action-beans.xml
   (with props)
    
oodt/branches/cas-protocol-api/src/main/resources/policy/protocol-cmd-line-beans.xml
   (with props)
    oodt/branches/cas-protocol-api/src/test/
    oodt/branches/cas-protocol-api/src/test/org/
    oodt/branches/cas-protocol-api/src/test/org/apache/
    oodt/branches/cas-protocol-api/src/test/org/apache/oodt/
    oodt/branches/cas-protocol-api/src/test/org/apache/oodt/cas/
    oodt/branches/cas-protocol-api/src/test/org/apache/oodt/cas/protocol/
    
oodt/branches/cas-protocol-api/src/test/org/apache/oodt/cas/protocol/MockProtocol.java
   (with props)
    
oodt/branches/cas-protocol-api/src/test/org/apache/oodt/cas/protocol/MockProtocolFactory.java
   (with props)
    
oodt/branches/cas-protocol-api/src/test/org/apache/oodt/cas/protocol/TestProtocolFile.java
   (with props)
    oodt/branches/cas-protocol-api/src/test/org/apache/oodt/cas/protocol/auth/
    
oodt/branches/cas-protocol-api/src/test/org/apache/oodt/cas/protocol/auth/TestBasicAuthentication.java
   (with props)
    
oodt/branches/cas-protocol-api/src/test/org/apache/oodt/cas/protocol/auth/TestNoAuthentication.java
   (with props)
    oodt/branches/cas-protocol-api/src/test/org/apache/oodt/cas/protocol/config/
    
oodt/branches/cas-protocol-api/src/test/org/apache/oodt/cas/protocol/config/MockSpringProtocolConfig.java
   (with props)
    oodt/branches/cas-protocol-api/src/test/org/apache/oodt/cas/protocol/system/
    
oodt/branches/cas-protocol-api/src/test/org/apache/oodt/cas/protocol/system/TestProtocolManager.java
   (with props)
    oodt/branches/cas-protocol-api/src/testdata/
    oodt/branches/cas-protocol-api/src/testdata/test-protocol-config.xml   
(with props)
Modified:
    oodt/branches/cas-protocol-api/pom.xml
    
oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/ProtocolFile.java
    
oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/action/DownloadAction.java
    
oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/auth/Authentication.java
    
oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/auth/BasicAuthentication.java
    
oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/auth/NoAuthentication.java
    
oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/config/SpringProtocolConfig.java
    
oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/system/CLProtocolManager.java
    
oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/system/ProtocolManager.java
    oodt/branches/cas-protocol-api/src/main/resources/policy/protocol-config.xml

Modified: oodt/branches/cas-protocol-api/pom.xml
URL: 
http://svn.apache.org/viewvc/oodt/branches/cas-protocol-api/pom.xml?rev=1128471&r1=1128470&r2=1128471&view=diff
==============================================================================
--- oodt/branches/cas-protocol-api/pom.xml (original)
+++ oodt/branches/cas-protocol-api/pom.xml Fri May 27 21:41:07 2011
@@ -1,95 +1,121 @@
 <?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
+<!-- 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";>
 
-      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>0.3-SNAPSHOT</version>
-    <relativePath>../core/pom.xml</relativePath>
-  </parent> 
-  <artifactId>cas-protocol-api</artifactId>
-  <name>CAS Protocol</name>
-  <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>
-                <phase>verify</phase>
-                <goals>
-                  <goal>check</goal>
-                </goals>
-              </execution>
-            </executions>
-          </plugin>
-        </plugins>
-      </build>
-    </profile>
-  </profiles>
-  <dependencies>
-    <dependency>
-      <groupId>org.apache.oodt</groupId>
-      <artifactId>cas-metadata</artifactId>
-      <version>${project.parent.version}</version>
-    </dependency>
-    <dependency>
-      <groupId>commons-lang</groupId>
-      <artifactId>commons-lang</artifactId>
-      <version>2.3</version>
-    </dependency>
-    <dependency>
-      <groupId>xmlrpc</groupId>
-      <artifactId>xmlrpc</artifactId>
-      <version>2.0.1</version>
-    </dependency>
-    <dependency>
-      <groupId>com.thoughtworks.xstream</groupId>
-      <artifactId>xstream</artifactId>
-      <version>1.3.1</version>
-      <exclusions>
-        <exclusion>
-          <!-- xom is an optional dependency of xstream. Its also an Apache 
incompatible license -->
-          <groupId>xom</groupId>
-          <artifactId>xom</artifactId>
-        </exclusion> 
-      </exclusions>
-    </dependency>
-    <dependency>
-      <groupId>junit</groupId>
-      <artifactId>junit</artifactId>
-      <version>3.8.2</version>
-      <scope>test</scope>
-    </dependency>
-  </dependencies>
+       <modelVersion>4.0.0</modelVersion>
+       <parent>
+               <groupId>org.apache.oodt</groupId>
+               <artifactId>oodt-core</artifactId>
+               <version>0.3-SNAPSHOT</version>
+               <relativePath>../core/pom.xml</relativePath>
+       </parent>
+       <artifactId>cas-protocol-api</artifactId>
+       <name>CAS Protocol</name>
+       <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>
+                                                               
<phase>verify</phase>
+                                                               <goals>
+                                                                       
<goal>check</goal>
+                                                               </goals>
+                                                       </execution>
+                                               </executions>
+                                       </plugin>
+                               </plugins>
+                       </build>
+               </profile>
+       </profiles>
+       <build>
+               <plugins>
+                       <plugin>
+                               <groupId>org.apache.maven.plugins</groupId>
+                               <artifactId>maven-assembly-plugin</artifactId>
+                               <version>2.2-beta-2</version>
+                               <configuration>
+                                       <descriptors>
+                                               
<descriptor>src/main/assembly/assembly.xml</descriptor>
+                                       </descriptors>
+                                       <archive>
+                                               <manifest>
+                                                       
<mainClass>org.apache.oodt.cas.protocol.system.CLProtocolManager</mainClass>
+                                               </manifest>
+                                       </archive>
+                               </configuration>
+                               <executions>
+                                       <execution>
+                                               <phase>package</phase>
+                                               <goals>
+                                                       <goal>single</goal>
+                                               </goals>
+                                       </execution>
+                               </executions>
+                       </plugin>
+               </plugins>
+       </build>
+       <dependencies>
+               <dependency>
+                       <groupId>org.apache.oodt</groupId>
+                       <artifactId>oodt-commons</artifactId>
+                       <version>${project.parent.version}</version>
+               </dependency>
+               <dependency>
+                       <groupId>org.apache.oodt</groupId>
+                       <artifactId>cas-metadata</artifactId>
+                       <version>${project.parent.version}</version>
+               </dependency>
+               <dependency>
+                       <groupId>commons-lang</groupId>
+                       <artifactId>commons-lang</artifactId>
+                       <version>2.3</version>
+               </dependency>
+               <dependency>
+                       <groupId>xmlrpc</groupId>
+                       <artifactId>xmlrpc</artifactId>
+                       <version>2.0.1</version>
+               </dependency>
+               <dependency>
+                       <groupId>com.thoughtworks.xstream</groupId>
+                       <artifactId>xstream</artifactId>
+                       <version>1.3.1</version>
+                       <exclusions>
+                               <exclusion>
+                                       <!-- xom is an optional dependency of 
xstream. Its also an Apache incompatible 
+                                               license -->
+                                       <groupId>xom</groupId>
+                                       <artifactId>xom</artifactId>
+                               </exclusion>
+                       </exclusions>
+               </dependency>
+               <dependency>
+                       <groupId>junit</groupId>
+                       <artifactId>junit</artifactId>
+                       <version>3.8.2</version>
+                       <scope>test</scope>
+               </dependency>
+       </dependencies>
 </project>

Added: oodt/branches/cas-protocol-api/src/main/assembly/assembly.xml
URL: 
http://svn.apache.org/viewvc/oodt/branches/cas-protocol-api/src/main/assembly/assembly.xml?rev=1128471&view=auto
==============================================================================
--- oodt/branches/cas-protocol-api/src/main/assembly/assembly.xml (added)
+++ oodt/branches/cas-protocol-api/src/main/assembly/assembly.xml Fri May 27 
21:41:07 2011
@@ -0,0 +1,85 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one or more contributor
+license agreements.  See the NOTICE.txt 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.
+-->
+<assembly>
+  <id>dist</id>
+  <formats>
+    <format>tar.gz</format>
+    <format>zip</format>
+  </formats>
+  <includeBaseDirectory>true</includeBaseDirectory>
+  <baseDirectory>${project.artifactId}-${project.version}</baseDirectory>
+  <includeSiteDirectory>false</includeSiteDirectory>
+  <fileSets>
+    <fileSet>
+      <directory>${basedir}</directory>
+      <outputDirectory>.</outputDirectory>
+      <includes>
+        <include>LICENSE.txt</include>
+        <include>CHANGES.txt</include>
+      </includes>
+    </fileSet>
+    <fileSet>
+      <directory>${basedir}/src/main/bin</directory>
+      <outputDirectory>bin</outputDirectory>
+      <includes/>
+      <fileMode>755</fileMode>
+    </fileSet>
+    <fileSet>
+      <directory>${basedir}/src/main/resources</directory>
+      <outputDirectory>etc</outputDirectory>
+      <includes>
+        <include>*.properties</include>
+        <include>jssecacerts</include>
+      </includes>
+    </fileSet>
+    <fileSet>
+      <directory>${basedir}/src/main/resources/examples</directory>
+      <outputDirectory>etc/examples</outputDirectory>
+      <excludes/>
+    </fileSet>
+    <fileSet>
+      <directory>${basedir}/src/main/resources</directory>
+      <outputDirectory>logs</outputDirectory>
+      <includes>
+        <include>REMOVE.log</include>
+      </includes>
+    </fileSet>
+    <fileSet>
+      <directory>${basedir}/src/main/resources/policy</directory>
+      <outputDirectory>policy</outputDirectory>
+      <includes>
+        <include>*.xml</include>
+      </includes>
+    </fileSet>
+    <fileSet>
+      <directory>target/site/apidocs</directory>
+      <filtered>false</filtered>
+      <outputDirectory>doc</outputDirectory>
+      <excludes/>
+    </fileSet>
+  </fileSets>
+  <dependencySets>
+    <dependencySet>
+      <outputDirectory>lib</outputDirectory>
+      <unpack>false</unpack>
+      <useProjectArtifact>true</useProjectArtifact>
+      <useTransitiveDependencies>true</useTransitiveDependencies>
+      <unpackOptions/>
+    </dependencySet>
+  </dependencySets>
+</assembly>

Propchange: oodt/branches/cas-protocol-api/src/main/assembly/assembly.xml
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: 
oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/ProtocolFile.java
URL: 
http://svn.apache.org/viewvc/oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/ProtocolFile.java?rev=1128471&r1=1128470&r2=1128471&view=diff
==============================================================================
--- 
oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/ProtocolFile.java
 (original)
+++ 
oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/ProtocolFile.java
 Fri May 27 21:41:07 2011
@@ -30,14 +30,15 @@ import org.apache.commons.lang.StringUti
 public class ProtocolFile {
 
     public static final ProtocolFile ROOT = new ProtocolFile(File.separator, 
true);
-    public static final ProtocolFile HOME = new ProtocolFile("~", true);
+    public static final ProtocolFile HOME = new ProtocolFile(new 
File("").getAbsolutePath(), true);
 
     private String path;
     private boolean isDir;
 
     public ProtocolFile(String path, boolean isDir) {
         this.isDir = isDir;
-       this.path = path.length() > 0 ? StringUtils.chomp(path, File.separator) 
: path;
+               this.path = path.length() > 0 && !path.equals(File.separator) ? 
StringUtils
+                               .chomp(path, File.separator) : path;
     }
 
     /**
@@ -64,7 +65,11 @@ public class ProtocolFile {
      * @return The name of the file this path represents
      */
     public String getName() {
-        return path.substring(path.lastIndexOf(File.separator) + 1);
+       if (this.equals(ROOT) || !path.contains(File.separator)) {
+               return path;
+       } else {
+               return path.substring(path.lastIndexOf(File.separator) + 1);
+       }
     }
 
     /**
@@ -82,7 +87,11 @@ public class ProtocolFile {
      * @return The parent {@link ProtocolFile}
      */
     public ProtocolFile getParent() {
-        return new ProtocolFile(path.substring(0, 
path.lastIndexOf(File.separator)), true);
+       if (this.equals(ROOT) || !path.contains(File.separator)) {
+               return null;
+       } else {
+               return new ProtocolFile(path.substring(0, 
path.lastIndexOf(File.separator)), true);
+       }
     }
 
     /**

Modified: 
oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/action/DownloadAction.java
URL: 
http://svn.apache.org/viewvc/oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/action/DownloadAction.java?rev=1128471&r1=1128470&r2=1128471&view=diff
==============================================================================
--- 
oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/action/DownloadAction.java
 (original)
+++ 
oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/action/DownloadAction.java
 Fri May 27 21:41:07 2011
@@ -18,6 +18,7 @@ package org.apache.oodt.cas.protocol.act
 
 //JDK imports
 import java.io.File;
+import java.net.URI;
 
 //OODT imports
 import org.apache.oodt.cas.protocol.Protocol;
@@ -25,21 +26,32 @@ import org.apache.oodt.cas.protocol.Prot
 import org.apache.oodt.cas.protocol.system.ProtocolManager;
 
 /**
- * A {@link ProtocolAction} which will downlaod a file from a given site
+ * A {@link ProtocolAction} which will downlaod a url
  *
  * @author bfoster
  */
 public class DownloadAction extends ProtocolAction {
        
-       private String file;
+       private String urlString;
+       private String toDir;
        
        public void performAction(ProtocolManager protocolManager) throws 
Exception {
-               Protocol protocol = 
protocolManager.getProtocolBySite(getSite(), getAuthentication(), null);
-               protocol.get(new ProtocolFile(file, false), new File(""));
+               URI uri = new URI(urlString);
+               Protocol protocol = protocolManager.getProtocolBySite(
+                               new URI(uri.getScheme(), uri.getHost(), null, 
null),
+                               getAuthentication(),
+                               null);
+               protocol.get(new ProtocolFile(uri.getPath(), false),
+                               (toDir != null ? new 
File(toDir).getAbsoluteFile() : new File(
+                                               ".").getAbsoluteFile()));
        }
        
-       public void setFile(String file) {
-               this.file = file;
+       public void setUrl(String urlString) {
+               this.urlString = urlString;
+       }
+       
+       public void setToDir(String toDir) {
+               this.toDir = toDir;
        }
 
 }

Modified: 
oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/auth/Authentication.java
URL: 
http://svn.apache.org/viewvc/oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/auth/Authentication.java?rev=1128471&r1=1128470&r2=1128471&view=diff
==============================================================================
--- 
oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/auth/Authentication.java
 (original)
+++ 
oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/auth/Authentication.java
 Fri May 27 21:41:07 2011
@@ -23,8 +23,8 @@ package org.apache.oodt.cas.protocol.aut
  */
 public interface Authentication {
 
-       public String user();
+       public String getUser();
        
-       public String pass();
+       public String getPass();
        
 }

Modified: 
oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/auth/BasicAuthentication.java
URL: 
http://svn.apache.org/viewvc/oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/auth/BasicAuthentication.java?rev=1128471&r1=1128470&r2=1128471&view=diff
==============================================================================
--- 
oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/auth/BasicAuthentication.java
 (original)
+++ 
oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/auth/BasicAuthentication.java
 Fri May 27 21:41:07 2011
@@ -32,11 +32,11 @@ public class BasicAuthentication impleme
                this.pass = pass;
        }
        
-       public String user() {
+       public String getUser() {
                return user;
        }
 
-       public String pass() {
+       public String getPass() {
                return pass;
        }
 

Modified: 
oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/auth/NoAuthentication.java
URL: 
http://svn.apache.org/viewvc/oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/auth/NoAuthentication.java?rev=1128471&r1=1128470&r2=1128471&view=diff
==============================================================================
--- 
oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/auth/NoAuthentication.java
 (original)
+++ 
oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/auth/NoAuthentication.java
 Fri May 27 21:41:07 2011
@@ -23,11 +23,11 @@ package org.apache.oodt.cas.protocol.aut
  */
 public class NoAuthentication implements Authentication {
 
-       public String user() {
+       public String getUser() {
                return null;
        }
 
-       public String pass() {
+       public String getPass() {
                return null;
        }
 }

Modified: 
oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/config/SpringProtocolConfig.java
URL: 
http://svn.apache.org/viewvc/oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/config/SpringProtocolConfig.java?rev=1128471&r1=1128470&r2=1128471&view=diff
==============================================================================
--- 
oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/config/SpringProtocolConfig.java
 (original)
+++ 
oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/config/SpringProtocolConfig.java
 Fri May 27 21:41:07 2011
@@ -36,7 +36,7 @@ import org.springframework.context.suppo
  */
 public class SpringProtocolConfig implements ProtocolConfig {
 
-       private Map<String, List<ProtocolFactory>> factoryMap;
+       protected Map<String, List<ProtocolFactory>> factoryMap;
        
        public SpringProtocolConfig(String configFile) {
                factoryMap = new HashMap<String, List<ProtocolFactory>>();
@@ -48,11 +48,16 @@ public class SpringProtocolConfig implem
                                factories = new ArrayList<ProtocolFactory>();
                        }
                        factories.add(factory);
+                       factoryMap.put(factory.getSchema(), factories);
                }
        }
        
        public List<ProtocolFactory> getFactoriesBySite(URI site) {
-               return factoryMap.get(site.getScheme());
+               List<ProtocolFactory> factories = 
factoryMap.get(site.getScheme());
+               if (factories == null) {
+                       factories = new ArrayList<ProtocolFactory>();
+               }
+               return factories;
        }
 
 }

Modified: 
oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/system/CLProtocolManager.java
URL: 
http://svn.apache.org/viewvc/oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/system/CLProtocolManager.java?rev=1128471&r1=1128470&r2=1128471&view=diff
==============================================================================
--- 
oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/system/CLProtocolManager.java
 (original)
+++ 
oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/system/CLProtocolManager.java
 Fri May 27 21:41:07 2011
@@ -47,15 +47,10 @@ public class CLProtocolManager extends P
                                .doDynamicReplacement(System
                                                .getProperty(
                                                                
"org.apache.oodt.cas.protocol.manager.config.file",
-                                                               
"classpath:/org/apache/oodt/cas/protocol/actions/protocol-manager-config.xml"));
-               String cmdLineConfig = PathUtils
-                               .doDynamicReplacement(System
-                                               .getProperty(
-                                                               
"org.apache.oodt.cas.protocol.cmdline.config.file",
-                                                               
"classpath:/org/apache/oodt/cas/protocol/actions/protocol-cmdline-beans.xml"));
+                                                               
"classpath:/org/apache/oodt/cas/protocol/actions/protocol-config.xml"));
 
                FileSystemXmlApplicationContext appContext = new 
FileSystemXmlApplicationContext(
-                               cmdLineConfig);
+                               protocolConfig);
                List<CmdLineOptionInstance> optionInstances = CmdLineOptionUtils
                                .loadValidateAndHandleInstances(appContext, 
args);
                CmdLineOptionInstance actionInstance = CmdLineOptionUtils

Modified: 
oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/system/ProtocolManager.java
URL: 
http://svn.apache.org/viewvc/oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/system/ProtocolManager.java?rev=1128471&r1=1128470&r2=1128471&view=diff
==============================================================================
--- 
oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/system/ProtocolManager.java
 (original)
+++ 
oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/system/ProtocolManager.java
 Fri May 27 21:41:07 2011
@@ -54,10 +54,11 @@ public class ProtocolManager {
        if (verifiedMap.containsKey(site)) {
                return verifiedMap.get(site).newInstance();
        } else {
+               System.out.println(protocolConfig);
                for (ProtocolFactory factory : 
protocolConfig.getFactoriesBySite(site)) {
                        try {
                                Protocol protocol = factory.newInstance();
-                               if (verifier.verify(protocol, site, auth)) {
+                               if (verifier == null || 
verifier.verify(protocol, site, auth)) {
                                        verifiedMap.put(site, factory);
                                        return protocol;
                                }

Added: 
oodt/branches/cas-protocol-api/src/main/resources/policy/protocol-action-beans.xml
URL: 
http://svn.apache.org/viewvc/oodt/branches/cas-protocol-api/src/main/resources/policy/protocol-action-beans.xml?rev=1128471&view=auto
==============================================================================
--- 
oodt/branches/cas-protocol-api/src/main/resources/policy/protocol-action-beans.xml
 (added)
+++ 
oodt/branches/cas-protocol-api/src/main/resources/policy/protocol-action-beans.xml
 Fri May 27 21:41:07 2011
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- 
+       
+       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"/>
+
+       <bean id="download" 
class="org.apache.oodt.cas.protocol.action.DownloadAction"/>
+       
+</beans>
\ No newline at end of file

Propchange: 
oodt/branches/cas-protocol-api/src/main/resources/policy/protocol-action-beans.xml
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: 
oodt/branches/cas-protocol-api/src/main/resources/policy/protocol-cmd-line-beans.xml
URL: 
http://svn.apache.org/viewvc/oodt/branches/cas-protocol-api/src/main/resources/policy/protocol-cmd-line-beans.xml?rev=1128471&view=auto
==============================================================================
--- 
oodt/branches/cas-protocol-api/src/main/resources/policy/protocol-cmd-line-beans.xml
 (added)
+++ 
oodt/branches/cas-protocol-api/src/main/resources/policy/protocol-cmd-line-beans.xml
 Fri May 27 21:41:07 2011
@@ -0,0 +1,78 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- 
+       
+       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"/>
+
+       <bean id="action" lazy-init="true" 
class="org.apache.oodt.commons.option.CmdLineOption">
+               <property name="shortOption" value="a"/>
+               <property name="longOption" value="action"/>
+               <property name="description" value="The Action to perfrom"/>
+               <property name="hasArgs" value="true"/>
+               <property name="optionArgName" value="bean id"/>
+               <property name="required" value="true"/>
+       </bean>
+               
+       <bean id="user" lazy-init="true" 
class="org.apache.oodt.commons.option.CmdLineOption">
+               <property name="shortOption" value="u"/>
+               <property name="longOption" value="user"/>
+               <property name="description" value="Username for 
authentication"/>
+               <property name="hasArgs" value="true"/>
+               <property name="optionArgName" value="username"/>
+               <property name="required" value="false"/>               
+               <property name="handler">
+                       <bean 
class="org.apache.oodt.commons.option.handler.CmdLineOptionBeanHandler">
+                               <property name="applyToBeans">
+                                       <list>
+                                               <bean 
class="org.apache.oodt.commons.option.handler.BeanInfo" p:bean-ref="Download"/> 
          
+                                       </list>
+                               </property>
+                       </bean>
+               </property>
+       </bean>
+       
+       <bean id="pass" lazy-init="true" 
class="org.apache.oodt.commons.option.CmdLineOption">
+               <property name="shortOption" value="p"/>
+               <property name="longOption" value="pass"/>
+               <property name="description" value="Password for 
authentication"/>
+               <property name="hasArgs" value="true"/>
+               <property name="optionArgName" value="password"/>
+               <property name="required" value="false"/>               
+               <property name="handler">
+                       <bean 
class="org.apache.oodt.commons.option.handler.CmdLineOptionBeanHandler">
+                               <property name="applyToBeans">
+                                       <list>
+                                               <bean 
class="org.apache.oodt.commons.option.handler.BeanInfo" p:bean-ref="Download"/> 
          
+                                       </list>
+                               </property>
+                       </bean>
+               </property>
+       </bean>
+       
+       <bean id="url" lazy-init="true" 
class="org.apache.oodt.commons.option.CmdLineOption">
+               <property name="shortOption" value="u"/>
+               <property name="longOption" value="url"/>
+               <property name="description" value="URL to download"/>
+               <property name="hasArgs" value="true"/>
+               <property name="optionArgName" value="URL"/>
+               <property name="required" value="false"/>               
+               <property name="handler">
+                       <bean 
class="org.apache.oodt.commons.option.handler.CmdLineOptionBeanHandler">
+                               <property name="applyToBeans">
+                                       <list>
+                                               <bean 
class="org.apache.oodt.commons.option.handler.BeanInfo" p:bean-ref="Download"/> 
          
+                                       </list>
+                               </property>
+                       </bean>
+               </property>
+       </bean>
+       
+</beans>
\ No newline at end of file

Propchange: 
oodt/branches/cas-protocol-api/src/main/resources/policy/protocol-cmd-line-beans.xml
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: 
oodt/branches/cas-protocol-api/src/main/resources/policy/protocol-config.xml
URL: 
http://svn.apache.org/viewvc/oodt/branches/cas-protocol-api/src/main/resources/policy/protocol-config.xml?rev=1128471&r1=1128470&r2=1128471&view=diff
==============================================================================
--- 
oodt/branches/cas-protocol-api/src/main/resources/policy/protocol-config.xml 
(original)
+++ 
oodt/branches/cas-protocol-api/src/main/resources/policy/protocol-config.xml 
Fri May 27 21:41:07 2011
@@ -10,6 +10,10 @@
        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="protocol-action-beans.xml"/>
+    <import resource="protocol-cmd-line-beans.xml"/>
+
+       <!-- list ProtocolFactories here -->
        <bean class="org.apache.oodt.cas.protocol.some.factory">
                
        </bean>

Added: 
oodt/branches/cas-protocol-api/src/test/org/apache/oodt/cas/protocol/MockProtocol.java
URL: 
http://svn.apache.org/viewvc/oodt/branches/cas-protocol-api/src/test/org/apache/oodt/cas/protocol/MockProtocol.java?rev=1128471&view=auto
==============================================================================
--- 
oodt/branches/cas-protocol-api/src/test/org/apache/oodt/cas/protocol/MockProtocol.java
 (added)
+++ 
oodt/branches/cas-protocol-api/src/test/org/apache/oodt/cas/protocol/MockProtocol.java
 Fri May 27 21:41:07 2011
@@ -0,0 +1,87 @@
+/*
+ * 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.Collections;
+import java.util.List;
+
+//OODT imports
+import org.apache.oodt.cas.protocol.auth.Authentication;
+import org.apache.oodt.cas.protocol.exceptions.ProtocolException;
+
+/**
+ * Mock {@link Protocol} for testing
+ * 
+ * @author bfoster
+ */
+public class MockProtocol implements Protocol {
+
+       private boolean connected;
+       private ProtocolFile cwd;
+       private String factoryId;
+       
+       public MockProtocol(String factoryId) {
+               connected = false;
+               this.factoryId = factoryId;
+       }
+       
+       public String getFactoryId() {
+               return factoryId;
+       }
+       
+       public void connect(String host, Authentication authentication)
+                       throws ProtocolException {
+               connected = true;
+       }
+
+       public void close() throws ProtocolException {
+               connected = false;
+       }
+
+       public boolean connected() {
+               return connected;
+       }
+
+       public void cd(ProtocolFile file) throws ProtocolException {
+               cwd = file;
+       }
+
+       public void get(ProtocolFile fromFile, File toFile)
+                       throws ProtocolException {
+               //do nothing
+       }
+
+       public void put(File fromFile, ProtocolFile toFile)
+                       throws ProtocolException {
+               //do nothing
+       }
+
+       public ProtocolFile pwd() throws ProtocolException {
+               return cwd;
+       }
+
+       public List<ProtocolFile> ls() throws ProtocolException {
+               return Collections.emptyList();
+       }
+
+       public void delete(ProtocolFile file) throws ProtocolException {
+               //do nothing
+       }
+
+}

Propchange: 
oodt/branches/cas-protocol-api/src/test/org/apache/oodt/cas/protocol/MockProtocol.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: 
oodt/branches/cas-protocol-api/src/test/org/apache/oodt/cas/protocol/MockProtocolFactory.java
URL: 
http://svn.apache.org/viewvc/oodt/branches/cas-protocol-api/src/test/org/apache/oodt/cas/protocol/MockProtocolFactory.java?rev=1128471&view=auto
==============================================================================
--- 
oodt/branches/cas-protocol-api/src/test/org/apache/oodt/cas/protocol/MockProtocolFactory.java
 (added)
+++ 
oodt/branches/cas-protocol-api/src/test/org/apache/oodt/cas/protocol/MockProtocolFactory.java
 Fri May 27 21:41:07 2011
@@ -0,0 +1,51 @@
+/*
+ * 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;
+       }
+}

Propchange: 
oodt/branches/cas-protocol-api/src/test/org/apache/oodt/cas/protocol/MockProtocolFactory.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: 
oodt/branches/cas-protocol-api/src/test/org/apache/oodt/cas/protocol/TestProtocolFile.java
URL: 
http://svn.apache.org/viewvc/oodt/branches/cas-protocol-api/src/test/org/apache/oodt/cas/protocol/TestProtocolFile.java?rev=1128471&view=auto
==============================================================================
--- 
oodt/branches/cas-protocol-api/src/test/org/apache/oodt/cas/protocol/TestProtocolFile.java
 (added)
+++ 
oodt/branches/cas-protocol-api/src/test/org/apache/oodt/cas/protocol/TestProtocolFile.java
 Fri May 27 21:41:07 2011
@@ -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.oodt.cas.protocol;
+
+//JDK imports
+import java.io.File;
+
+//JUnit imports
+import junit.framework.TestCase;
+
+/**
+ * Test class for {@link ProtocolFile}
+ * 
+ * @author bfoster
+ */
+public class TestProtocolFile extends TestCase {
+
+       public void testInitialState() {
+               String filePath = File.separator + "path" + File.separator + 
"to" + File.separator + "file";
+               ProtocolFile pFile = new ProtocolFile(filePath, false);
+               assertEquals(filePath, pFile.getPath());
+               assertEquals(pFile.getPath(), pFile.toString());
+               assertEquals("file", pFile.getName());
+               assertFalse(pFile.isDir());
+               assertFalse(pFile.isRelative());
+               
+               // Test Parent file
+               String parentPath = File.separator + "path" + File.separator + 
"to";
+               assertEquals(parentPath, pFile.getParent().getPath());
+               assertEquals(pFile.getParent().getPath(), 
pFile.getParent().toString());
+               assertEquals("to", pFile.getParent().getName());
+               assertTrue(pFile.getParent().isDir());
+               assertFalse(pFile.getParent().isRelative());
+       }
+       
+       public void testRoot() {
+               assertEquals(File.separator, ProtocolFile.ROOT.getPath());
+               assertNull(ProtocolFile.ROOT.getParent());
+               assertEquals(ProtocolFile.ROOT.getPath(), 
ProtocolFile.ROOT.getName());
+               assertEquals(ProtocolFile.ROOT.getPath(), 
ProtocolFile.ROOT.toString());
+               assertTrue(ProtocolFile.ROOT.isDir());
+               assertFalse(ProtocolFile.ROOT.isRelative());
+       }
+       
+       public void testHome() {
+               assertEquals(new File("").getAbsolutePath(), 
ProtocolFile.HOME.getPath());
+               assertEquals(ProtocolFile.HOME.getPath(), 
ProtocolFile.HOME.toString());
+               assertFalse(ProtocolFile.HOME.isRelative());
+               assertTrue(ProtocolFile.HOME.isDir());
+       }
+}

Propchange: 
oodt/branches/cas-protocol-api/src/test/org/apache/oodt/cas/protocol/TestProtocolFile.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: 
oodt/branches/cas-protocol-api/src/test/org/apache/oodt/cas/protocol/auth/TestBasicAuthentication.java
URL: 
http://svn.apache.org/viewvc/oodt/branches/cas-protocol-api/src/test/org/apache/oodt/cas/protocol/auth/TestBasicAuthentication.java?rev=1128471&view=auto
==============================================================================
--- 
oodt/branches/cas-protocol-api/src/test/org/apache/oodt/cas/protocol/auth/TestBasicAuthentication.java
 (added)
+++ 
oodt/branches/cas-protocol-api/src/test/org/apache/oodt/cas/protocol/auth/TestBasicAuthentication.java
 Fri May 27 21:41:07 2011
@@ -0,0 +1,35 @@
+/*
+ * 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());
+       }
+       
+}

Propchange: 
oodt/branches/cas-protocol-api/src/test/org/apache/oodt/cas/protocol/auth/TestBasicAuthentication.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: 
oodt/branches/cas-protocol-api/src/test/org/apache/oodt/cas/protocol/auth/TestNoAuthentication.java
URL: 
http://svn.apache.org/viewvc/oodt/branches/cas-protocol-api/src/test/org/apache/oodt/cas/protocol/auth/TestNoAuthentication.java?rev=1128471&view=auto
==============================================================================
--- 
oodt/branches/cas-protocol-api/src/test/org/apache/oodt/cas/protocol/auth/TestNoAuthentication.java
 (added)
+++ 
oodt/branches/cas-protocol-api/src/test/org/apache/oodt/cas/protocol/auth/TestNoAuthentication.java
 Fri May 27 21:41:07 2011
@@ -0,0 +1,35 @@
+/*
+ * 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();
+               assertNull(auth.getUser());
+               assertNull(auth.getPass());
+       }
+       
+}

Propchange: 
oodt/branches/cas-protocol-api/src/test/org/apache/oodt/cas/protocol/auth/TestNoAuthentication.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: 
oodt/branches/cas-protocol-api/src/test/org/apache/oodt/cas/protocol/config/MockSpringProtocolConfig.java
URL: 
http://svn.apache.org/viewvc/oodt/branches/cas-protocol-api/src/test/org/apache/oodt/cas/protocol/config/MockSpringProtocolConfig.java?rev=1128471&view=auto
==============================================================================
--- 
oodt/branches/cas-protocol-api/src/test/org/apache/oodt/cas/protocol/config/MockSpringProtocolConfig.java
 (added)
+++ 
oodt/branches/cas-protocol-api/src/test/org/apache/oodt/cas/protocol/config/MockSpringProtocolConfig.java
 Fri May 27 21:41:07 2011
@@ -0,0 +1,44 @@
+/*
+ * 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/testdata/test-protocol-config.xml";
+
+       public MockSpringProtocolConfig() {
+               super(CONFIG_FILE);
+       }
+
+       public String getConfigFile() {
+               return CONFIG_FILE;
+       }
+
+       public Map<String, List<ProtocolFactory>> getFactoryMap() {
+               return factoryMap;
+       }
+}

Propchange: 
oodt/branches/cas-protocol-api/src/test/org/apache/oodt/cas/protocol/config/MockSpringProtocolConfig.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: 
oodt/branches/cas-protocol-api/src/test/org/apache/oodt/cas/protocol/system/TestProtocolManager.java
URL: 
http://svn.apache.org/viewvc/oodt/branches/cas-protocol-api/src/test/org/apache/oodt/cas/protocol/system/TestProtocolManager.java?rev=1128471&view=auto
==============================================================================
--- 
oodt/branches/cas-protocol-api/src/test/org/apache/oodt/cas/protocol/system/TestProtocolManager.java
 (added)
+++ 
oodt/branches/cas-protocol-api/src/test/org/apache/oodt/cas/protocol/system/TestProtocolManager.java
 Fri May 27 21:41:07 2011
@@ -0,0 +1,94 @@
+/*
+ * 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;
+                               }
+                       }
+               });
+               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());
+       }
+       
+}

Propchange: 
oodt/branches/cas-protocol-api/src/test/org/apache/oodt/cas/protocol/system/TestProtocolManager.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: oodt/branches/cas-protocol-api/src/testdata/test-protocol-config.xml
URL: 
http://svn.apache.org/viewvc/oodt/branches/cas-protocol-api/src/testdata/test-protocol-config.xml?rev=1128471&view=auto
==============================================================================
--- oodt/branches/cas-protocol-api/src/testdata/test-protocol-config.xml (added)
+++ oodt/branches/cas-protocol-api/src/testdata/test-protocol-config.xml Fri 
May 27 21:41:07 2011
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- 
+       
+       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="http" 
class="org.apache.oodt.cas.protocol.MockProtocolFactory">
+               <property name="schema" value="http"/>
+       </bean>
+       
+</beans>

Propchange: oodt/branches/cas-protocol-api/src/testdata/test-protocol-config.xml
------------------------------------------------------------------------------
    svn:mime-type = text/plain


Reply via email to