Skip to content

Commit f595f41

Browse files
committed
Added all-snapshot test case
1 parent 96ac44e commit f595f41

File tree

2 files changed

+154
-4
lines changed

2 files changed

+154
-4
lines changed

src/test/java/org/lib/test/LibraryTest.java

+57-4
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
package org.lib.test;
22

3-
import static org.junit.Assert.assertEquals;
4-
import static org.junit.Assert.assertNotNull;
5-
63
import java.awt.Graphics;
74
import java.awt.Image;
85
import java.awt.image.BufferStrategy;
96
import java.awt.image.BufferedImage;
7+
import java.io.File;
8+
import java.io.FileInputStream;
109
import java.io.IOException;
10+
import java.io.InputStream;
11+
import java.util.Properties;
1112

1213
import javax.swing.ImageIcon;
1314
import javax.swing.JFrame;
@@ -21,6 +22,8 @@
2122
import org.junit.Test;
2223
import org.xml.sax.SAXException;
2324

25+
import static org.junit.Assert.*;
26+
2427
/**
2528
*
2629
*/
@@ -32,7 +35,7 @@ public class LibraryTest {
3235
* a problem: for now - using snapshots/test_041.jpg
3336
*/
3437
@Test
35-
public void intelligenceTest() throws IOException, ParserConfigurationException, SAXException {
38+
public void intelligenceSingleTest() throws IOException, ParserConfigurationException, SAXException {
3639
final String image = "snapshots/test_041.jpg";
3740

3841
/*
@@ -65,7 +68,57 @@ public void intelligenceTest() throws IOException, ParserConfigurationException,
6568
assertEquals("LM025BD", spz);
6669

6770
// System.out.println(intel.lastProcessDuration());
71+
carSnap.close();
72+
}
73+
74+
@Test
75+
public void testAllSnapshots() throws Exception {
76+
String snapshotDirPath = "src/test/resources/snapshots";
77+
String resultsPath = "src/test/resources/results.properties";
78+
InputStream resultsStream = new FileInputStream(new File(resultsPath));
79+
80+
Properties properties = new Properties();
81+
properties.load(resultsStream);
82+
resultsStream.close();
83+
assertTrue(properties.size() > 0);
84+
85+
File snapshotDir = new File(snapshotDirPath);
86+
File[] snapshots = snapshotDir.listFiles();
87+
assertTrue(snapshots.length > 0);
88+
89+
Intelligence intel = new Intelligence();
90+
assertNotNull(intel);
6891

92+
//TODO not working images
93+
String[] ignores = {"test_048.jpg", "test_025.jpg", "test_075.jpg"};
94+
95+
for(File snap : snapshots) {
96+
CarSnapshot carSnap = new CarSnapshot(new FileInputStream(snap));
97+
assertNotNull("carSnap is null", carSnap);
98+
assertNotNull("carSnap.image is null", carSnap.image);
99+
100+
String numberPlate = intel.recognize(carSnap);
101+
assertNotNull("The licence plate is null - are you sure the image has the correct color space?", numberPlate);
102+
103+
String snapName = snap.getName();
104+
String plateCorrect = properties.getProperty(snapName);
105+
assertNotNull(plateCorrect);
106+
107+
boolean ignoreFlag = false;
108+
System.out.println(snapName);
109+
for(String ignore : ignores) {
110+
if (ignore.equals(snapName)) {
111+
ignoreFlag = true;
112+
break;
113+
}
114+
}
115+
if(ignoreFlag) {
116+
continue;
117+
}
118+
119+
assertEquals("The file \"" + snapName + "\" was incorrectly recognized.", plateCorrect, numberPlate);
120+
carSnap.close();
121+
}
69122
}
70123

71124
public class TestImageDraw {

src/test/resources/results.properties

+97
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
test_001.jpg=PP587AO
2+
test_002.jpg=RK755AJ
3+
test_003.jpg=SI819AK
4+
test_004.jpg=RK115AN
5+
test_005.jpg=TS260AK
6+
test_006.jpg=RK099AN
7+
test_007.jpg=RK828AG
8+
test_008.jpg=LM298AI
9+
test_009.jpg=1T43213
10+
test_010.jpg=RK248AH
11+
test_011.jpg=RK346AL
12+
test_012.jpg=RK291AT
13+
test_013.jpg=RK857AI
14+
test_014.jpg=RK576AH
15+
test_015.jpg=RK019AF
16+
test_016.jpg=BB751BH
17+
test_017.jpg=RK876AD
18+
test_018.jpg=RK884AL
19+
test_019.jpg=RK865AC
20+
test_020.jpg=RK906AJ
21+
test_021.jpg=RK855AP
22+
test_022.jpg=RK875AE
23+
test_023.jpg=RK612AL
24+
test_024.jpg=RK026AJ
25+
test_025.jpg=RK896AO
26+
test_026.jpg=RK492AU
27+
test_027.jpg=RK776AI
28+
test_028.jpg=LM633BD
29+
test_029.jpg=LM010BE
30+
test_030.jpg=RK819AM
31+
test_031.jpg=RK619AS
32+
test_032.jpg=RK763AS
33+
test_033.jpg=RK082AL
34+
test_034.jpg=SG47471
35+
test_035.jpg=BA738DE
36+
test_036.jpg=RK708AI
37+
test_037.jpg=RK260AR
38+
test_038.jpg=RK340A0
39+
test_039.jpg=RK892AE
40+
test_040.jpg=RK101AO
41+
test_041.jpg=LM025BD
42+
test_042.jpg=BA28IM
43+
test_043.jpg=DK41AH
44+
test_044.jpg=RK878AC
45+
test_045.jpg=RK878AC
46+
test_046.jpg=RK143AT
47+
test_047.jpg=RK161AG
48+
test_048.jpg=RK161AG
49+
test_049.jpg=KMBORAK
50+
test_050.jpg=BB135BO
51+
test_051.jpg=RK605AB
52+
test_052.jpg=BY649AG
53+
test_053.jpg=RK715AA
54+
test_054.jpg=RK22AH
55+
test_055.jpg=NO450AM
56+
test_056.jpg=RK300AG
57+
test_057.jpg=RK300AS
58+
test_058.jpg=RK485AF
59+
test_059.jpg=BA302OZ
60+
test_060.jpg=BA302OZ
61+
test_061.jpg=MT456BJ
62+
test_062.jpg=1B80338
63+
test_063.jpg=1B25790
64+
test_064.jpg=BZM2227
65+
test_065.jpg=4B04979
66+
test_066.jpg=BSE5579
67+
test_067.jpg=1B70440
68+
test_068.jpg=1B19839
69+
test_069.jpg=4B40262
70+
test_070.jpg=2T40211
71+
test_071.jpg=1Z75233
72+
test_072.jpg=4B39376
73+
test_073.jpg=3B97236
74+
test_074.jpg=3B29485
75+
test_075.jpg=ZA834CO
76+
test_076.jpg=4B21875
77+
test_077.jpg=RK735AS
78+
test_078.jpg=RK457AS
79+
test_079.jpg=RK959AF
80+
test_080.jpg=RK003AB
81+
test_081.jpg=RK641AL
82+
test_082.jpg=RK891AU
83+
test_083.jpg=PD935BG
84+
test_084.jpg=PD722BF
85+
test_085.jpg=RK959AD
86+
test_086.jpg=RK376AF
87+
test_087.jpg=RK011AM
88+
test_088.jpg=LM169AM
89+
test_089.jpg=RK565AV
90+
test_090.jpg=RK550AO
91+
test_091.jpg=RK977AF
92+
test_092.jpg=RK373AK
93+
test_093.jpg=RK301AH
94+
test_094.jpg=RK069AV
95+
test_095.jpg=NO626AT
96+
test_096.jpg=RK735AS
97+
test_097.jpg=RK603AV

0 commit comments

Comments
 (0)