mirror of https://github.com/apache/lucene.git
SOLR-2542: Fixed DIH Context variables which were broken for all scopes other then SCOPE_ENTITY
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1231367 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
8b8c2b4dee
commit
b2de49f606
|
@ -455,6 +455,9 @@ Bug Fixes
|
|||
* SOLR-3024: Fixed JSONTestUtil.matchObj, in previous releases it was not
|
||||
respecting the 'delta' arg (David Smiley via hossman)
|
||||
|
||||
* SOLR-2542: Fixed DIH Context variables which were broken for all scopes other
|
||||
then SCOPE_ENTITY (Linbin Chen & Frank Wesemann via hossman)
|
||||
|
||||
Other Changes
|
||||
----------------------
|
||||
* SOLR-2922: Upgrade commons-io and commons-lang to 2.1 and 2.6, respectively. (koji)
|
||||
|
|
|
@ -155,7 +155,7 @@ public class ContextImpl extends Context {
|
|||
|
||||
private void putVal(String name, Object val, Map map) {
|
||||
if(val == null) map.remove(name);
|
||||
else entitySession.put(name, val);
|
||||
else map.put(name, val);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -0,0 +1,71 @@
|
|||
/**
|
||||
* 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 java.util.HashMap;
|
||||
|
||||
import org.apache.solr.handler.dataimport.DataConfig.Entity;
|
||||
import org.apache.solr.handler.dataimport.DataImporter.RequestParams;
|
||||
import org.junit.Test;
|
||||
|
||||
public class TestContextImpl extends AbstractDataImportHandlerTestCase {
|
||||
|
||||
@Test
|
||||
public void testEntityScope() {
|
||||
ContextImpl ctx = new ContextImpl(new Entity(), new VariableResolverImpl(), null, "something", new HashMap<String,Object>(), null, null);
|
||||
String lala = new String("lala");
|
||||
ctx.setSessionAttribute("huhu", lala, Context.SCOPE_ENTITY);
|
||||
Object got = ctx.getSessionAttribute("huhu", Context.SCOPE_ENTITY);
|
||||
|
||||
assertEquals(lala, got);
|
||||
|
||||
}
|
||||
@Test
|
||||
public void testCoreScope() {
|
||||
DataImporter di = new DataImporter();
|
||||
di.loadAndInit("<dataConfig><document /></dataConfig>");
|
||||
DocBuilder db = new DocBuilder(di, new SolrWriter(null, null),new SimplePropertiesWriter(), new RequestParams());
|
||||
ContextImpl ctx = new ContextImpl(new Entity(), new VariableResolverImpl(), null, "something", new HashMap<String,Object>(), null, db);
|
||||
String lala = new String("lala");
|
||||
ctx.setSessionAttribute("huhu", lala, Context.SCOPE_SOLR_CORE);
|
||||
Object got = ctx.getSessionAttribute("huhu", Context.SCOPE_SOLR_CORE);
|
||||
assertEquals(lala, got);
|
||||
|
||||
}
|
||||
@Test
|
||||
public void testDocumentScope() {
|
||||
ContextImpl ctx = new ContextImpl(new Entity(), new VariableResolverImpl(), null, "something", new HashMap<String,Object>(), null, null);
|
||||
ctx.setDoc(new DocBuilder.DocWrapper());
|
||||
String lala = new String("lala");
|
||||
ctx.setSessionAttribute("huhu", lala, Context.SCOPE_DOC);
|
||||
Object got = ctx.getSessionAttribute("huhu", Context.SCOPE_DOC);
|
||||
|
||||
assertEquals(lala, got);
|
||||
|
||||
}
|
||||
@Test
|
||||
public void testGlobalScope() {
|
||||
ContextImpl ctx = new ContextImpl(new Entity(), new VariableResolverImpl(), null, "something", new HashMap<String,Object>(), null, null);
|
||||
String lala = new String("lala");
|
||||
ctx.setSessionAttribute("huhu", lala, Context.SCOPE_GLOBAL);
|
||||
Object got = ctx.getSessionAttribute("huhu", Context.SCOPE_GLOBAL);
|
||||
|
||||
assertEquals(lala, got);
|
||||
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue