changeset 943:ad881e214d8d

bugfixes
author Devel 2
date Wed, 26 Sep 2018 14:11:08 +0200
parents 96f3c8ba4b4d
children 6dd4491e27b9
files stress-tester/src/main/java/com/passus/st/emitter/SessionInfo.java stress-tester/src/main/java/com/passus/st/reader/nc/NcDataBlockReader.java stress-tester/src/main/java/com/passus/st/reader/nc/NcDataHelper.java stress-tester/src/main/java/com/passus/st/type/ByteStringType.java stress-tester/src/main/java/com/passus/st/type/STTypes.java stress-tester/src/test/java/com/passus/st/emitter/SessionInfoTest.java
diffstat 6 files changed, 20 insertions(+), 23 deletions(-) [+]
line wrap: on
line diff
--- a/stress-tester/src/main/java/com/passus/st/emitter/SessionInfo.java	Wed Sep 19 08:26:50 2018 +0200
+++ b/stress-tester/src/main/java/com/passus/st/emitter/SessionInfo.java	Wed Sep 26 14:11:08 2018 +0200
@@ -3,18 +3,18 @@
 import com.passus.commons.utils.UniqueIdGenerator;
 import com.passus.net.IpAddress;
 import com.passus.net.SocketAddress;
-import com.passus.net.session.SessionBean;
+import com.passus.net.session.Session;
+import org.apache.commons.lang3.StringUtils;
+
 import java.text.ParseException;
 import java.util.Objects;
