You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@manifoldcf.apache.org by kw...@apache.org on 2012/07/10 10:51:33 UTC
svn commit: r1359528 - in /manifoldcf/branches/CONNECTORS-470:
connectors/sharepoint/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/sharepoint/
connectors/sharepoint/connector/src/test/java/org/
connectors/sharepoint/connector/src/tes...
Author: kwright
Date: Tue Jul 10 08:51:33 2012
New Revision: 1359528
URL: http://svn.apache.org/viewvc?rev=1359528&view=rev
Log:
Add unit tests for building Lists service XML
Added:
manifoldcf/branches/CONNECTORS-470/connectors/sharepoint/connector/src/test/java/org/
manifoldcf/branches/CONNECTORS-470/connectors/sharepoint/connector/src/test/java/org/apache/
manifoldcf/branches/CONNECTORS-470/connectors/sharepoint/connector/src/test/java/org/apache/manifoldcf/
manifoldcf/branches/CONNECTORS-470/connectors/sharepoint/connector/src/test/java/org/apache/manifoldcf/crawler/
manifoldcf/branches/CONNECTORS-470/connectors/sharepoint/connector/src/test/java/org/apache/manifoldcf/crawler/connectors/
manifoldcf/branches/CONNECTORS-470/connectors/sharepoint/connector/src/test/java/org/apache/manifoldcf/crawler/connectors/sharepoint/
manifoldcf/branches/CONNECTORS-470/connectors/sharepoint/connector/src/test/java/org/apache/manifoldcf/crawler/connectors/sharepoint/XMLGenTest.java (with props)
Modified:
manifoldcf/branches/CONNECTORS-470/connectors/sharepoint/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/sharepoint/SPSProxyHelper.java
manifoldcf/branches/CONNECTORS-470/framework/core/src/main/java/org/apache/manifoldcf/core/common/XMLDoc.java
Modified: manifoldcf/branches/CONNECTORS-470/connectors/sharepoint/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/sharepoint/SPSProxyHelper.java
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-470/connectors/sharepoint/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/sharepoint/SPSProxyHelper.java?rev=1359528&r1=1359527&r2=1359528&view=diff
==============================================================================
--- manifoldcf/branches/CONNECTORS-470/connectors/sharepoint/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/sharepoint/SPSProxyHelper.java (original)
+++ manifoldcf/branches/CONNECTORS-470/connectors/sharepoint/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/sharepoint/SPSProxyHelper.java Tue Jul 10 08:51:33 2012
@@ -2022,12 +2022,12 @@ public class SPSProxyHelper {
{
XMLDoc doc = new XMLDoc();
Object viewFieldsNode = doc.createElement(null,"viewFields");
- for (String x : (List<String>)fieldNames)
+ for (Object x : fieldNames)
{
Object child = doc.createElement(viewFieldsNode,"FieldRef");
- doc.setAttribute(child,"Name",x);
+ doc.setAttribute(child,"Name",(String)x);
}
- return doc.getXML();
+ return doc.getXMLNoEntityPreamble();
}
/** Build a query XML object that matches a specified field and value pair.
@@ -2044,21 +2044,22 @@ public class SPSProxyHelper {
Object valueClause = doc.createElement(equalsClause,"Value");
doc.setAttribute(valueClause,"Type",type);
doc.createText(valueClause,value);
- return doc.getXML();
+ return doc.getXMLNoEntityPreamble();
}
// MHL to build list query, which has a sort order based on an indexed column such as ID
/** Build queryOptions XML object that specifies a paging value.
*/
- protected static String buildPagingQueryOptions(int startRow)
+ protected static String buildPagingQueryOptions(String pageNextString)
throws ManifoldCFException
{
XMLDoc doc = new XMLDoc();
Object optionsNode = doc.createElement(null,"QueryOptions");
Object pagingNode = doc.createElement(optionsNode,"Paging");
- doc.setAttribute(pagingNode,"ListItemCollectionPositionNext",Integer.toString(startRow));
- return doc.getXML();
+ doc.setAttribute(pagingNode,"ListItemCollectionPositionNext",
+ pageNextString);
+ return doc.getXMLNoEntityPreamble();
}
/**
Added: manifoldcf/branches/CONNECTORS-470/connectors/sharepoint/connector/src/test/java/org/apache/manifoldcf/crawler/connectors/sharepoint/XMLGenTest.java
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-470/connectors/sharepoint/connector/src/test/java/org/apache/manifoldcf/crawler/connectors/sharepoint/XMLGenTest.java?rev=1359528&view=auto
==============================================================================
--- manifoldcf/branches/CONNECTORS-470/connectors/sharepoint/connector/src/test/java/org/apache/manifoldcf/crawler/connectors/sharepoint/XMLGenTest.java (added)
+++ manifoldcf/branches/CONNECTORS-470/connectors/sharepoint/connector/src/test/java/org/apache/manifoldcf/crawler/connectors/sharepoint/XMLGenTest.java Tue Jul 10 08:51:33 2012
@@ -0,0 +1,56 @@
+/* $Id$ */
+
+/**
+* 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.manifoldcf.crawler.connectors.sharepoint;
+
+import org.junit.*;
+import static org.junit.Assert.*;
+
+import java.util.*;
+
+public class XMLGenTest
+{
+
+ @Test
+ public void buildPagingQueryOptions()
+ throws Exception
+ {
+ String pagingXML = SPSProxyHelper.buildPagingQueryOptions("some next string");
+ assertEquals("<QueryOptions><Paging ListItemCollectionPositionNext=\"some next string\"/></QueryOptions>",pagingXML);
+ }
+
+ @Test
+ public void buildViewFieldsTest()
+ throws Exception
+ {
+ ArrayList list = new ArrayList();
+ list.add("foo");
+ list.add("bar");
+ String viewFieldsXML = SPSProxyHelper.buildViewFields(list);
+ assertEquals("<viewFields><FieldRef Name=\"foo\"/><FieldRef Name=\"bar\"/></viewFields>",viewFieldsXML);
+ }
+
+ @Test
+ public void buildMatchQueryTest()
+ throws Exception
+ {
+ String matchQuery = SPSProxyHelper.buildMatchQuery("foo","Text","bar");
+ assertEquals("<Query><Where><Eq><FieldRef Name=\"foo\"/><Value Type=\"Text\">bar</Value></Eq></Where></Query>",matchQuery);
+ }
+
+}
\ No newline at end of file
Propchange: manifoldcf/branches/CONNECTORS-470/connectors/sharepoint/connector/src/test/java/org/apache/manifoldcf/crawler/connectors/sharepoint/XMLGenTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: manifoldcf/branches/CONNECTORS-470/connectors/sharepoint/connector/src/test/java/org/apache/manifoldcf/crawler/connectors/sharepoint/XMLGenTest.java
------------------------------------------------------------------------------
svn:keywords = Id
Modified: manifoldcf/branches/CONNECTORS-470/framework/core/src/main/java/org/apache/manifoldcf/core/common/XMLDoc.java
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-470/framework/core/src/main/java/org/apache/manifoldcf/core/common/XMLDoc.java?rev=1359528&r1=1359527&r2=1359528&view=diff
==============================================================================
--- manifoldcf/branches/CONNECTORS-470/framework/core/src/main/java/org/apache/manifoldcf/core/common/XMLDoc.java (original)
+++ manifoldcf/branches/CONNECTORS-470/framework/core/src/main/java/org/apache/manifoldcf/core/common/XMLDoc.java Tue Jul 10 08:51:33 2012
@@ -241,6 +241,15 @@ public class XMLDoc
}
}
+ /** Get XML with no entity preamble */
+ public String getXMLNoEntityPreamble()
+ throws ManifoldCFException
+ {
+ String initial = getXML();
+ int index = initial.indexOf(">");
+ return initial.substring(index+1);
+ }
+
/** Convert the response for transmit
* @return xml in byte array
*/