2008-06-20 16:00:54 -04:00
|
|
|
#!/bin/sh
|
|
|
|
# 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.
|
|
|
|
|
|
|
|
#Test script to tell if the server is accepting UTF-8
|
|
|
|
#The python writer currently escapes non-ascii chars, so it's good for testing
|
|
|
|
|
2015-08-12 13:43:08 -04:00
|
|
|
SOLR_URL=http://localhost:8983/solr
|
2008-06-20 16:00:54 -04:00
|
|
|
|
2008-06-20 16:12:14 -04:00
|
|
|
if [ ! -z $1 ]; then
|
2015-08-12 13:43:08 -04:00
|
|
|
SOLR_URL=$1
|
2008-06-20 16:12:14 -04:00
|
|
|
fi
|
|
|
|
|
2015-08-12 13:43:08 -04:00
|
|
|
curl "$SOLR_URL/select?q=hello¶ms=explicit&wt=python" 2> /dev/null | grep 'hello' > /dev/null 2>&1
|
2008-06-20 16:00:54 -04:00
|
|
|
if [ $? = 0 ]; then
|
|
|
|
echo "Solr server is up."
|
|
|
|
else
|
2012-09-27 11:01:25 -04:00
|
|
|
echo "ERROR: Could not curl to Solr - is curl installed? Is Solr not running?"
|
2008-06-20 16:00:54 -04:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2015-08-12 13:43:08 -04:00
|
|
|
curl "$SOLR_URL/select?q=h%C3%A9llo&echoParams=explicit&wt=python" 2> /dev/null | grep 'h\\u00e9llo' > /dev/null 2>&1
|
2008-06-20 16:00:54 -04:00
|
|
|
if [ $? = 0 ]; then
|
|
|
|
echo "HTTP GET is accepting UTF-8"
|
|
|
|
else
|
|
|
|
echo "ERROR: HTTP GET is not accepting UTF-8"
|
|
|
|
fi
|
|
|
|
|
2015-08-12 13:43:08 -04:00
|
|
|
curl $SOLR_URL/select --data-binary 'q=h%C3%A9llo&echoParams=explicit&wt=python' -H 'Content-type:application/x-www-form-urlencoded; charset=UTF-8' 2> /dev/null | grep 'h\\u00e9llo' > /dev/null 2>&1
|
2008-06-20 16:00:54 -04:00
|
|
|
if [ $? = 0 ]; then
|
|
|
|
echo "HTTP POST is accepting UTF-8"
|
|
|
|
else
|
|
|
|
echo "ERROR: HTTP POST is not accepting UTF-8"
|
|
|
|
fi
|
|
|
|
|
2015-08-12 13:43:08 -04:00
|
|
|
curl $SOLR_URL/select --data-binary 'q=h%C3%A9llo&echoParams=explicit&wt=python' 2> /dev/null | grep 'h\\u00e9llo' > /dev/null 2>&1
|
2008-06-20 16:12:14 -04:00
|
|
|
if [ $? = 0 ]; then
|
|
|
|
echo "HTTP POST defaults to UTF-8"
|
|
|
|
else
|
|
|
|
echo "HTTP POST does not default to UTF-8"
|
|
|
|
fi
|
|
|
|
|
2008-08-04 17:54:33 -04:00
|
|
|
|
2011-02-25 17:09:14 -05:00
|
|
|
#A unicode character outside of the BMP (a circle with an x inside)
|
|
|
|
CHAR="𐌈"
|
|
|
|
CODEPOINT='0x10308'
|
2008-08-04 17:54:33 -04:00
|
|
|
#URL encoded UTF8 of the codepoint
|
2015-08-12 13:43:08 -04:00
|
|
|
UTF8_Q='%F0%90%8C%88'
|
2008-08-04 17:54:33 -04:00
|
|
|
#expected return of the python writer (currently uses UTF-16 surrogates)
|
2011-02-25 17:09:14 -05:00
|
|
|
EXPECTED='\\ud800\\udf08'
|
2008-08-04 17:54:33 -04:00
|
|
|
|
2015-08-12 13:43:08 -04:00
|
|
|
curl "$SOLR_URL/select?q=$UTF8_Q&echoParams=explicit&wt=python" 2> /dev/null | grep $EXPECTED > /dev/null 2>&1
|
2008-08-04 17:54:33 -04:00
|
|
|
if [ $? = 0 ]; then
|
|
|
|
echo "HTTP GET is accepting UTF-8 beyond the basic multilingual plane"
|
|
|
|
else
|
|
|
|
echo "ERROR: HTTP GET is not accepting UTF-8 beyond the basic multilingual plane"
|
|
|
|
fi
|
|
|
|
|
2015-08-12 13:43:08 -04:00
|
|
|
curl $SOLR_URL/select --data-binary "q=$UTF8_Q&echoParams=explicit&wt=python" -H 'Content-type:application/x-www-form-urlencoded; charset=UTF-8' 2> /dev/null | grep $EXPECTED > /dev/null 2>&1
|
2008-08-04 17:54:33 -04:00
|
|
|
if [ $? = 0 ]; then
|
|
|
|
echo "HTTP POST is accepting UTF-8 beyond the basic multilingual plane"
|
|
|
|
else
|
|
|
|
echo "ERROR: HTTP POST is not accepting UTF-8 beyond the basic multilingual plane"
|
|
|
|
fi
|
|
|
|
|
2015-08-12 13:43:08 -04:00
|
|
|
curl "$SOLR_URL/select?q=$UTF8_Q&echoParams=explicit&wt=python" --data-binary '' 2> /dev/null | grep $EXPECTED > /dev/null 2>&1
|
2008-08-04 17:54:33 -04:00
|
|
|
if [ $? = 0 ]; then
|
|
|
|
echo "HTTP POST + URL params is accepting UTF-8 beyond the basic multilingual plane"
|
|
|
|
else
|
|
|
|
echo "ERROR: HTTP POST + URL params is not accepting UTF-8 beyond the basic multilingual plane"
|
|
|
|
fi
|
|
|
|
|
2017-07-24 11:42:02 -04:00
|
|
|
#curl "$SOLR_URL/select?q=$UTF8_Q&echoParams=explicit" 2> /dev/null | od -tx1 -w1000 | sed 's/ //g' | grep 'f4808198' > /dev/null 2>&1
|
|
|
|
curl "$SOLR_URL/select?q=$UTF8_Q&echoParams=explicit" 2> /dev/null | grep "$CHAR" > /dev/null 2>&1
|
2011-02-25 17:07:34 -05:00
|
|
|
if [ $? = 0 ]; then
|
2011-02-25 17:09:14 -05:00
|
|
|
echo "Response correctly returns UTF-8 beyond the basic multilingual plane"
|
2011-02-25 17:07:34 -05:00
|
|
|
else
|
|
|
|
echo "ERROR: Response can't return UTF-8 beyond the basic multilingual plane"
|
|
|
|
fi
|
|
|
|
|
|
|
|
|