-import org.apache.commons.lang3.StringUtils;
 
 /**
- *
  * @author Mirosław Hawrot
  */
 public class SessionInfo {
 
-    private static final int DEFAULT_TRANSPORT = SessionBean.PROTOCOL_TCP;
+    private static final int DEFAULT_TRANSPORT = Session.PROTOCOL_TCP;
 
     private final String sessionId;
 
@@ -156,12 +156,12 @@
             parts[0] = parts[0].trim();
             parts[1] = parts[1].trim();
 
-            int transport = SessionBean.PROTOCOL_TCP;
+            int transport = Session.PROTOCOL_TCP;
             int pos = parts[0].lastIndexOf(" ");
             if (pos != -1) {
                 String transportStr = parts[0].substring(0, pos).trim();
                 if (transportStr.equalsIgnoreCase("udp")) {
-                    transport = SessionBean.PROTOCOL_UDP;
+                    transport = Session.PROTOCOL_UDP;
                 } else if (!transportStr.equalsIgnoreCase("tcp")) {
                     throw new Exception("Invalid transport '" + transportStr + "'");
                 }
--- a/stress-tester/src/main/java/com/passus/st/reader/nc/NcDataBlockReader.java	Wed Sep 19 08:26:50 2018 +0200
+++ b/stress-tester/src/main/java/com/passus/st/reader/nc/NcDataBlockReader.java	Wed Sep 26 14:11:08 2018 +0200
@@ -6,7 +6,7 @@
 import com.passus.data.DefaultByteBuffAllocator;
 import com.passus.data.HeapByteBuff;
 import com.passus.net.IpAddress;
-import com.passus.net.session.SessionBean;
+import com.passus.net.session.Session;
 import com.passus.st.emitter.SessionInfo;
 import com.passus.st.reader.DataBlockReader;
 import com.passus.st.reader.nc.option.DefaultValueCoder;
@@ -264,7 +264,7 @@
         int sessionId = ncDataHelper.readInt4(buffer);
         String sourceName = ncDataHelper.readStringNullTerminated(buffer);
         byte transport = buffer.read();
-        if (transport != SessionBean.PROTOCOL_TCP && transport != SessionBean.PROTOCOL_UDP) {
+        if (transport != Session.PROTOCOL_TCP && transport != Session.PROTOCOL_UDP) {
             throw new IOException("Not supported session transport '" + transport + "'.");
         }
 
--- a/stress-tester/src/main/java/com/passus/st/reader/nc/NcDataHelper.java	Wed Sep 19 08:26:50 2018 +0200
+++ b/stress-tester/src/main/java/com/passus/st/reader/nc/NcDataHelper.java	Wed Sep 26 14:11:08 2018 +0200
@@ -1,23 +1,20 @@
 package com.passus.st.reader.nc;
 
 import com.passus.commons.utils.AsciiUtils;
-import com.passus.data.ByteBuff;
-import com.passus.data.ByteBuffUtils;
-import com.passus.data.ByteString;
-import com.passus.data.ByteStringImpl;
+import com.passus.commons.utils.FormatUtils;
+import com.passus.data.*;
 import com.passus.data.DataHelper.BigEndianDataHelper;
-import com.passus.data.DataUtils;
 import com.passus.net.Ip4Address;
 import com.passus.net.Ip6Address;
 import com.passus.net.IpAddress;
-import java.nio.ByteBuffer;
-import java.nio.charset.Charset;
 import org.apache.commons.lang3.mutable.Mutable;
 import org.apache.commons.lang3.mutable.MutableInt;
 import org.apache.commons.lang3.mutable.MutableLong;
 
+import java.nio.ByteBuffer;
+import java.nio.charset.Charset;
+
 /**
- *
  * @author Mirosław Hawrot
  */
 public class NcDataHelper extends BigEndianDataHelper {
@@ -376,7 +373,7 @@
     }
 
     public int writeIpAddress(ByteBuffer buffer, IpAddress ip) {
-        byte[] data = ip.getAddress();
+        byte[] data = FormatUtils.intsToBytesBE(ip.getAddress());
         buffer.put((byte) ip.getVersion());
         buffer.put(data);
         return data.length + 1;
--- a/stress-tester/src/main/java/com/passus/st/type/ByteStringType.java	Wed Sep 19 08:26:50 2018 +0200
+++ b/stress-tester/src/main/java/com/passus/st/type/ByteStringType.java	Wed Sep 26 14:11:08 2018 +0200
@@ -3,10 +3,8 @@
 import com.passus.commons.ConversionException;
 import com.passus.data.ByteString;
 import com.passus.data.type.Type;
-import com.passus.net.http.URL;
 
 /**
- *
  * @author Mirosław Hawrot
  */
 public class ByteStringType extends Type<ByteString> {
--- a/stress-tester/src/main/java/com/passus/st/type/STTypes.java	Wed Sep 19 08:26:50 2018 +0200
+++ b/stress-tester/src/main/java/com/passus/st/type/STTypes.java	Wed Sep 26 14:11:08 2018 +0200
@@ -4,7 +4,6 @@
 import com.passus.filter.matcher.TypeMatcher;
 
 /**
- *
  * @author Mirosław Hawrot
  */
 public class STTypes {
@@ -12,6 +11,9 @@
     public static final URLType URL = new URLType();
     public static final ByteStringType BYTE_STRING = new ByteStringType();
 
+    private STTypes() {
+    }
+
     public static void registerAll() {
         Type.registerType(URL);
         Type.registerType(BYTE_STRING);
--- a/stress-tester/src/test/java/com/passus/st/emitter/SessionInfoTest.java	Wed Sep 19 08:26:50 2018 +0200
+++ b/stress-tester/src/test/java/com/passus/st/emitter/SessionInfoTest.java	Wed Sep 26 14:11:08 2018 +0200
@@ -1,7 +1,7 @@
 package com.passus.st.emitter;
 
 import com.passus.net.Ip4Address;
-import com.passus.net.session.SessionBean;
+import com.passus.net.session.Session;
 import static org.testng.Assert.*;
 
 import org.testng.annotations.Test;
@@ -20,7 +20,7 @@
         assertEquals(100, info.getSrcPort());
         assertEquals(new Ip4Address("2.2.2.2"), info.getDstIp());
         assertEquals(200, info.getDstPort());
-        assertEquals(SessionBean.PROTOCOL_TCP, info.getTransport());
+        assertEquals(Session.PROTOCOL_TCP, info.getTransport());
         
         info = SessionInfo.parse("udp  1.1.1.1:100 <-> 2.2.2.2:200");
 
@@ -28,7 +28,7 @@
         assertEquals(100, info.getSrcPort());
         assertEquals(new Ip4Address("2.2.2.2"), info.getDstIp());
         assertEquals(200, info.getDstPort());
-        assertEquals(SessionBean.PROTOCOL_UDP, info.getTransport());
+        assertEquals(Session.PROTOCOL_UDP, info.getTransport());
     }
 
 }