source: sandbox/expresso-solr/solr/example/exampledocs/test_utf8.sh @ 7588

Revision 7588, 3.6 KB checked in by adir, 11 years ago (diff)

Ticket #000 - Adicionando a integracao de buscas com Solr na base a ser isnerida na comunidade

  • Property svn:executable set to *
Line 
1#!/bin/sh
2# Licensed to the Apache Software Foundation (ASF) under one or more
3# contributor license agreements.  See the NOTICE file distributed with
4# this work for additional information regarding copyright ownership.
5# The ASF licenses this file to You under the Apache License, Version 2.0
6# (the "License"); you may not use this file except in compliance with
7# the License.  You may obtain a copy of the License at
8#
9#     http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16
17#Test script to tell if the server is accepting UTF-8
18#The python writer currently escapes non-ascii chars, so it's good for testing
19
20URL=http://localhost:8983/solr
21
22if [ ! -z $1 ]; then
23  URL=$1
24fi
25
26curl "$URL/select?q=hello&params=explicit&wt=python" 2> /dev/null | grep 'hello' > /dev/null 2>&1
27if [ $? = 0 ]; then
28  echo "Solr server is up."
29else
30  echo "ERROR: Solr is not up."
31  exit 1
32fi
33
34curl "$URL/select?q=h%C3%A9llo&echoParams=explicit&wt=python" 2> /dev/null | grep 'h\\u00e9llo' > /dev/null 2>&1
35if [ $? = 0 ]; then
36  echo "HTTP GET is accepting UTF-8"
37else
38  echo "ERROR: HTTP GET is not accepting UTF-8"
39fi
40
41curl $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
42if [ $? = 0 ]; then
43  echo "HTTP POST is accepting UTF-8"
44else
45  echo "ERROR: HTTP POST is not accepting UTF-8"
46fi
47
48curl $URL/select --data-binary 'q=h%C3%A9llo&echoParams=explicit&wt=python' 2> /dev/null | grep 'h\\u00e9llo' > /dev/null 2>&1
49if [ $? = 0 ]; then
50  echo "HTTP POST defaults to UTF-8"
51else
52  echo "HTTP POST does not default to UTF-8"
53fi
54
55
56#A unicode character outside of the BMP (a circle with an x inside)
57CHAR="𐌈"
58CODEPOINT='0x10308'
59#URL encoded UTF8 of the codepoint
60URL_UTF8='%F0%90%8C%88'
61#expected return of the python writer (currently uses UTF-16 surrogates)
62EXPECTED='\\ud800\\udf08'
63
64curl "$URL/select?q=$URL_UTF8&echoParams=explicit&wt=python" 2> /dev/null | grep $EXPECTED > /dev/null 2>&1
65if [ $? = 0 ]; then
66  echo "HTTP GET is accepting UTF-8 beyond the basic multilingual plane"
67else
68  echo "ERROR: HTTP GET is not accepting UTF-8 beyond the basic multilingual plane"
69fi
70
71curl $URL/select --data-binary "q=$URL_UTF8&echoParams=explicit&wt=python"  -H 'Content-type:application/x-www-form-urlencoded; charset=UTF-8' 2> /dev/null | grep $EXPECTED > /dev/null 2>&1
72if [ $? = 0 ]; then
73  echo "HTTP POST is accepting UTF-8 beyond the basic multilingual plane"
74else
75  echo "ERROR: HTTP POST is not accepting UTF-8 beyond the basic multilingual plane"
76fi
77
78curl "$URL/select?q=$URL_UTF8&echoParams=explicit&wt=python" --data-binary '' 2> /dev/null | grep $EXPECTED > /dev/null 2>&1
79if [ $? = 0 ]; then
80  echo "HTTP POST + URL params is accepting UTF-8 beyond the basic multilingual plane"
81else
82  echo "ERROR: HTTP POST + URL params is not accepting UTF-8 beyond the basic multilingual plane"
83fi
84
85#curl "$URL/select?q=$URL_UTF8&echoParams=explicit&wt=json" 2> /dev/null | od -tx1 -w1000 | sed 's/ //g' | grep 'f4808198' > /dev/null 2>&1
86curl "$URL/select?q=$URL_UTF8&echoParams=explicit&wt=json" 2> /dev/null | grep "$CHAR" > /dev/null 2>&1
87if [ $? = 0 ]; then
88  echo "Response correctly returns UTF-8 beyond the basic multilingual plane"
89else
90  echo "ERROR: Response can't return UTF-8 beyond the basic multilingual plane"
91fi
92
93
Note: See TracBrowser for help on using the repository browser.