Bladeren bron

Merge branch 'master' of https://github.com/DMDirc/Parser

pull/164/head
Greg Holmes 7 jaren geleden
bovenliggende
commit
b951ed460a

+ 4
- 2
irc/src/main/java/com/dmdirc/parser/irc/IRCParser.java Bestand weergeven

@@ -59,8 +59,9 @@ import java.net.UnknownHostException;
59 59
 import java.security.KeyManagementException;
60 60
 import java.security.NoSuchAlgorithmException;
61 61
 import java.security.SecureRandom;
62
+import java.time.Instant;
62 63
 import java.time.LocalDateTime;
63
-import java.time.ZoneOffset;
64
+import java.time.ZoneId;
64 65
 import java.time.format.DateTimeFormatter;
65 66
 import java.time.format.DateTimeParseException;
66 67
 import java.util.ArrayList;
@@ -1114,7 +1115,8 @@ public class IRCParser extends BaseSocketAwareParser implements SecureParser, En
1114 1115
         if (line.getTags().containsKey("tsirc date")) {
1115 1116
             try {
1116 1117
                 final long ts = Long.parseLong(line.getTags().get("tsirc date")) - tsdiff;
1117
-                lineTS = LocalDateTime.ofEpochSecond(ts / 1000L, (int) (ts % 1000L), ZoneOffset.UTC);
1118
+                lineTS = LocalDateTime.ofInstant(Instant.ofEpochSecond(ts / 1000L, (int) (ts % 1000L)),
1119
+                        ZoneId.systemDefault());
1118 1120
             } catch (final NumberFormatException nfe) { /* Do nothing. */ }
1119 1121
         } else if (line.getTags().containsKey("time")) {
1120 1122
             try {

+ 76
- 0
irc/src/test/java/com/dmdirc/parser/irc/outputqueue/PriorityOutputQueueTest.java Bestand weergeven

@@ -0,0 +1,76 @@
1
+/*
2
+ * Copyright (c) 2006-2016 DMDirc Developers
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.parser.irc.outputqueue;
24
+
25
+import com.dmdirc.parser.common.QueuePriority;
26
+import org.junit.Before;
27
+import org.junit.Test;
28
+
29
+import java.io.BufferedOutputStream;
30
+import java.io.BufferedReader;
31
+import java.io.IOException;
32
+import java.io.InputStreamReader;
33
+import java.io.PipedInputStream;
34
+import java.io.PipedOutputStream;
35
+
36
+import static org.junit.Assert.assertEquals;
37
+
38
+public class PriorityOutputQueueTest {
39
+
40
+    private BufferedReader reader;
41
+    private BufferedOutputStream outputStream;
42
+    private PriorityOutputQueue outputQueue;
43
+
44
+    @Before
45
+    public void setup() throws IOException {
46
+        PipedInputStream pipeInput = new PipedInputStream();
47
+        reader = new BufferedReader(new InputStreamReader(pipeInput));
48
+        outputStream = new BufferedOutputStream(new PipedOutputStream(pipeInput));
49
+        outputQueue = new PriorityOutputQueue();
50
+    }
51
+
52
+    @Test(expected = IllegalStateException.class)
53
+    public void testThrowsIfOutputStreamNotSet() {
54
+        outputQueue.sendLine("testing", QueuePriority.IMMEDIATE);
55
+    }
56
+
57
+    @Test
58
+    public void testSendsLinesToOutput() throws IOException {
59
+        outputQueue.setOutputStream(outputStream);
60
+        outputQueue.sendLine("test 123");
61
+        outputQueue.sendLine("456...");
62
+        assertEquals("test 123", reader.readLine());
63
+        assertEquals("456...", reader.readLine());
64
+    }
65
+
66
+    @Test
67
+    public void testDiscarding() throws IOException {
68
+        outputQueue.setOutputStream(outputStream);
69
+        outputQueue.setDiscarding(true);
70
+        outputQueue.sendLine("test 123");
71
+        outputQueue.setDiscarding(false);
72
+        outputQueue.sendLine("456...");
73
+        assertEquals("456...", reader.readLine());
74
+    }
75
+
76
+}

+ 0
- 3
irc/src/test/java/com/dmdirc/parser/irc/processors/Process001Test.java Bestand weergeven

@@ -26,9 +26,7 @@ import com.dmdirc.parser.common.ParserError;
26 26
 import com.dmdirc.parser.irc.IRCClientInfo;
27 27
 import com.dmdirc.parser.irc.IRCParser;
28 28
 import com.dmdirc.parser.irc.ProcessingManager;
29
-
30 29
 import org.junit.Before;
31
-import org.junit.Ignore;
32 30
 import org.junit.Test;
33 31
 import org.junit.runner.RunWith;
34 32
 import org.mockito.ArgumentCaptor;
@@ -49,7 +47,6 @@ import static org.mockito.Mockito.verify;
49 47
 import static org.mockito.Mockito.when;
50 48
 
51 49
 @RunWith(MockitoJUnitRunner.class)
52
-@Ignore
53 50
 public class Process001Test {
54 51
 
55 52
     @Mock private IRCParser parser;

Laden…
Annuleren
Opslaan