manifoldcf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kwri...@apache.org
Subject svn commit: r1583903 [2/2] - in /manifoldcf/branches/CONNECTORS-856-2: ./ connectors/solr/ connectors/solr/connector/src/test/java/org/apache/ connectors/solr/connector/src/test/java/org/apache/manifoldcf/ connectors/solr/connector/src/test/java/org/ap...
Date Wed, 02 Apr 2014 07:15:41 GMT
Added: manifoldcf/branches/CONNECTORS-856-2/connectors/solr/connector/src/test/java/org/apache/manifoldcf/agents/output/solr/SolrConnectorTest.java
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-856-2/connectors/solr/connector/src/test/java/org/apache/manifoldcf/agents/output/solr/SolrConnectorTest.java?rev=1583903&view=auto
==============================================================================
--- manifoldcf/branches/CONNECTORS-856-2/connectors/solr/connector/src/test/java/org/apache/manifoldcf/agents/output/solr/SolrConnectorTest.java
(added)
+++ manifoldcf/branches/CONNECTORS-856-2/connectors/solr/connector/src/test/java/org/apache/manifoldcf/agents/output/solr/SolrConnectorTest.java
Wed Apr  2 07:15:40 2014
@@ -0,0 +1,102 @@
+/**
+ * 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.agents.output.solr;
+
+import junit.framework.TestCase;
+import org.apache.manifoldcf.agents.interfaces.IOutputAddActivity;
+import org.apache.manifoldcf.agents.interfaces.RepositoryDocument;
+import org.apache.manifoldcf.agents.interfaces.ServiceInterruption;
+import org.apache.manifoldcf.core.interfaces.ManifoldCFException;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import static org.mockito.Matchers.*;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+import static org.powermock.api.mockito.PowerMockito.mock;
+import static org.powermock.api.mockito.PowerMockito.spy;
+
+/**
+ * @Author: Alessandro Benedetti
+ * Date: 18/12/2013
+ */
+public class SolrConnectorTest extends TestCase{
+
+  SolrConnector connectorToTest;
+  HttpPoster poster;
+  RepositoryDocument document;
+  IOutputAddActivity act;
+
+  @Override
+  public void setUp() throws Exception {
+    connectorToTest=spy(new SolrConnector());
+    poster=mock(HttpPoster.class);
+    document=mock(RepositoryDocument.class);
+    act=mock(IOutputAddActivity.class);
+    when(poster.indexPost(anyString(),eq(document),anyMap(),anyMap(),anyBoolean(),anyString(),eq(act))).thenReturn(true);
+
+  }
+
+  /**
+   * Test the AddOrReplaceDocument with an example test string in input
+   * @throws ManifoldCFException
+   * @throws ServiceInterruption
+   */
+  public void testAddOrReplaceDocument() throws ManifoldCFException, ServiceInterruption
{
+    Map<String, List<String>> expectedSourceTargets = getMappingsMap();
+    Map<String,List<String>> expectedStreamParams = getStreamTypeMap();
+
+    connectorToTest.poster=poster;
+    String outputDescription = "1+stream.type=text/plain=+3+cm:description=cm_description_s=+cm:name=cm_name_s=+cm:title=cm_title_s=+1+keepAllMetadata=true=+";
+    connectorToTest.addOrReplaceDocument("Document Id", outputDescription,document,"",act);
+    verify(poster).indexPost(eq("Document Id"),eq(document),eq(expectedStreamParams),eq(expectedSourceTargets),eq(true),eq(""),eq(act));
+  }
+
+  /**
+   * returns the expected mappings map for the input string in test
+   * @return
+   */
+  private Map<String, List<String>> getMappingsMap() {
+    Map<String, List<String>> sourceTargets = new HashMap<String, List<String>>();
+    List<String> firstList=new ArrayList<String>();
+    firstList.add("cm_description_s");
+    List<String> secondList=new ArrayList<String>();
+    secondList.add("cm_name_s");
+    List<String> thirdList=new ArrayList<String>();
+    thirdList.add("cm_title_s");
+
+    sourceTargets.put("cm:description",firstList);
+    sourceTargets.put("cm:name",secondList);
+    sourceTargets.put("cm:title",thirdList);
+    return sourceTargets;
+  }
+
+  /**
+   * returns the expected mappings map for the input string in test
+   * @return
+   */
+  private Map<String, List<String>> getStreamTypeMap() {
+    Map<String, List<String>> sourceTargets = new HashMap<String, List<String>>();
+    List<String> firstList=new ArrayList<String>();
+    firstList.add("text/plain");
+    sourceTargets.put("stream.type",firstList);
+    return sourceTargets;
+  }
+}

