/**
* 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.solr.handler.dataimport;
import org.junit.After;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import java.util.Arrays;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class TestThreaded extends AbstractDataImportHandlerTestCase {
private static final String threads2 = "threads=\"2\"";
private static final Pattern threads2Pattern = Pattern.compile(threads2);
private static String dataConfigNPulsOne = "\n"
+"\n"
+ " \n"
+ " "
+ " \n"
+ " \n"
+ " \n"
+ " \n" + " \n"
+ " \n" + "";
private static final Matcher nPulsOne = threads2Pattern.matcher(dataConfigNPulsOne);
@BeforeClass
public static void beforeClass() throws Exception {
initCore("dataimport-solrconfig.xml", "dataimport-schema.xml");
}
@Before
public void setupData(){
List parentRow = new ArrayList();
// parentRow.add(createMap("id", "1"));
parentRow.add(createMap("id", "2"));
parentRow.add(createMap("id", "3"));
parentRow.add(createMap("id", "4"));
parentRow.add(createMap("id", "1"));
MockDataSource.setCollection("select * from x", parentRow);
// for every x we have four linked y-s
List childRow = Arrays.asList(
createMap("desc", "hello"),
createMap("desc", "bye"),
createMap("desc", "hi"),
createMap("desc", "aurevoir"));
// for N+1 scenario
MockDataSource.setCollection("select * from y where y.A=1", shuffled(childRow));
MockDataSource.setCollection("select * from y where y.A=2", shuffled(childRow));
MockDataSource.setCollection("select * from y where y.A=3", shuffled(childRow));
MockDataSource.setCollection("select * from y where y.A=4", shuffled(childRow));
// for cached scenario
List cartesianProduct = new ArrayList();
for(Map parent : (List