mirror of
https://github.com/zxing/zxing.git
synced 2024-11-09 20:44:03 -08:00
Many more changes from recent IJ inspections
This commit is contained in:
parent
431ae9e06e
commit
36f38c5beb
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,5 +1,4 @@
|
|||
target
|
||||
private
|
||||
.idea
|
||||
*.iml
|
||||
.DS_Store
|
||||
|
|
|
@ -40,6 +40,7 @@ import android.util.Log;
|
|||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
|
@ -195,7 +196,7 @@ final class QRCodeEncoder {
|
|||
baos.write(buffer, 0, bytesRead);
|
||||
}
|
||||
vcard = baos.toByteArray();
|
||||
vcardString = new String(vcard, 0, vcard.length, "UTF-8");
|
||||
vcardString = new String(vcard, 0, vcard.length, StandardCharsets.UTF_8);
|
||||
} catch (IOException ioe) {
|
||||
throw new WriterException(ioe);
|
||||
}
|
||||
|
|
|
@ -99,7 +99,7 @@ final class BookResultInfoRetriever extends SupplementalInfoRetriever {
|
|||
String baseBookUri = "http://www.google." + LocaleManager.getBookSearchCountryTLD(context)
|
||||
+ "/search?tbm=bks&source=zxing&q=";
|
||||
|
||||
append(isbn, source, newTexts.toArray(new String[newTexts.size()]), baseBookUri + isbn);
|
||||
append(isbn, source, newTexts.toArray(EMPTY_STR_ARRAY), baseBookUri + isbn);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -46,6 +46,8 @@ public abstract class SupplementalInfoRetriever extends AsyncTask<Object,Object,
|
|||
|
||||
private static final String TAG = "SupplementalInfo";
|
||||
|
||||
static final String[] EMPTY_STR_ARRAY = new String[0];
|
||||
|
||||
private final WeakReference<TextView> textViewRef;
|
||||
private final WeakReference<HistoryManager> historyManagerRef;
|
||||
private final Collection<Spannable> newContents;
|
||||
|
|
|
@ -37,6 +37,8 @@ import java.util.Map;
|
|||
*/
|
||||
public final class MultiFormatReader implements Reader {
|
||||
|
||||
private static final Reader[] EMPTY_READER_ARRAY = new Reader[0];
|
||||
|
||||
private Map<DecodeHintType,?> hints;
|
||||
private Reader[] readers;
|
||||
|
||||
|
@ -152,7 +154,7 @@ public final class MultiFormatReader implements Reader {
|
|||
readers.add(new MultiFormatOneDReader(hints));
|
||||
}
|
||||
}
|
||||
this.readers = readers.toArray(new Reader[readers.size()]);
|
||||
this.readers = readers.toArray(EMPTY_READER_ARRAY);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -24,7 +24,6 @@ import java.util.Collections;
|
|||
import java.util.Comparator;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* This produces nearly optimal encodings of text into the first-level of
|
||||
|
@ -284,7 +283,7 @@ public final class HighLevelEncoder {
|
|||
}
|
||||
|
||||
private static Collection<State> simplifyStates(Iterable<State> states) {
|
||||
List<State> result = new LinkedList<>();
|
||||
Collection<State> result = new LinkedList<>();
|
||||
for (State newState : states) {
|
||||
boolean add = true;
|
||||
for (Iterator<State> iterator = result.iterator(); iterator.hasNext();) {
|
||||
|
|
|
@ -85,7 +85,7 @@ public final class AddressBookAUResultParser extends ResultParser {
|
|||
if (values == null) {
|
||||
return null;
|
||||
}
|
||||
return values.toArray(new String[values.size()]);
|
||||
return values.toArray(EMPTY_STR_ARRAY);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -67,6 +67,8 @@ public abstract class ResultParser {
|
|||
private static final Pattern EQUALS = Pattern.compile("=");
|
||||
private static final String BYTE_ORDER_MARK = "\ufeff";
|
||||
|
||||
static final String[] EMPTY_STR_ARRAY = new String[0];
|
||||
|
||||
/**
|
||||
* Attempts to parse the raw {@link Result}'s contents as a particular type
|
||||
* of information (email, URL, etc.) and return a {@link ParsedResult} encapsulating
|
||||
|
@ -236,7 +238,7 @@ public abstract class ResultParser {
|
|||
if (matches == null || matches.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
return matches.toArray(new String[matches.size()]);
|
||||
return matches.toArray(EMPTY_STR_ARRAY);
|
||||
}
|
||||
|
||||
private static int countPrecedingBackslashes(CharSequence s, int pos) {
|
||||
|
|
|
@ -80,8 +80,8 @@ public final class SMSMMSResultParser extends ResultParser {
|
|||
}
|
||||
addNumberVia(numbers, vias, smsURIWithoutQuery.substring(lastComma + 1));
|
||||
|
||||
return new SMSParsedResult(numbers.toArray(new String[numbers.size()]),
|
||||
vias.toArray(new String[vias.size()]),
|
||||
return new SMSParsedResult(numbers.toArray(EMPTY_STR_ARRAY),
|
||||
vias.toArray(EMPTY_STR_ARRAY),
|
||||
subject,
|
||||
body);
|
||||
}
|
||||
|
@ -106,4 +106,4 @@ public final class SMSMMSResultParser extends ResultParser {
|
|||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -296,7 +296,7 @@ public final class VCardResultParser extends ResultParser {
|
|||
result.add(value);
|
||||
}
|
||||
}
|
||||
return result.toArray(new String[result.size()]);
|
||||
return result.toArray(EMPTY_STR_ARRAY);
|
||||
}
|
||||
|
||||
private static String[] toTypes(Collection<List<String>> lists) {
|
||||
|
@ -324,7 +324,7 @@ public final class VCardResultParser extends ResultParser {
|
|||
result.add(type);
|
||||
}
|
||||
}
|
||||
return result.toArray(new String[result.size()]);
|
||||
return result.toArray(EMPTY_STR_ARRAY);
|
||||
}
|
||||
|
||||
private static boolean isLikeVCardDate(CharSequence value) {
|
||||
|
|
|
@ -99,7 +99,7 @@ public final class BitArray implements Cloneable {
|
|||
int bitsOffset = from / 32;
|
||||
int currentBits = bits[bitsOffset];
|
||||
// mask off lesser bits first
|
||||
currentBits &= ~((1 << (from & 0x1F)) - 1);
|
||||
currentBits &= -(1 << (from & 0x1F));
|
||||
while (currentBits == 0) {
|
||||
if (++bitsOffset == bits.length) {
|
||||
return size;
|
||||
|
@ -122,7 +122,7 @@ public final class BitArray implements Cloneable {
|
|||
int bitsOffset = from / 32;
|
||||
int currentBits = ~bits[bitsOffset];
|
||||
// mask off lesser bits first
|
||||
currentBits &= ~((1 << (from & 0x1F)) - 1);
|
||||
currentBits &= -(1 << (from & 0x1F));
|
||||
while (currentBits == 0) {
|
||||
if (++bitsOffset == bits.length) {
|
||||
return size;
|
||||
|
|
|
@ -90,7 +90,6 @@ public final class WhiteRectangleDetector {
|
|||
int down = downInit;
|
||||
boolean sizeExceeded = false;
|
||||
boolean aBlackPointFoundOnBorder = true;
|
||||
boolean atLeastOneBlackPointFoundOnBorder = false;
|
||||
|
||||
boolean atLeastOneBlackPointFoundOnRight = false;
|
||||
boolean atLeastOneBlackPointFoundOnBottom = false;
|
||||
|
@ -181,13 +180,9 @@ public final class WhiteRectangleDetector {
|
|||
break;
|
||||
}
|
||||
|
||||
if (aBlackPointFoundOnBorder) {
|
||||
atLeastOneBlackPointFoundOnBorder = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (!sizeExceeded && atLeastOneBlackPointFoundOnBorder) {
|
||||
if (!sizeExceeded) {
|
||||
|
||||
int maxSize = right - left;
|
||||
|
||||
|
|
|
@ -45,8 +45,7 @@ class C40Encoder implements Encoder {
|
|||
if ((buffer.length() % 3) == 2 && (available < 2 || available > 2)) {
|
||||
lastCharSize = backtrackOneCharacter(context, buffer, removed, lastCharSize);
|
||||
}
|
||||
while ((buffer.length() % 3) == 1
|
||||
&& ((lastCharSize <= 3 && available != 1) || lastCharSize > 3)) {
|
||||
while ((buffer.length() % 3) == 1 && (lastCharSize > 3 || available != 1)) {
|
||||
lastCharSize = backtrackOneCharacter(context, buffer, removed, lastCharSize);
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -59,14 +59,10 @@ public final class MaxiCodeReader implements Reader {
|
|||
@Override
|
||||
public Result decode(BinaryBitmap image, Map<DecodeHintType,?> hints)
|
||||
throws NotFoundException, ChecksumException, FormatException {
|
||||
DecoderResult decoderResult;
|
||||
if (hints != null && hints.containsKey(DecodeHintType.PURE_BARCODE)) {
|
||||
BitMatrix bits = extractPureBits(image.getBlackMatrix());
|
||||
decoderResult = decoder.decode(bits, hints);
|
||||
} else {
|
||||
throw NotFoundException.getNotFoundInstance();
|
||||
}
|
||||
|
||||
// Note that MaxiCode reader effectively always assumes PURE_BARCODE mode
|
||||
// and can't detect it in an image
|
||||
BitMatrix bits = extractPureBits(image.getBlackMatrix());
|
||||
DecoderResult decoderResult = decoder.decode(bits, hints);
|
||||
Result result = new Result(decoderResult.getText(), decoderResult.getRawBytes(), NO_POINTS, BarcodeFormat.MAXICODE);
|
||||
|
||||
String ecLevel = decoderResult.getECLevel();
|
||||
|
|
|
@ -47,6 +47,8 @@ public final class GenericMultipleBarcodeReader implements MultipleBarcodeReader
|
|||
private static final int MIN_DIMENSION_TO_RECUR = 100;
|
||||
private static final int MAX_DEPTH = 4;
|
||||
|
||||
static final Result[] EMPTY_RESULT_ARRAY = new Result[0];
|
||||
|
||||
private final Reader delegate;
|
||||
|
||||
public GenericMultipleBarcodeReader(Reader delegate) {
|
||||
|
@ -66,7 +68,7 @@ public final class GenericMultipleBarcodeReader implements MultipleBarcodeReader
|
|||
if (results.isEmpty()) {
|
||||
throw NotFoundException.getNotFoundInstance();
|
||||
}
|
||||
return results.toArray(new Result[results.size()]);
|
||||
return results.toArray(EMPTY_RESULT_ARRAY);
|
||||
}
|
||||
|
||||
private void doDecodeMultiple(BinaryBitmap image,
|
||||
|
|
|
@ -92,7 +92,7 @@ public final class QRCodeMultiReader extends QRCodeReader implements MultipleBar
|
|||
return EMPTY_RESULT_ARRAY;
|
||||
} else {
|
||||
results = processStructuredAppend(results);
|
||||
return results.toArray(new Result[results.size()]);
|
||||
return results.toArray(EMPTY_RESULT_ARRAY);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -66,7 +66,7 @@ public final class MultiDetector extends Detector {
|
|||
if (result.isEmpty()) {
|
||||
return EMPTY_DETECTOR_RESULTS;
|
||||
} else {
|
||||
return result.toArray(new DetectorResult[result.size()]);
|
||||
return result.toArray(EMPTY_DETECTOR_RESULTS);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -49,6 +49,7 @@ import java.util.Map;
|
|||
final class MultiFinderPatternFinder extends FinderPatternFinder {
|
||||
|
||||
private static final FinderPatternInfo[] EMPTY_RESULT_ARRAY = new FinderPatternInfo[0];
|
||||
private static final FinderPattern[][] EMPTY_FP_2D_ARRAY = new FinderPattern[0][];
|
||||
|
||||
// TODO MIN_MODULE_COUNT and MAX_MODULE_COUNT would be great hints to ask the user for
|
||||
// since it limits the number of regions to decode
|
||||
|
@ -216,12 +217,12 @@ final class MultiFinderPatternFinder extends FinderPatternFinder {
|
|||
|
||||
// All tests passed!
|
||||
results.add(test);
|
||||
} // end iterate p3
|
||||
} // end iterate p2
|
||||
} // end iterate p1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!results.isEmpty()) {
|
||||
return results.toArray(new FinderPattern[results.size()][]);
|
||||
return results.toArray(EMPTY_FP_2D_ARRAY);
|
||||
}
|
||||
|
||||
// Nothing found!
|
||||
|
@ -279,7 +280,7 @@ final class MultiFinderPatternFinder extends FinderPatternFinder {
|
|||
|
||||
if (foundPatternCross(stateCount)) {
|
||||
handlePossibleCenter(stateCount, i, maxJ);
|
||||
} // end if foundPatternCross
|
||||
}
|
||||
} // for i=iSkip-1 ...
|
||||
FinderPattern[][] patternInfo = selectMutipleBestPatterns();
|
||||
List<FinderPatternInfo> result = new ArrayList<>();
|
||||
|
@ -291,7 +292,7 @@ final class MultiFinderPatternFinder extends FinderPatternFinder {
|
|||
if (result.isEmpty()) {
|
||||
return EMPTY_RESULT_ARRAY;
|
||||
} else {
|
||||
return result.toArray(new FinderPatternInfo[result.size()]);
|
||||
return result.toArray(EMPTY_RESULT_ARRAY);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -36,6 +36,8 @@ import java.util.Map;
|
|||
*/
|
||||
public final class MultiFormatOneDReader extends OneDReader {
|
||||
|
||||
private static final OneDReader[] EMPTY_ONED_ARRAY = new OneDReader[0];
|
||||
|
||||
private final OneDReader[] readers;
|
||||
|
||||
public MultiFormatOneDReader(Map<DecodeHintType,?> hints) {
|
||||
|
@ -84,7 +86,7 @@ public final class MultiFormatOneDReader extends OneDReader {
|
|||
readers.add(new RSS14Reader());
|
||||
readers.add(new RSSExpandedReader());
|
||||
}
|
||||
this.readers = readers.toArray(new OneDReader[readers.size()]);
|
||||
this.readers = readers.toArray(EMPTY_ONED_ARRAY);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -37,6 +37,8 @@ import java.util.Map;
|
|||
*/
|
||||
public final class MultiFormatUPCEANReader extends OneDReader {
|
||||
|
||||
private static final UPCEANReader[] EMPTY_READER_ARRAY = new UPCEANReader[0];
|
||||
|
||||
private final UPCEANReader[] readers;
|
||||
|
||||
public MultiFormatUPCEANReader(Map<DecodeHintType,?> hints) {
|
||||
|
@ -63,7 +65,7 @@ public final class MultiFormatUPCEANReader extends OneDReader {
|
|||
readers.add(new EAN8Reader());
|
||||
readers.add(new UPCEReader());
|
||||
}
|
||||
this.readers = readers.toArray(new UPCEANReader[readers.size()]);
|
||||
this.readers = readers.toArray(EMPTY_READER_ARRAY);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -43,6 +43,8 @@ import java.util.Map;
|
|||
*/
|
||||
public final class PDF417Reader implements Reader, MultipleBarcodeReader {
|
||||
|
||||
private static final Result[] EMPTY_RESULT_ARRAY = new Result[0];
|
||||
|
||||
/**
|
||||
* Locates and decodes a PDF417 code in an image.
|
||||
*
|
||||
|
@ -94,7 +96,7 @@ public final class PDF417Reader implements Reader, MultipleBarcodeReader {
|
|||
}
|
||||
results.add(result);
|
||||
}
|
||||
return results.toArray(new Result[results.size()]);
|
||||
return results.toArray(EMPTY_RESULT_ARRAY);
|
||||
}
|
||||
|
||||
private static int getMaxWidth(ResultPoint p1, ResultPoint p2) {
|
||||
|
|
|
@ -256,7 +256,7 @@ public final class PDF417ScanningDecoder {
|
|||
Collection<Integer> erasures = new ArrayList<>();
|
||||
int[] codewords = new int[detectionResult.getBarcodeRowCount() * detectionResult.getBarcodeColumnCount()];
|
||||
List<int[]> ambiguousIndexValuesList = new ArrayList<>();
|
||||
List<Integer> ambiguousIndexesList = new ArrayList<>();
|
||||
Collection<Integer> ambiguousIndexesList = new ArrayList<>();
|
||||
for (int row = 0; row < detectionResult.getBarcodeRowCount(); row++) {
|
||||
for (int column = 0; column < detectionResult.getBarcodeColumnCount(); column++) {
|
||||
int[] values = barcodeMatrix[row][column + 1].getValue();
|
||||
|
|
|
@ -19,9 +19,9 @@ package com.google.zxing.multi.qrcode;
|
|||
import javax.imageio.ImageIO;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import com.google.zxing.BarcodeFormat;
|
||||
import com.google.zxing.BinaryBitmap;
|
||||
|
@ -55,14 +55,14 @@ public final class MultiQRCodeTestCase extends Assert {
|
|||
assertNotNull(results);
|
||||
assertEquals(4, results.length);
|
||||
|
||||
Set<String> barcodeContents = new HashSet<>();
|
||||
Collection<String> barcodeContents = new HashSet<>();
|
||||
for (Result result : results) {
|
||||
barcodeContents.add(result.getText());
|
||||
assertEquals(BarcodeFormat.QR_CODE, result.getBarcodeFormat());
|
||||
Map<ResultMetadataType,Object> metadata = result.getResultMetadata();
|
||||
assertNotNull(metadata);
|
||||
}
|
||||
Set<String> expectedContents = new HashSet<>();
|
||||
Collection<String> expectedContents = new HashSet<>();
|
||||
expectedContents.add("You earned the class a 5 MINUTE DANCE PARTY!! Awesome! Way to go! Let's boogie!");
|
||||
expectedContents.add("You earned the class 5 EXTRA MINUTES OF RECESS!! Fabulous!! Way to go!!");
|
||||
expectedContents.add("You get to SIT AT MRS. SIGMON'S DESK FOR A DAY!! Awesome!! Way to go!! Guess I better clean up! :)");
|
||||
|
|
|
@ -105,7 +105,7 @@ public final class CommandLineRunner {
|
|||
}
|
||||
}
|
||||
|
||||
private static List<URI> expand(List<URI> inputs) throws IOException {
|
||||
private static List<URI> expand(Iterable<URI> inputs) throws IOException {
|
||||
List<URI> expanded = new ArrayList<>();
|
||||
for (URI input : inputs) {
|
||||
if (isFileOrDir(input)) {
|
||||
|
@ -132,7 +132,7 @@ public final class CommandLineRunner {
|
|||
return expanded;
|
||||
}
|
||||
|
||||
private static List<URI> retainValid(List<URI> inputs, boolean recursive) {
|
||||
private static List<URI> retainValid(Iterable<URI> inputs, boolean recursive) {
|
||||
List<URI> retained = new ArrayList<>();
|
||||
for (URI input : inputs) {
|
||||
boolean retain;
|
||||
|
@ -151,7 +151,7 @@ public final class CommandLineRunner {
|
|||
return retained;
|
||||
}
|
||||
|
||||
private static boolean isExpandable(List<URI> inputs) {
|
||||
private static boolean isExpandable(Iterable<URI> inputs) {
|
||||
for (URI input : inputs) {
|
||||
if (isFileOrDir(input) && Files.isDirectory(Paths.get(input))) {
|
||||
return true;
|
||||
|
|
|
@ -30,8 +30,8 @@ import com.google.gwt.user.client.ui.Widget;
|
|||
*/
|
||||
public final class GeoLocationGenerator implements GeneratorSource {
|
||||
|
||||
private static final String LON_REGEXP = "[+-]?[0-9]+(.[0-9]+)?";
|
||||
private static final String LAT_REGEXP = "[+-]?[0-9]+(.[0-9]+)?";
|
||||
private static final String LON_REGEXP = "[+-]?[0-9]+(?:.[0-9]+)?";
|
||||
private static final String LAT_REGEXP = "[+-]?[0-9]+(?:.[0-9]+)?";
|
||||
|
||||
private Grid table;
|
||||
private final TextBox latitude = new TextBox();
|
||||
|
|
|
@ -109,7 +109,7 @@ public final class DecodeServlet extends HttpServlet {
|
|||
HINTS_PURE.put(DecodeHintType.PURE_BARCODE, Boolean.TRUE);
|
||||
}
|
||||
|
||||
private Iterable<String> blockedURLSubstrings;
|
||||
private Collection<String> blockedURLSubstrings;
|
||||
private Timer timer;
|
||||
private DoSTracker destHostTracker;
|
||||
|
||||
|
@ -155,11 +155,14 @@ public final class DecodeServlet extends HttpServlet {
|
|||
|
||||
// Remove any whitespace to sanitize; none is valid anyway
|
||||
imageURIString = WHITESPACE.matcher(imageURIString).replaceAll("");
|
||||
for (CharSequence substring : blockedURLSubstrings) {
|
||||
if (imageURIString.contains(substring)) {
|
||||
log.info("Disallowed URI " + imageURIString);
|
||||
errorResponse(request, response, "badurl");
|
||||
return;
|
||||
|
||||
if (!blockedURLSubstrings.isEmpty()) {
|
||||
for (CharSequence substring : blockedURLSubstrings) {
|
||||
if (imageURIString.contains(substring)) {
|
||||
log.info("Disallowed URI " + imageURIString);
|
||||
errorResponse(request, response, "badurl");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -198,6 +201,11 @@ public final class DecodeServlet extends HttpServlet {
|
|||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (destHostTracker.isBanned(imageURI.getHost())) {
|
||||
errorResponse(request, response, "badurl");
|
||||
return;
|
||||
}
|
||||
|
||||
URL imageURL;
|
||||
try {
|
||||
|
@ -215,12 +223,6 @@ public final class DecodeServlet extends HttpServlet {
|
|||
return;
|
||||
}
|
||||
|
||||
if (destHostTracker.isBanned(imageURL.getHost())) {
|
||||
log.info("Temporarily not requesting from host: " + imageURIString);
|
||||
errorResponse(request, response, "badurl");
|
||||
return;
|
||||
}
|
||||
|
||||
HttpURLConnection connection;
|
||||
try {
|
||||
connection = (HttpURLConnection) imageURL.openConnection();
|
||||
|
|
|
@ -34,7 +34,7 @@ public final class DoSFilterTestCase extends Assert {
|
|||
MockHttpServletRequest request = new MockHttpServletRequest();
|
||||
request.setRequestURI("/");
|
||||
request.setRemoteAddr("1.2.3.4");
|
||||
MockHttpServletResponse response = new MockHttpServletResponse();
|
||||
HttpServletResponse response = new MockHttpServletResponse();
|
||||
DoSFilter filter = new DoSFilter();
|
||||
filter.init(null);
|
||||
for (int i = 0; i < DoSFilter.MAX_ACCESS_PER_TIME; i++) {
|
||||
|
|
|
@ -19,6 +19,8 @@ package com.google.zxing.web;
|
|||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Tests {@link LRUMap}.
|
||||
*/
|
||||
|
@ -26,7 +28,7 @@ public final class LRUMapTestCase extends Assert {
|
|||
|
||||
@Test
|
||||
public void testLRU() {
|
||||
LRUMap<String,String> map = new LRUMap<>(2);
|
||||
Map<String,String> map = new LRUMap<>(2);
|
||||
map.put("foo", "bar");
|
||||
map.put("bar", "baz");
|
||||
assertEquals("bar", map.get("foo"));
|
||||
|
|
|
@ -23,6 +23,7 @@ import org.springframework.mock.web.MockFilterChain;
|
|||
import org.springframework.mock.web.MockHttpServletRequest;
|
||||
import org.springframework.mock.web.MockHttpServletResponse;
|
||||
|
||||
import javax.servlet.FilterChain;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
|
@ -34,8 +35,8 @@ public final class WelcomeFilterTestCase extends Assert {
|
|||
public void testRedirect() {
|
||||
MockHttpServletRequest request = new MockHttpServletRequest();
|
||||
request.setRequestURI("/");
|
||||
MockHttpServletResponse response = new MockHttpServletResponse();
|
||||
MockFilterChain chain = new MockFilterChain();
|
||||
HttpServletResponse response = new MockHttpServletResponse();
|
||||
FilterChain chain = new MockFilterChain();
|
||||
new WelcomeFilter().doFilter(request, response, chain);
|
||||
assertEquals(HttpServletResponse.SC_MOVED_PERMANENTLY, response.getStatus());
|
||||
assertEquals("/w/decode.jspx", response.getHeader(HttpHeaders.LOCATION));
|
||||
|
|
Loading…
Reference in a new issue