Propchange: manifoldcf/branches/CONNECTORS-856-2/connectors/solr/connector/src/test/java/org/apache/manifoldcf/agents/output/solr/SolrConnectorTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: manifoldcf/branches/CONNECTORS-856-2/connectors/solr/connector/src/test/java/org/apache/manifoldcf/agents/output/solr/SolrConnectorTest.java
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: manifoldcf/branches/CONNECTORS-856-2/connectors/solr/pom.xml
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-856-2/connectors/solr/pom.xml?rev=1583903&r1=1583902&r2=1583903&view=diff
==============================================================================
--- manifoldcf/branches/CONNECTORS-856-2/connectors/solr/pom.xml (original)
+++ manifoldcf/branches/CONNECTORS-856-2/connectors/solr/pom.xml Wed Apr  2 07:15:40 2014
@@ -230,6 +230,18 @@
       <version>${junit.version}</version>
       <scope>test</scope>
     </dependency>
+      <dependency>
+          <groupId>org.powermock</groupId>
+          <artifactId>powermock-module-junit4</artifactId>
+          <version>${powerMock.version}</version>
+          <scope>test</scope>
+      </dependency>
+      <dependency>
+          <groupId>org.powermock</groupId>
+          <artifactId>powermock-api-mockito</artifactId>
+          <version>${powerMock.version}</version>
+          <scope>test</scope>
+      </dependency>
     <dependency>
       <groupId>${project.groupId}</groupId>
       <artifactId>mcf-core</artifactId>

Modified: manifoldcf/branches/CONNECTORS-856-2/framework/build.xml
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-856-2/framework/build.xml?rev=1583903&r1=1583902&r2=1583903&view=diff
==============================================================================
--- manifoldcf/branches/CONNECTORS-856-2/framework/build.xml (original)
+++ manifoldcf/branches/CONNECTORS-856-2/framework/build.xml Wed Apr  2 07:15:40 2014
@@ -58,7 +58,6 @@
             <include name="slf4j*.jar"/>
             <include name="jsp-2.1*.jar"/>
             <include name="jsp-api*.jar"/>
-            <include name="junit*.jar"/>
             <include name="log4j*.jar"/>
             <include name="serializer*.jar"/>
             <include name="servlet-api*.jar"/>
@@ -81,6 +80,22 @@
         </fileset>
 
     </path>
+
+    <path id="framework-test-classpath">
+        <path refid="framework-classpath"/>
+        <fileset dir="../lib">
+            <include name="junit*.jar"/>
+            <include name="powermock-module-junit4*.jar"/>
+            <include name="powermock-core*.jar"/>
+            <include name="powermock-reflect*.jar"/>
+            <include name="powermock-api-support*.jar"/>
+            <include name="powermock-api-mockito*.jar"/>
+            <include name="mockito-all*.jar"/>
+            <include name="noggit*.jar"/>
+            <include name="javassist*.jar"/>
+            <include name="objenesis*.jar"/>
+        </fileset>
+    </path>
     
     <target name="doc">
         <mkdir dir="dist/doc"/>
@@ -1518,7 +1533,7 @@
         <mkdir dir="build/core-tests/classes"/>
         <javac srcdir="core/src/test/java" destdir="build/core-tests/classes" deprecation="true"
target="1.6" source="1.6" debug="true" encoding="utf-8" debuglevel="lines,vars,source">
             <classpath>
-                <path refid="framework-classpath"/>
+                <path refid="framework-test-classpath"/>
                 <pathelement location="build/core/classes"/>
             </classpath>
         </javac>
@@ -1528,7 +1543,7 @@
         <mkdir dir="build/agents-tests/classes"/>
         <javac srcdir="agents/src/test/java" destdir="build/agents-tests/classes" deprecation="true"
target="1.6" source="1.6" debug="true" encoding="utf-8" debuglevel="lines,vars,source">
             <classpath>
-                <path refid="framework-classpath"/>
+                <path refid="framework-test-classpath"/>
                 <pathelement location="build/core/classes"/>
                 <pathelement location="build/core-tests/classes"/>
                 <pathelement location="build/agents/classes"/>
@@ -1540,7 +1555,7 @@
         <mkdir dir="build/pull-agent-tests/classes"/>
         <javac srcdir="pull-agent/src/test/java" destdir="build/pull-agent-tests/classes"
deprecation="true" target="1.6" source="1.6" debug="true" encoding="utf-8" debuglevel="lines,vars,source">
             <classpath>
