<commit_before>package org.jsmpp.util;

import static org.testng.Assert.*;

import org.jsmpp.PDUStringException;
import org.jsmpp.SMPPConstant;
import org.jsmpp.bean.BindResp;
import org.jsmpp.bean.BindType;
import org.testng.annotations.Test;

/**
 * Test composing PDU, decompose and read.
 * @author uudashr
 *
 */
public class ComposerDecomposerReaderTest {
    private static final boolean DEBUG = false;
    
    @Test(groups="checkintest")
    public void lowLevel() {
        PDUComposer composer = new DefaultComposer();
        PDUDecomposer decomposer = new DefaultDecomposer();
        
        byte[] b = null;
        String systemId = "smsc";
        /*
        try {
            b = composer.bindResp(BindType.BIND_TRX.responseCommandId(), 1, systemId);
            assertEquals(b.length, 16 + systemId.length() + 1);
            printLog("Length of bytes : " + b.length);
        } catch (PDUStringException e) {
            fail("Failed composing bind response", e);
        }
        */
        
        PDUByteBuffer buf = new PDUByteBuffer(BindType.BIND_TRX.responseCommandId(), 0, 1);
        buf.append(systemId);
        b = buf.toBytes();
        assertEquals(b.length, 16 + systemId.length() + 1);
        printLog("Length of bytes : " + b.length);
        
        
        SequentialBytesReader reader = new SequentialBytesReader(b);
        assertEquals(b.length, reader.remainBytesLength());
        
        int commandLength =  reader.readInt();
        assertEquals(commandLength, b.length);
        assertEquals(4, reader.cursor);
        assertEquals(b.length - 4, reader.remainBytesLength());
        
        int commandId =  reader.readInt();
        assertEquals(commandId, BindType.BIND_TRX.responseCommandId());
        assertEquals(8, reader.cursor);
        assertEquals(b.length - 8, reader.remainBytesLength());
        
        int commandStatus = reader.readInt();
        assertEquals(commandStatus, SMPPConstant.STAT_ESME_ROK);
        assertEquals(12, reader.cursor);
        assertEquals(b.length - 12, reader.remainBytesLength());
        
        int sequenceNumber = reader.readInt();
        assertEquals(sequenceNumber, 1);
        assertEquals(16, reader.cursor);
        assertEquals(b.length - 16, reader.remainBytesLength());
        
        String readedSystemId = reader.readCString();
        assertEquals(readedSystemId, systemId);
        
        /*
        try {
            BindResp resp = decomposer.bindResp(b);
        } catch (PDUStringException e) {
            fail("Failed decomposing bind response", e);
        }
        */
    }
    
    @Test(groups="checkintest")
    public void highLevel() {<commit_msg>Clean up the code<commit_after>package org.jsmpp.util;

import static org.testng.Assert.*;

import org.jsmpp.PDUStringException;
import org.jsmpp.SMPPConstant;
import org.jsmpp.bean.BindResp;
import org.jsmpp.bean.BindType;
import org.testng.annotations.Test;

/**
 * Test composing PDU, decompose and read.
 * @author uudashr
 *
 */
public class ComposerDecomposerReaderTest {
    private static final boolean DEBUG = false;
    
    @Test(groups="checkintest")
    public void lowLevel() {
        byte[] b = null;
        String systemId = "smsc";
        
        PDUByteBuffer buf = new PDUByteBuffer(BindType.BIND_TRX.responseCommandId(), 0, 1);
        buf.append(systemId);
        b = buf.toBytes();
        assertEquals(b.length, 16 + systemId.length() + 1);
        printLog("Length of bytes : " + b.length);
        
        
        SequentialBytesReader reader = new SequentialBytesReader(b);
        assertEquals(b.length, reader.remainBytesLength());
        
        int commandLength =  reader.readInt();
        assertEquals(commandLength, b.length);
        assertEquals(4, reader.cursor);
        assertEquals(b.length - 4, reader.remainBytesLength());
        
        int commandId =  reader.readInt();
        assertEquals(commandId, BindType.BIND_TRX.responseCommandId());
        assertEquals(8, reader.cursor);
        assertEquals(b.length - 8, reader.remainBytesLength());
        
        int commandStatus = reader.readInt();
        assertEquals(commandStatus, SMPPConstant.STAT_ESME_ROK);
        assertEquals(12, reader.cursor);
        assertEquals(b.length - 12, reader.remainBytesLength());
        
        int sequenceNumber = reader.readInt();
        assertEquals(sequenceNumber, 1);
        assertEquals(16, reader.cursor);
        assertEquals(b.length - 16, reader.remainBytesLength());
        
        String readedSystemId = reader.readCString();
        assertEquals(readedSystemId, systemId);
    }
    
    @Test(groups="checkintest")
    public void highLevel() {
{'fraction_non_alphanumeric': 0.11191489361702128, 'fraction_numerical': 0.00851063829787234, 'mean_word_length': 2.5640636846095526, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2495946', 'n_tokens_mistral': 1373, 'n_tokens_neox': 1331, 'n_words': 272}