소스 검색

IRCParser/test fixes.

Add @ChildImplementations to TestParser
- Should fix the billion unit test failures per night
Release semaphores even if we break due to lack of error checking
Make TestParser set some sensible-ish ping values

Change-Id: I0918114380f2c22de5d7c9574714ae9e1f098b12
Reviewed-on: http://gerrit.dmdirc.com/2196
Automatic-Compile: DMDirc Build Manager
Reviewed-by: Greg Holmes <greg@dmdirc.com>
tags/0.7rc1
Chris Smith 12 년 전
부모
커밋
1d570b9c5e
2개의 변경된 파일22개의 추가작업 그리고 8개의 파일을 삭제
  1. 12
    8
      src/com/dmdirc/parser/irc/IRCParser.java
  2. 10
    0
      test/com/dmdirc/harness/parser/TestParser.java

+ 12
- 8
src/com/dmdirc/parser/irc/IRCParser.java 파일 보기

@@ -1915,15 +1915,19 @@ public class IRCParser extends BaseParser implements SecureParser,
1915 1915
     protected void startPingTimer() {
1916 1916
         pingTimerSem.acquireUninterruptibly();
1917 1917
 
1918
-        setPingNeeded(false);
1919
-        if (pingTimer != null) {
1920
-            pingTimer.cancel();
1921
-        }
1922
-        pingTimer = new Timer("IRCParser pingTimer");
1923
-        pingTimer.schedule(new PingTimer(this, pingTimer), 0, getPingTimerInterval());
1924
-        pingCountDown = 1;
1918
+        try {
1919
+            setPingNeeded(false);
1925 1920
 
1926
-        pingTimerSem.release();
1921
+            if (pingTimer != null) {
1922
+                pingTimer.cancel();
1923
+            }
1924
+
1925
+            pingTimer = new Timer("IRCParser pingTimer");
1926
+            pingTimer.schedule(new PingTimer(this, pingTimer), 0, getPingTimerInterval());
1927
+            pingCountDown = 1;
1928
+        } finally {
1929
+            pingTimerSem.release();
1930
+        }
1927 1931
     }
1928 1932
 
1929 1933
     /**

+ 10
- 0
test/com/dmdirc/harness/parser/TestParser.java 파일 보기

@@ -22,6 +22,7 @@
22 22
 
23 23
 package com.dmdirc.harness.parser;
24 24
 
25
+import com.dmdirc.parser.common.ChildImplementations;
25 26
 import com.dmdirc.parser.common.MyInfo;
26 27
 import com.dmdirc.parser.common.QueuePriority;
27 28
 import com.dmdirc.parser.interfaces.Parser;
@@ -32,6 +33,11 @@ import java.util.ArrayList;
32 33
 import java.util.List;
33 34
 import java.util.Timer;
34 35
 
36
+@ChildImplementations({
37
+    IRCChannelClientInfo.class,
38
+    IRCChannelInfo.class,
39
+    IRCClientInfo.class
40
+})
35 41
 public class TestParser extends IRCParser implements Parser {
36 42
 
37 43
     public final List<String> sentLines = new ArrayList<String>();
@@ -43,11 +49,15 @@ public class TestParser extends IRCParser implements Parser {
43 49
     public TestParser() {
44 50
         super(buildURI());
45 51
         currentSocketState = SocketState.OPEN;
52
+        setPingTimerFraction(10);
53
+        setPingTimerInterval(60000);
46 54
     }
47 55
 
48 56
     public TestParser(MyInfo myDetails, URI address) {
49 57
         super(myDetails, address);
50 58
         currentSocketState = SocketState.OPEN;
59
+        setPingTimerFraction(10);
60
+        setPingTimerInterval(60000);
51 61
     }
52 62
 
53 63
     private static URI buildURI() {

Loading…
취소
저장