-                <path refid="framework-classpath"/>
+                <path refid="framework-test-classpath"/>
                 <pathelement location="build/core/classes"/>
                 <pathelement location="build/core-tests/classes"/>
                 <pathelement location="build/agents/classes"/>
@@ -1554,7 +1569,7 @@
         <mkdir dir="build/script-engine-tests/classes"/>
         <javac srcdir="script-engine/src/test/java" destdir="build/script-engine-tests/classes"
deprecation="true" target="1.6" source="1.6" debug="true" encoding="utf-8" debuglevel="lines,vars,source">
             <classpath>
-                <path refid="framework-classpath"/>
+                <path refid="framework-test-classpath"/>
                 <pathelement location="build/core/classes"/>
                 <pathelement location="build/script-engine/classes"/>
             </classpath>
@@ -1594,6 +1609,15 @@
             <fileset dir="../lib">
                 <include name="junit*.jar"/>
                 <include name="juli*.jar"/>
+                <include name="powermock-module-junit4*.jar"/>
+                <include name="powermock-core*.jar"/>
+                <include name="powermock-reflect*.jar"/>
+                <include name="powermock-api-support*.jar"/>
+                <include name="powermock-api-mockito*.jar"/>
+                <include name="mockito-all*.jar"/>
+                <include name="noggit*.jar"/>
+                <include name="javassist*.jar"/>
+                <include name="objenesis*.jar"/>
             </fileset>
             <fileset dir="build/test-jar">
                 <include name="mcf-core-tests.jar"/>
@@ -1610,7 +1634,7 @@
         <mkdir dir="test-output"/>
         <junit fork="true" maxmemory="128m" dir="test-output" outputtoformatters="true"
showoutput="true" haltonfailure="true">
             <classpath>
-                <path refid="framework-classpath"/>
+                <path refid="framework-test-classpath"/>
                 <pathelement location="build/core/classes"/>
                 <pathelement location="build/core-tests/classes"/>
             </classpath>
@@ -1628,7 +1652,7 @@
         <mkdir dir="test-output"/>
         <junit fork="true" maxmemory="128m" dir="test-output" outputtoformatters="true"
showoutput="true" haltonfailure="true">
             <classpath>
-                <path refid="framework-classpath"/>
+                <path refid="framework-test-classpath"/>
                 <pathelement location="build/core/classes"/>
                 <pathelement location="build/core-tests/classes"/>
                 <pathelement location="build/agents/classes"/>
@@ -1647,7 +1671,7 @@
         <mkdir dir="test-output"/>
         <junit fork="true" maxmemory="128m" dir="test-output" outputtoformatters="true"
showoutput="true" haltonfailure="true">
             <classpath>
-                <path refid="framework-classpath"/>
+                <path refid="framework-test-classpath"/>
                 <pathelement location="build/core/classes"/>
                 <pathelement location="build/script-engine/classes"/>
                 <pathelement location="build/script-engine-tests/classes"/>
@@ -1664,7 +1688,7 @@
         <mkdir dir="test-output"/>
         <junit fork="true" maxmemory="128m" dir="test-output" outputtoformatters="true"
showoutput="true" haltonfailure="true">
             <classpath>
-                <path refid="framework-classpath"/>
+                <path refid="framework-test-classpath"/>
                 <fileset dir="build/test-jar">
                     <include name="mcf-core-tests.jar"/>
                 </fileset>
@@ -1682,7 +1706,7 @@
         <mkdir dir="test-derby-output"/>
         <junit fork="true" maxmemory="128m" dir="test-derby-output" outputtoformatters="true"
showoutput="true" haltonfailure="true">
             <classpath>
-                <path refid="framework-classpath"/>
+                <path refid="framework-test-classpath"/>
                 <pathelement location="build/core/classes"/>
                 <pathelement location="build/ui-core/classes"/>
                 <pathelement location="build/agents/classes"/>
@@ -1705,7 +1729,7 @@
         <mkdir dir="test-postgresql-output"/>
         <junit fork="true" maxmemory="128m" dir="test-postgresql-output" outputtoformatters="true"
showoutput="true" haltonfailure="true">
             <classpath>
-                <path refid="framework-classpath"/>
+                <path refid="framework-test-classpath"/>
                 <pathelement location="build/core/classes"/>
                 <pathelement location="build/ui-core/classes"/>
                 <pathelement location="build/agents/classes"/>
@@ -1728,7 +1752,7 @@
         <mkdir dir="test-mysql-output"/>
         <junit fork="true" maxmemory="128m" dir="test-mysql-output" outputtoformatters="true"
showoutput="true" haltonfailure="true">
             <classpath>
-                <path refid="framework-classpath"/>
+                <path refid="framework-test-classpath"/>
                 <pathelement location="build/core/classes"/>
                 <pathelement location="build/ui-core/classes"/>
                 <pathelement location="build/agents/classes"/>
@@ -1751,7 +1775,7 @@
         <mkdir dir="test-HSQLDB-output"/>
         <junit fork="true" maxmemory="128m" dir="test-HSQLDB-output" outputtoformatters="true"
showoutput="true" haltonfailure="true">
             <classpath>
-                <path refid="framework-classpath"/>
+                <path refid="framework-test-classpath"/>
                 <pathelement location="build/core/classes"/>
                 <pathelement location="build/ui-core/classes"/>
                 <pathelement location="build/agents/classes"/>
@@ -1774,7 +1798,7 @@
         <mkdir dir="test-HSQLDBext-output"/>
         <junit fork="true" maxmemory="128m" dir="test-HSQLDBext-output" outputtoformatters="true"
showoutput="true" haltonfailure="true">
             <classpath>
-                <path refid="framework-classpath"/>
+                <path refid="framework-test-classpath"/>
                 <pathelement location="build/core/classes"/>
                 <pathelement location="build/ui-core/classes"/>
                 <pathelement location="build/agents/classes"/>

Modified: manifoldcf/branches/CONNECTORS-856-2/framework/buildfiles/connector-build.xml
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-856-2/framework/buildfiles/connector-build.xml?rev=1583903&r1=1583902&r2=1583903&view=diff
==============================================================================
--- manifoldcf/branches/CONNECTORS-856-2/framework/buildfiles/connector-build.xml (original)
+++ manifoldcf/branches/CONNECTORS-856-2/framework/buildfiles/connector-build.xml Wed Apr
 2 07:15:40 2014
@@ -130,7 +130,6 @@
             <include name="slf4j*.jar"/>
             <include name="jsp-2.1*.jar"/>
             <include name="jsp-api*.jar"/>
-            <include name="junit*.jar"/>
             <include name="log4j*.jar"/>
             <include name="serializer*.jar"/>
             <include name="servlet-api*.jar"/>

Modified: manifoldcf/branches/CONNECTORS-856-2/lib-license/LICENSE.txt
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-856-2/lib-license/LICENSE.txt?rev=1583903&r1=1583902&r2=1583903&view=diff
==============================================================================
--- manifoldcf/branches/CONNECTORS-856-2/lib-license/LICENSE.txt (original)
+++ manifoldcf/branches/CONNECTORS-856-2/lib-license/LICENSE.txt Wed Apr  2 07:15:40 2014
@@ -323,10 +323,29 @@ License: Apache 2 (http://www.apache.org
 This product includes a guava.jar.
 License: Apache 2  (http://www.apache.org/licenses/LICENSE-2.0.txt)
 
+This product includes a mockito-all.jar.
+License: MIT (http://code.google.com/p/mockito/wiki/License)
+
 This product may include pdf files that embed IPA-licensed fonts.
 License: IPA Font License Agreement v1.0 (http://ossipedia.ipa.go.jp/ipafont/index.html#LicenseEng)
 
 ==========================================================================
+The following license applies to mockito-all.jar:
+--------------------------------------------------------------------------
+
+
+The MIT License
+
+Copyright (c) 2007 Mockito contributors
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software
and associated documentation files (the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge, publish, distribute,
sublicense, and/or sell copies of the Software, and to permit persons to whom the Software
is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all copies or
substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+
+==========================================================================
 The following license applies to json.jar, which is generated from the json
 sources from http://www.json.org/java/index.html
 --------------------------------------------------------------------------

Modified: manifoldcf/branches/CONNECTORS-856-2/pom.xml
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-856-2/pom.xml?rev=1583903&r1=1583902&r2=1583903&view=diff
==============================================================================
--- manifoldcf/branches/CONNECTORS-856-2/pom.xml (original)
+++ manifoldcf/branches/CONNECTORS-856-2/pom.xml Wed Apr  2 07:15:40 2014
@@ -38,6 +38,7 @@
     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
     <!-- dependency versions -->
     <junit.version>4.8.2</junit.version>
+    <powerMock.version>1.5.2</powerMock.version>
     <postgresql.version>9.1-901.jdbc4</postgresql.version>
     <mysql.version>5.1.18</mysql.version>
     <hsqldb.version>2.3.1</hsqldb.version>



Mime
View raw message