SimpleName:IDENTIFIER 235 testSetInteger testSetInteger

SimpleName:IDENTIFIER 237 BitUtils BitUtils

SimpleName:IDENTIFIER 238 setNextInteger setNextInteger

SimpleName:IDENTIFIER 239 setNextInteger setNextInteger

SimpleName:IDENTIFIER 240 setNextInteger setNextInteger

SimpleName:IDENTIFIER 241 setNextInteger setNextInteger

SimpleName:IDENTIFIER 242 setNextInteger setNextInteger

SimpleName:IDENTIFIER 243 setNextInteger setNextInteger

SimpleName:IDENTIFIER 244 setNextInteger setNextInteger

SimpleName:IDENTIFIER 247 Assertions Assertions

SimpleName:IDENTIFIER 247 assertThat assertThat

SimpleName:IDENTIFIER 247 getNextInteger getNextInteger

SimpleName:IDENTIFIER 247 isEqualTo isEqualTo

SimpleName:IDENTIFIER 248 Assertions Assertions

SimpleName:IDENTIFIER 248 assertThat assertThat

SimpleName:IDENTIFIER 248 getNextInteger getNextInteger

SimpleName:IDENTIFIER 248 isEqualTo isEqualTo

SimpleName:IDENTIFIER 249 Assertions Assertions

SimpleName:IDENTIFIER 249 assertThat assertThat

SimpleName:IDENTIFIER 249 getNextInteger getNextInteger

SimpleName:IDENTIFIER 249 isEqualTo isEqualTo

SimpleName:IDENTIFIER 250 Assertions Assertions

SimpleName:IDENTIFIER 250 assertThat assertThat

SimpleName:IDENTIFIER 250 getNextInteger getNextInteger

SimpleName:IDENTIFIER 250 isEqualTo isEqualTo

SimpleName:IDENTIFIER 251 Assertions Assertions

SimpleName:IDENTIFIER 251 assertThat assertThat

SimpleName:IDENTIFIER 251 getNextInteger getNextInteger

SimpleName:IDENTIFIER 251 isEqualTo isEqualTo

SimpleName:IDENTIFIER 252 Assertions Assertions

SimpleName:IDENTIFIER 252 assertThat assertThat

SimpleName:IDENTIFIER 252 getNextInteger getNextInteger

SimpleName:IDENTIFIER 252 isEqualTo isEqualTo

SimpleName:IDENTIFIER 253 Assertions Assertions

SimpleName:IDENTIFIER 253 assertThat assertThat

SimpleName:IDENTIFIER 253 getNextInteger getNextInteger

SimpleName:IDENTIFIER 253 isEqualTo isEqualTo

SimpleName:IDENTIFIER 255 BitUtils BitUtils

SimpleName:IDENTIFIER 256 setNextInteger setNextInteger

SimpleName:IDENTIFIER 257 setNextInteger setNextInteger

SimpleName:IDENTIFIER 258 setNextInteger setNextInteger

SimpleName:IDENTIFIER 259 setNextInteger setNextInteger

SimpleName:IDENTIFIER 260 setNextInteger setNextInteger

SimpleName:IDENTIFIER 261 setNextInteger setNextInteger

SimpleName:IDENTIFIER 265 Assertions Assertions

SimpleName:IDENTIFIER 265 assertThat assertThat

SimpleName:IDENTIFIER 265 getNextInteger getNextInteger

SimpleName:IDENTIFIER 265 isEqualTo isEqualTo

SimpleName:IDENTIFIER 266 Assertions Assertions

SimpleName:IDENTIFIER 266 assertThat assertThat

SimpleName:IDENTIFIER 266 getNextInteger getNextInteger

SimpleName:IDENTIFIER 266 isEqualTo isEqualTo

SimpleName:IDENTIFIER 267 Assertions Assertions

SimpleName:IDENTIFIER 267 assertThat assertThat

SimpleName:IDENTIFIER 267 getNextInteger getNextInteger

SimpleName:IDENTIFIER 267 isEqualTo isEqualTo

SimpleName:IDENTIFIER 268 Assertions Assertions

SimpleName:IDENTIFIER 268 assertThat assertThat

SimpleName:IDENTIFIER 268 getNextInteger getNextInteger

SimpleName:IDENTIFIER 268 isEqualTo isEqualTo

SimpleName:IDENTIFIER 269 Assertions Assertions

SimpleName:IDENTIFIER 269 assertThat assertThat

SimpleName:IDENTIFIER 269 getNextInteger getNextInteger

SimpleName:IDENTIFIER 269 isEqualTo isEqualTo

SimpleName:IDENTIFIER 270 Assertions Assertions

SimpleName:IDENTIFIER 270 assertThat assertThat

SimpleName:IDENTIFIER 270 getNextInteger getNextInteger

SimpleName:IDENTIFIER 270 isEqualTo isEqualTo

SimpleName:IDENTIFIER 272 BitUtils BitUtils

SimpleName:IDENTIFIER 273 setNextInteger setNextInteger

SimpleName:IDENTIFIER 274 setNextInteger setNextInteger

SimpleName:IDENTIFIER 275 setNextInteger setNextInteger

SimpleName:IDENTIFIER 276 setNextInteger setNextInteger

SimpleName:IDENTIFIER 277 setNextInteger setNextInteger

SimpleName:IDENTIFIER 278 setNextInteger setNextInteger

SimpleName:IDENTIFIER 279 setNextInteger setNextInteger

SimpleName:IDENTIFIER 280 setNextInteger setNextInteger

SimpleName:IDENTIFIER 281 setNextInteger setNextInteger

SimpleName:IDENTIFIER 284 Assertions Assertions

SimpleName:IDENTIFIER 284 assertThat assertThat

SimpleName:IDENTIFIER 284 getNextInteger getNextInteger

SimpleName:IDENTIFIER 284 isEqualTo isEqualTo

SimpleName:IDENTIFIER 285 Assertions Assertions

SimpleName:IDENTIFIER 285 assertThat assertThat

SimpleName:IDENTIFIER 285 getNextInteger getNextInteger

SimpleName:IDENTIFIER 285 isEqualTo isEqualTo

SimpleName:IDENTIFIER 286 Assertions Assertions

SimpleName:IDENTIFIER 286 assertThat assertThat

SimpleName:IDENTIFIER 286 getNextInteger getNextInteger

SimpleName:IDENTIFIER 286 isEqualTo isEqualTo

SimpleName:IDENTIFIER 287 Assertions Assertions

SimpleName:IDENTIFIER 287 assertThat assertThat

SimpleName:IDENTIFIER 287 getNextInteger getNextInteger

SimpleName:IDENTIFIER 287 isEqualTo isEqualTo

SimpleName:IDENTIFIER 288 Assertions Assertions

SimpleName:IDENTIFIER 288 assertThat assertThat

SimpleName:IDENTIFIER 288 getNextInteger getNextInteger

SimpleName:IDENTIFIER 288 isEqualTo isEqualTo

SimpleName:IDENTIFIER 289 Assertions Assertions

SimpleName:IDENTIFIER 289 assertThat assertThat

SimpleName:IDENTIFIER 289 getNextInteger getNextInteger

SimpleName:IDENTIFIER 289 isEqualTo isEqualTo

SimpleName:IDENTIFIER 290 Assertions Assertions

SimpleName:IDENTIFIER 290 assertThat assertThat

SimpleName:IDENTIFIER 290 getNextInteger getNextInteger

SimpleName:IDENTIFIER 290 isEqualTo isEqualTo

SimpleName:IDENTIFIER 291 Assertions Assertions

SimpleName:IDENTIFIER 291 assertThat assertThat

SimpleName:IDENTIFIER 291 getNextInteger getNextInteger

SimpleName:IDENTIFIER 291 isEqualTo isEqualTo

SimpleName:IDENTIFIER 292 Assertions Assertions

SimpleName:IDENTIFIER 292 assertThat assertThat

SimpleName:IDENTIFIER 292 getNextInteger getNextInteger

SimpleName:IDENTIFIER 292 isEqualTo isEqualTo

SimpleName:IDENTIFIER 296 setNextInteger setNextInteger

@Test
public void testSetInteger() {
    BitUtils bit3 = new BitUtils(128);
    bit3.setNextInteger(10, 6);
    bit3.setNextInteger(23, 12);
    bit3.setNextInteger(5, 8);
    bit3.setNextInteger(930, 16);
    bit3.setNextInteger(5, 3);
    bit3.setNextInteger(159, 8);
    bit3.setNextInteger(7, 3);
    bit3.reset();
    Assertions.assertThat(bit3.getNextInteger(6)).isEqualTo(10);
    Assertions.assertThat(bit3.getNextInteger(12)).isEqualTo(23);
    Assertions.assertThat(bit3.getNextInteger(8)).isEqualTo(5);
    Assertions.assertThat(bit3.getNextInteger(16)).isEqualTo(930);
    Assertions.assertThat(bit3.getNextInteger(3)).isEqualTo(5);
    Assertions.assertThat(bit3.getNextInteger(8)).isEqualTo(159);
    Assertions.assertThat(bit3.getNextInteger(3)).isEqualTo(7);
    BitUtils bit2 = new BitUtils(128);
    bit2.setNextInteger(3, 2);
    bit2.setNextInteger(1057, 14);
    bit2.setNextInteger(1, 1);
    bit2.setNextInteger(1532, 15);
    bit2.setNextInteger(8, 8);
    bit2.setNextInteger(1532, 15);
    bit2.reset();
    Assertions.assertThat(bit2.getNextInteger(2)).isEqualTo(3);
    Assertions.assertThat(bit2.getNextInteger(14)).isEqualTo(1057);
    Assertions.assertThat(bit2.getNextInteger(1)).isEqualTo(1);
    Assertions.assertThat(bit2.getNextInteger(15)).isEqualTo(1532);
    Assertions.assertThat(bit2.getNextInteger(8)).isEqualTo(8);
    Assertions.assertThat(bit2.getNextInteger(15)).isEqualTo(1532);
    BitUtils bit = new BitUtils(64);
    bit.setNextInteger(3, 2);
    bit.setNextInteger(255, 8);
    bit.setNextInteger(0, 2);
    bit.setNextInteger(15, 4);
    bit.setNextInteger(2, 2);
    bit.setNextInteger(3, 3);
    bit.setNextInteger(1, 1);
    bit.setNextInteger(0, 1);
    bit.setNextInteger(1, 1);
    bit.reset();
    Assertions.assertThat(bit.getNextInteger(2)).isEqualTo(3);
    Assertions.assertThat(bit.getNextInteger(8)).isEqualTo(255);
    Assertions.assertThat(bit.getNextInteger(2)).isEqualTo(0);
    Assertions.assertThat(bit.getNextInteger(4)).isEqualTo(15);
    Assertions.assertThat(bit.getNextInteger(2)).isEqualTo(2);
    Assertions.assertThat(bit.getNextInteger(3)).isEqualTo(3);
    Assertions.assertThat(bit.getNextInteger(1)).isEqualTo(1);
    Assertions.assertThat(bit.getNextInteger(1)).isEqualTo(0);
    Assertions.assertThat(bit.getNextInteger(1)).isEqualTo(1);
    bit.clear();
    bit.setNextInteger(500, 33);
}

@Test(expected = IllegalArgumentException.class)
public void testSetInteger() {
    BitUtils bit3 = new BitUtils(128);
    bit3.setNextInteger(10, 6);
    bit3.setNextInteger(23, 12);
    bit3.setNextInteger(5, 8);
    bit3.setNextInteger(930, 16);
    bit3.setNextInteger(5, 3);
    bit3.setNextInteger(159, 8);
    bit3.setNextInteger(7, 3);
    bit3.reset();
    Assertions.assertThat(bit3.getNextInteger(6)).isEqualTo(10);
    Assertions.assertThat(bit3.getNextInteger(12)).isEqualTo(23);
    Assertions.assertThat(bit3.getNextInteger(8)).isEqualTo(5);
    Assertions.assertThat(bit3.getNextInteger(16)).isEqualTo(930);
    Assertions.assertThat(bit3.getNextInteger(3)).isEqualTo(5);
    Assertions.assertThat(bit3.getNextInteger(8)).isEqualTo(159);
    Assertions.assertThat(bit3.getNextInteger(3)).isEqualTo(7);
    BitUtils bit2 = new BitUtils(128);
    bit2.setNextInteger(3, 2);
    bit2.setNextInteger(1057, 14);
    bit2.setNextInteger(1, 1);
    bit2.setNextInteger(1532, 15);
    bit2.setNextInteger(8, 8);
    bit2.setNextInteger(1532, 15);
    bit2.reset();
    Assertions.assertThat(bit2.getNextInteger(2)).isEqualTo(3);
    Assertions.assertThat(bit2.getNextInteger(14)).isEqualTo(1057);
    Assertions.assertThat(bit2.getNextInteger(1)).isEqualTo(1);
    Assertions.assertThat(bit2.getNextInteger(15)).isEqualTo(1532);
    Assertions.assertThat(bit2.getNextInteger(8)).isEqualTo(8);
    Assertions.assertThat(bit2.getNextInteger(15)).isEqualTo(1532);
    BitUtils bit = new BitUtils(64);
    bit.setNextInteger(3, 2);
    bit.setNextInteger(255, 8);
    bit.setNextInteger(0, 2);
    bit.setNextInteger(15, 4);
    bit.setNextInteger(2, 2);
    bit.setNextInteger(3, 3);
    bit.setNextInteger(1, 1);
    bit.setNextInteger(0, 1);
    bit.setNextInteger(1, 1);
    bit.reset();
    Assertions.assertThat(bit.getNextInteger(2)).isEqualTo(3);
    Assertions.assertThat(bit.getNextInteger(8)).isEqualTo(255);
    Assertions.assertThat(bit.getNextInteger(2)).isEqualTo(0);
    Assertions.assertThat(bit.getNextInteger(4)).isEqualTo(15);
    Assertions.assertThat(bit.getNextInteger(2)).isEqualTo(2);
    Assertions.assertThat(bit.getNextInteger(3)).isEqualTo(3);
    Assertions.assertThat(bit.getNextInteger(1)).isEqualTo(1);
    Assertions.assertThat(bit.getNextInteger(1)).isEqualTo(0);
    Assertions.assertThat(bit.getNextInteger(1)).isEqualTo(1);
    bit.clear();
    bit.setNextInteger(500, 33);
}

package fr.devnied.bitlib;

import org.fest.assertions.Assertions;
import org.junit.Assert;
import org.junit.Test;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public final class adhoc_BitUtilsTest {

    private final byte[] test = new byte[] { (byte) 0x11, (byte) 0x00, (byte) 0x00, (byte) 0x67, (byte) 0xEF };
    /*TEST PLACEHOLDER*/
}

Test the method to set an integer


SimpleName:IDENTIFIER 340 testSetLong testSetLong

SimpleName:IDENTIFIER 342 BitUtils BitUtils

SimpleName:IDENTIFIER 343 setNextLong setNextLong

SimpleName:IDENTIFIER 344 setNextLong setNextLong

SimpleName:IDENTIFIER 345 setNextLong setNextLong

SimpleName:IDENTIFIER 346 setNextLong setNextLong

SimpleName:IDENTIFIER 347 setNextLong setNextLong

SimpleName:IDENTIFIER 348 setNextLong setNextLong

SimpleName:IDENTIFIER 349 setNextLong setNextLong

SimpleName:IDENTIFIER 352 Assertions Assertions

SimpleName:IDENTIFIER 352 assertThat assertThat

SimpleName:IDENTIFIER 352 getNextLong getNextLong

SimpleName:IDENTIFIER 352 isEqualTo isEqualTo

SimpleName:IDENTIFIER 353 Assertions Assertions

SimpleName:IDENTIFIER 353 assertThat assertThat

SimpleName:IDENTIFIER 353 getNextLong getNextLong

SimpleName:IDENTIFIER 353 isEqualTo isEqualTo

SimpleName:IDENTIFIER 354 Assertions Assertions

SimpleName:IDENTIFIER 354 assertThat assertThat

SimpleName:IDENTIFIER 354 getNextLong getNextLong

SimpleName:IDENTIFIER 354 isEqualTo isEqualTo

SimpleName:IDENTIFIER 355 Assertions Assertions

SimpleName:IDENTIFIER 355 assertThat assertThat

SimpleName:IDENTIFIER 355 getNextLong getNextLong

SimpleName:IDENTIFIER 355 isEqualTo isEqualTo

SimpleName:IDENTIFIER 356 Assertions Assertions

SimpleName:IDENTIFIER 356 assertThat assertThat

SimpleName:IDENTIFIER 356 getNextLong getNextLong

SimpleName:IDENTIFIER 356 isEqualTo isEqualTo

SimpleName:IDENTIFIER 357 Assertions Assertions

SimpleName:IDENTIFIER 357 assertThat assertThat

SimpleName:IDENTIFIER 357 getNextLong getNextLong

SimpleName:IDENTIFIER 357 isEqualTo isEqualTo

SimpleName:IDENTIFIER 358 Assertions Assertions

SimpleName:IDENTIFIER 358 assertThat assertThat

SimpleName:IDENTIFIER 358 getNextLong getNextLong

SimpleName:IDENTIFIER 358 isEqualTo isEqualTo

SimpleName:IDENTIFIER 360 BitUtils BitUtils

SimpleName:IDENTIFIER 361 setNextLong setNextLong

SimpleName:IDENTIFIER 362 setNextLong setNextLong

SimpleName:IDENTIFIER 363 setNextLong setNextLong

SimpleName:IDENTIFIER 364 setNextLong setNextLong

SimpleName:IDENTIFIER 365 setNextLong setNextLong

SimpleName:IDENTIFIER 366 setNextLong setNextLong

SimpleName:IDENTIFIER 370 Assertions Assertions

SimpleName:IDENTIFIER 370 assertThat assertThat

SimpleName:IDENTIFIER 370 getNextLong getNextLong

SimpleName:IDENTIFIER 370 isEqualTo isEqualTo

SimpleName:IDENTIFIER 371 Assertions Assertions

SimpleName:IDENTIFIER 371 assertThat assertThat

SimpleName:IDENTIFIER 371 getNextLong getNextLong

SimpleName:IDENTIFIER 371 isEqualTo isEqualTo

SimpleName:IDENTIFIER 372 Assertions Assertions

SimpleName:IDENTIFIER 372 assertThat assertThat

SimpleName:IDENTIFIER 372 getNextLong getNextLong

SimpleName:IDENTIFIER 372 isEqualTo isEqualTo

SimpleName:IDENTIFIER 373 Assertions Assertions

SimpleName:IDENTIFIER 373 assertThat assertThat

SimpleName:IDENTIFIER 373 getNextLong getNextLong

SimpleName:IDENTIFIER 373 isEqualTo isEqualTo

SimpleName:IDENTIFIER 374 Assertions Assertions

SimpleName:IDENTIFIER 374 assertThat assertThat

SimpleName:IDENTIFIER 374 getNextLong getNextLong

SimpleName:IDENTIFIER 374 isEqualTo isEqualTo

SimpleName:IDENTIFIER 375 Assertions Assertions

SimpleName:IDENTIFIER 375 assertThat assertThat

SimpleName:IDENTIFIER 375 getNextLong getNextLong

SimpleName:IDENTIFIER 375 isEqualTo isEqualTo

SimpleName:IDENTIFIER 377 BitUtils BitUtils

SimpleName:IDENTIFIER 378 setNextLong setNextLong

SimpleName:IDENTIFIER 379 setNextLong setNextLong

SimpleName:IDENTIFIER 380 setNextLong setNextLong

SimpleName:IDENTIFIER 381 setNextLong setNextLong

SimpleName:IDENTIFIER 382 setNextLong setNextLong

SimpleName:IDENTIFIER 383 setNextLong setNextLong

SimpleName:IDENTIFIER 384 setNextLong setNextLong

SimpleName:IDENTIFIER 385 setNextLong setNextLong

SimpleName:IDENTIFIER 386 setNextLong setNextLong

SimpleName:IDENTIFIER 389 Assertions Assertions

SimpleName:IDENTIFIER 389 assertThat assertThat

SimpleName:IDENTIFIER 389 getNextLong getNextLong

SimpleName:IDENTIFIER 389 isEqualTo isEqualTo

SimpleName:IDENTIFIER 390 Assertions Assertions

SimpleName:IDENTIFIER 390 assertThat assertThat

SimpleName:IDENTIFIER 390 getNextLong getNextLong

SimpleName:IDENTIFIER 390 isEqualTo isEqualTo

SimpleName:IDENTIFIER 391 Assertions Assertions

SimpleName:IDENTIFIER 391 assertThat assertThat

SimpleName:IDENTIFIER 391 getNextLong getNextLong

SimpleName:IDENTIFIER 391 isEqualTo isEqualTo

SimpleName:IDENTIFIER 392 Assertions Assertions

SimpleName:IDENTIFIER 392 assertThat assertThat

SimpleName:IDENTIFIER 392 getNextLong getNextLong

SimpleName:IDENTIFIER 392 isEqualTo isEqualTo

SimpleName:IDENTIFIER 393 Assertions Assertions

SimpleName:IDENTIFIER 393 assertThat assertThat

SimpleName:IDENTIFIER 393 getNextLong getNextLong

SimpleName:IDENTIFIER 393 isEqualTo isEqualTo

SimpleName:IDENTIFIER 394 Assertions Assertions

SimpleName:IDENTIFIER 394 assertThat assertThat

SimpleName:IDENTIFIER 394 getNextLong getNextLong

SimpleName:IDENTIFIER 394 isEqualTo isEqualTo

SimpleName:IDENTIFIER 395 Assertions Assertions

SimpleName:IDENTIFIER 395 assertThat assertThat

SimpleName:IDENTIFIER 395 getNextLong getNextLong

SimpleName:IDENTIFIER 395 isEqualTo isEqualTo

SimpleName:IDENTIFIER 396 Assertions Assertions

SimpleName:IDENTIFIER 396 assertThat assertThat

SimpleName:IDENTIFIER 396 getNextLong getNextLong

SimpleName:IDENTIFIER 396 isEqualTo isEqualTo

SimpleName:IDENTIFIER 397 Assertions Assertions

SimpleName:IDENTIFIER 397 assertThat assertThat

SimpleName:IDENTIFIER 397 getNextLong getNextLong

SimpleName:IDENTIFIER 397 isEqualTo isEqualTo

SimpleName:IDENTIFIER 401 setNextLong setNextLong

@Test
public void testSetLong() {
    BitUtils bit3 = new BitUtils(128);
    bit3.setNextLong(10, 6);
    bit3.setNextLong(23, 12);
    bit3.setNextLong(5, 8);
    bit3.setNextLong(930, 16);
    bit3.setNextLong(5, 3);
    bit3.setNextLong(159, 8);
    bit3.setNextLong(7, 3);
    bit3.reset();
    Assertions.assertThat(bit3.getNextLong(6)).isEqualTo(10);
    Assertions.assertThat(bit3.getNextLong(12)).isEqualTo(23);
    Assertions.assertThat(bit3.getNextLong(8)).isEqualTo(5);
    Assertions.assertThat(bit3.getNextLong(16)).isEqualTo(930);
    Assertions.assertThat(bit3.getNextLong(3)).isEqualTo(5);
    Assertions.assertThat(bit3.getNextLong(8)).isEqualTo(159);
    Assertions.assertThat(bit3.getNextLong(3)).isEqualTo(7);
    BitUtils bit2 = new BitUtils(128);
    bit2.setNextLong(3, 2);
    bit2.setNextLong(1057, 14);
    bit2.setNextLong(1, 1);
    bit2.setNextLong(1532, 15);
    bit2.setNextLong(8, 8);
    bit2.setNextLong(1532, 15);
    bit2.reset();
    Assertions.assertThat(bit2.getNextLong(2)).isEqualTo(3);
    Assertions.assertThat(bit2.getNextLong(14)).isEqualTo(1057);
    Assertions.assertThat(bit2.getNextLong(1)).isEqualTo(1);
    Assertions.assertThat(bit2.getNextLong(15)).isEqualTo(1532);
    Assertions.assertThat(bit2.getNextLong(8)).isEqualTo(8);
    Assertions.assertThat(bit2.getNextLong(15)).isEqualTo(1532);
    BitUtils bit = new BitUtils(64);
    bit.setNextLong(3, 2);
    bit.setNextLong(255, 8);
    bit.setNextLong(0, 2);
    bit.setNextLong(15, 4);
    bit.setNextLong(2, 2);
    bit.setNextLong(3, 3);
    bit.setNextLong(1, 1);
    bit.setNextLong(0, 1);
    bit.setNextLong(1, 1);
    bit.reset();
    Assertions.assertThat(bit.getNextLong(2)).isEqualTo(3);
    Assertions.assertThat(bit.getNextLong(8)).isEqualTo(255);
    Assertions.assertThat(bit.getNextLong(2)).isEqualTo(0);
    Assertions.assertThat(bit.getNextLong(4)).isEqualTo(15);
    Assertions.assertThat(bit.getNextLong(2)).isEqualTo(2);
    Assertions.assertThat(bit.getNextLong(3)).isEqualTo(3);
    Assertions.assertThat(bit.getNextLong(1)).isEqualTo(1);
    Assertions.assertThat(bit.getNextLong(1)).isEqualTo(0);
    Assertions.assertThat(bit.getNextLong(1)).isEqualTo(1);
    bit.reset();
    bit.setNextLong(500, 65);
}

@Test(expected = IllegalArgumentException.class)
public void testSetLong() {
    BitUtils bit3 = new BitUtils(128);
    bit3.setNextLong(10, 6);
    bit3.setNextLong(23, 12);
    bit3.setNextLong(5, 8);
    bit3.setNextLong(930, 16);
    bit3.setNextLong(5, 3);
    bit3.setNextLong(159, 8);
    bit3.setNextLong(7, 3);
    bit3.reset();
    Assertions.assertThat(bit3.getNextLong(6)).isEqualTo(10);
    Assertions.assertThat(bit3.getNextLong(12)).isEqualTo(23);
    Assertions.assertThat(bit3.getNextLong(8)).isEqualTo(5);
    Assertions.assertThat(bit3.getNextLong(16)).isEqualTo(930);
    Assertions.assertThat(bit3.getNextLong(3)).isEqualTo(5);
    Assertions.assertThat(bit3.getNextLong(8)).isEqualTo(159);
    Assertions.assertThat(bit3.getNextLong(3)).isEqualTo(7);
    BitUtils bit2 = new BitUtils(128);
    bit2.setNextLong(3, 2);
    bit2.setNextLong(1057, 14);
    bit2.setNextLong(1, 1);
    bit2.setNextLong(1532, 15);
    bit2.setNextLong(8, 8);
    bit2.setNextLong(1532, 15);
    bit2.reset();
    Assertions.assertThat(bit2.getNextLong(2)).isEqualTo(3);
    Assertions.assertThat(bit2.getNextLong(14)).isEqualTo(1057);
    Assertions.assertThat(bit2.getNextLong(1)).isEqualTo(1);
    Assertions.assertThat(bit2.getNextLong(15)).isEqualTo(1532);
    Assertions.assertThat(bit2.getNextLong(8)).isEqualTo(8);
    Assertions.assertThat(bit2.getNextLong(15)).isEqualTo(1532);
    BitUtils bit = new BitUtils(64);
    bit.setNextLong(3, 2);
    bit.setNextLong(255, 8);
    bit.setNextLong(0, 2);
    bit.setNextLong(15, 4);
    bit.setNextLong(2, 2);
    bit.setNextLong(3, 3);
    bit.setNextLong(1, 1);
    bit.setNextLong(0, 1);
    bit.setNextLong(1, 1);
    bit.reset();
    Assertions.assertThat(bit.getNextLong(2)).isEqualTo(3);
    Assertions.assertThat(bit.getNextLong(8)).isEqualTo(255);
    Assertions.assertThat(bit.getNextLong(2)).isEqualTo(0);
    Assertions.assertThat(bit.getNextLong(4)).isEqualTo(15);
    Assertions.assertThat(bit.getNextLong(2)).isEqualTo(2);
    Assertions.assertThat(bit.getNextLong(3)).isEqualTo(3);
    Assertions.assertThat(bit.getNextLong(1)).isEqualTo(1);
    Assertions.assertThat(bit.getNextLong(1)).isEqualTo(0);
    Assertions.assertThat(bit.getNextLong(1)).isEqualTo(1);
    bit.reset();
    bit.setNextLong(500, 65);
}

Test the method to set an long


SimpleName:IDENTIFIER 617 expected expected

SimpleName:IDENTIFIER 617 IllegalArgumentException IllegalArgumentException

SimpleName:IDENTIFIER 618 testOverflowIntegerSign testOverflowIntegerSign

SimpleName:IDENTIFIER 619 BitUtils BitUtils

SimpleName:IDENTIFIER 619 Integer Integer

SimpleName:IDENTIFIER 620 setNextInteger setNextInteger

SimpleName:IDENTIFIER 622 Assertions Assertions

SimpleName:IDENTIFIER 622 assertThat assertThat

SimpleName:IDENTIFIER 622 getNextIntegerSigned getNextIntegerSigned

SimpleName:IDENTIFIER 622 isEqualTo isEqualTo

@Test(expected = IllegalArgumentException.class)
public void testOverflowIntegerSign() {
    BitUtils bit = new BitUtils(Integer.SIZE);
    bit.setNextInteger(-2, 4);
    bit.reset();
    Assertions.assertThat(bit.getNextIntegerSigned(33)).isEqualTo(-2);
}

Unit test for signed value


SimpleName:IDENTIFIER 628 expected expected

SimpleName:IDENTIFIER 628 IllegalArgumentException IllegalArgumentException

SimpleName:IDENTIFIER 629 testOverflowLongSign testOverflowLongSign

SimpleName:IDENTIFIER 630 BitUtils BitUtils

SimpleName:IDENTIFIER 631 setNextInteger setNextInteger

SimpleName:IDENTIFIER 633 Assertions Assertions

SimpleName:IDENTIFIER 633 assertThat assertThat

SimpleName:IDENTIFIER 633 getNextLongSigned getNextLongSigned

SimpleName:IDENTIFIER 633 isEqualTo isEqualTo

@Test(expected = IllegalArgumentException.class)
public void testOverflowLongSign() {
    BitUtils bit = new BitUtils(Long.SIZE);
    bit.setNextInteger(-2, 4);
    bit.reset();
    Assertions.assertThat(bit.getNextLongSigned(65)).isEqualTo(-2);
}

Unit test for signed value


SimpleName:IDENTIFIER 26 expected expected

SimpleName:IDENTIFIER 26 ConverterException ConverterException

SimpleName:IDENTIFIER 27 testStringToRError testStringToRError

SimpleName:IDENTIFIER 27 ConverterException ConverterException

SimpleName:IDENTIFIER 28 converter converter

SimpleName:IDENTIFIER 28 stringToR stringToR

StringLiteralExpr:LITERAL 28 "abc" "abc"

@Test(expected = ConverterException.class)
public void testStringToRError() throws ConverterException {
    converter.stringToR("abc");
}

package io.github.biezhi.excel.plus.converter;

import io.github.biezhi.excel.plus.conveter.Converter;
import io.github.biezhi.excel.plus.conveter.DoubleConverter;
import io.github.biezhi.excel.plus.conveter.FloatConverter;
import io.github.biezhi.excel.plus.exception.ConverterException;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;

public class adhoc_FloatConverterTest {

    private Converter<String, Float> converter = new FloatConverter();
    /*TEST PLACEHOLDER*/
}


SimpleName:IDENTIFIER 27 expected expected

SimpleName:IDENTIFIER 28 testStringToRError testStringToRError

SimpleName:IDENTIFIER 28 ConverterException ConverterException

SimpleName:IDENTIFIER 29 converter converter

SimpleName:IDENTIFIER 29 stringToR stringToR

StringLiteralExpr:LITERAL 29 "abc" "abc"

package io.github.biezhi.excel.plus.converter;

import io.github.biezhi.excel.plus.conveter.Converter;
import io.github.biezhi.excel.plus.conveter.DecimalConverter;
import io.github.biezhi.excel.plus.exception.ConverterException;
import org.junit.Test;
import java.math.BigDecimal;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;

public class adhoc_DecimalConverterTest {

    private Converter<String, BigDecimal> converter = new DecimalConverter();
    /*TEST PLACEHOLDER*/
}


SimpleName:IDENTIFIER 23 expected expected

SimpleName:IDENTIFIER 23 ConverterException ConverterException

SimpleName:IDENTIFIER 24 testStringToRError testStringToRError

SimpleName:IDENTIFIER 24 ConverterException ConverterException

SimpleName:IDENTIFIER 25 converter converter

SimpleName:IDENTIFIER 25 stringToR stringToR

SimpleName:IDENTIFIER 25 Integer Integer

SimpleName:IDENTIFIER 26 converter converter

SimpleName:IDENTIFIER 26 stringToR stringToR

StringLiteralExpr:LITERAL 26 "abc" "abc"

@Test(expected = ConverterException.class)
public void testStringToRError() throws ConverterException {
    converter.stringToR(Integer.MAX_VALUE + "");
    converter.stringToR("abc");
}

package io.github.biezhi.excel.plus.converter;

import io.github.biezhi.excel.plus.conveter.ByteConverter;
import io.github.biezhi.excel.plus.conveter.Converter;
import io.github.biezhi.excel.plus.exception.ConverterException;
import org.junit.Test;
import static org.junit.Assert.assertEquals;

public class adhoc_ByteConverterTest {

    private Converter<String, Byte> converter = new ByteConverter();
    /*TEST PLACEHOLDER*/
}


SimpleName:IDENTIFIER 26 expected expected

SimpleName:IDENTIFIER 26 ConverterException ConverterException

SimpleName:IDENTIFIER 27 testStringToRError testStringToRError

SimpleName:IDENTIFIER 27 ConverterException ConverterException

SimpleName:IDENTIFIER 28 converter converter

SimpleName:IDENTIFIER 28 stringToR stringToR

StringLiteralExpr:LITERAL 28 "abc" "abc"

@Test(expected = ConverterException.class)
public void testStringToRError() throws ConverterException {
    converter.stringToR("abc");
}

package io.github.biezhi.excel.plus.converter;

import io.github.biezhi.excel.plus.conveter.Converter;
import io.github.biezhi.excel.plus.conveter.DoubleConverter;
import io.github.biezhi.excel.plus.conveter.ShortConverter;
import io.github.biezhi.excel.plus.exception.ConverterException;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;

public class adhoc_ShortConverterTest {

    private Converter<String, Short> converter = new ShortConverter();
    /*TEST PLACEHOLDER*/
}


SimpleName:IDENTIFIER 53 expected expected

SimpleName:IDENTIFIER 53 ConverterException ConverterException

SimpleName:IDENTIFIER 54 testToStringError testToStringError

SimpleName:IDENTIFIER 54 ConverterException ConverterException

SimpleName:IDENTIFIER 55 converter converter

SimpleName:IDENTIFIER 55 DateConverter DateConverter

StringLiteralExpr:LITERAL 55 "abcd" "abcd"

SimpleName:IDENTIFIER 56 converter converter

SimpleName:IDENTIFIER 56 toString toString

@Test(expected = ConverterException.class)
public void testToStringError() throws ConverterException {
    Converter<String, Date> converter = new DateConverter("abcd");
    converter.toString(new Date());
}

package io.github.biezhi.excel.plus.converter;

import io.github.biezhi.excel.plus.conveter.Converter;
import io.github.biezhi.excel.plus.conveter.DateConverter;
import io.github.biezhi.excel.plus.exception.ConverterException;
import org.junit.Test;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;

public class adhoc_DateConverterTest {
    /*TEST PLACEHOLDER*/
}


SimpleName:IDENTIFIER 25 expected expected

SimpleName:IDENTIFIER 25 ConverterException ConverterException

SimpleName:IDENTIFIER 26 testStringToRError testStringToRError

SimpleName:IDENTIFIER 26 ConverterException ConverterException

SimpleName:IDENTIFIER 27 converter converter

SimpleName:IDENTIFIER 27 stringToR stringToR

StringLiteralExpr:LITERAL 27 "abc" "abc"

SimpleName:IDENTIFIER 28 converter converter

SimpleName:IDENTIFIER 28 stringToR stringToR

@Test(expected = ConverterException.class)
public void testStringToRError() throws ConverterException {
    converter.stringToR("abc");
    converter.stringToR((Long.MAX_VALUE + 1) + "");
}

package io.github.biezhi.excel.plus.converter;

import io.github.biezhi.excel.plus.conveter.Converter;
import io.github.biezhi.excel.plus.conveter.LongConverter;
import io.github.biezhi.excel.plus.exception.ConverterException;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;

public class adhoc_LongConverterTest {

    private Converter<String, Long> converter = new LongConverter();
    /*TEST PLACEHOLDER*/
}


SimpleName:IDENTIFIER 28 expected expected

SimpleName:IDENTIFIER 28 ConverterException ConverterException

SimpleName:IDENTIFIER 29 testStringToRError testStringToRError

SimpleName:IDENTIFIER 29 ConverterException ConverterException

SimpleName:IDENTIFIER 30 converter converter

SimpleName:IDENTIFIER 30 stringToR stringToR

StringLiteralExpr:LITERAL 30 "abc" "abc"

@Test(expected = ConverterException.class)
public void testStringToRError() throws ConverterException {
    converter.stringToR("abc");
}

package io.github.biezhi.excel.plus.converter;

import io.github.biezhi.excel.plus.conveter.Converter;
import io.github.biezhi.excel.plus.conveter.DecimalConverter;
import io.github.biezhi.excel.plus.conveter.DoubleConverter;
import io.github.biezhi.excel.plus.exception.ConverterException;
import org.junit.Test;
import java.math.BigDecimal;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;

public class adhoc_DoubleConverterTest {

    private Converter<String, Double> converter = new DoubleConverter();
    /*TEST PLACEHOLDER*/
}


SimpleName:IDENTIFIER 30 expected expected

SimpleName:IDENTIFIER 30 ConverterException ConverterException

SimpleName:IDENTIFIER 31 testStringToRError testStringToRError

SimpleName:IDENTIFIER 31 ConverterException ConverterException

SimpleName:IDENTIFIER 32 converter converter

SimpleName:IDENTIFIER 32 stringToR stringToR

StringLiteralExpr:LITERAL 32 "abc" "abc"

SimpleName:IDENTIFIER 33 converter converter

SimpleName:IDENTIFIER 33 stringToR stringToR

@Test(expected = ConverterException.class)
public void testStringToRError() throws ConverterException {
    converter.stringToR("abc");
    converter.stringToR(Long.MAX_VALUE + "");
}

package io.github.biezhi.excel.plus.converter;

import io.github.biezhi.excel.plus.conveter.Converter;
import io.github.biezhi.excel.plus.conveter.IntConverter;
import io.github.biezhi.excel.plus.exception.ConverterException;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;

public class adhoc_IntConverterTest {

    private Converter<String, Integer> converter = new IntConverter();
    /*TEST PLACEHOLDER*/
}


SimpleName:IDENTIFIER 33 expected expected

SimpleName:IDENTIFIER 33 ConverterException ConverterException

SimpleName:IDENTIFIER 34 testStringToRError testStringToRError

SimpleName:IDENTIFIER 34 ConverterException ConverterException

SimpleName:IDENTIFIER 35 converter converter

SimpleName:IDENTIFIER 35 LocalDateConverter LocalDateConverter

StringLiteralExpr:LITERAL 35 "yyyy/MM/dd" "yyyy/MM/dd"

SimpleName:IDENTIFIER 36 converter converter

SimpleName:IDENTIFIER 36 stringToR stringToR

@Test(expected = ConverterException.class)
public void testStringToRError() throws ConverterException {
    Converter<String, LocalDate> converter = new LocalDateConverter("yyyy/MM/dd");
    converter.stringToR("2018-12-12");
}

package io.github.biezhi.excel.plus.converter;

import io.github.biezhi.excel.plus.conveter.Converter;
import io.github.biezhi.excel.plus.conveter.LocalDateConverter;
import io.github.biezhi.excel.plus.exception.ConverterException;
import org.junit.Test;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;

public class adhoc_LocalDateConverterTest {
    /*TEST PLACEHOLDER*/
}


SimpleName:IDENTIFIER 35 expected expected

SimpleName:IDENTIFIER 35 ConverterException ConverterException

SimpleName:IDENTIFIER 36 testStringToRError testStringToRError

SimpleName:IDENTIFIER 36 ConverterException ConverterException

SimpleName:IDENTIFIER 37 converter converter

SimpleName:IDENTIFIER 37 LocalDateTimeConverter LocalDateTimeConverter

SimpleName:IDENTIFIER 37 pattern pattern

SimpleName:IDENTIFIER 38 converter converter

SimpleName:IDENTIFIER 38 stringToR stringToR

@Test(expected = ConverterException.class)
public void testStringToRError() throws ConverterException {
    Converter<String, LocalDateTime> converter = new LocalDateTimeConverter(pattern);
    converter.stringToR("2018-12-12");
}

package io.github.biezhi.excel.plus.converter;

import io.github.biezhi.excel.plus.conveter.Converter;
import io.github.biezhi.excel.plus.conveter.LocalDateTimeConverter;
import io.github.biezhi.excel.plus.exception.ConverterException;
import org.junit.Test;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;

public class adhoc_LocalDateTimeConverterTest {

    private final String pattern = "yyyy/MM/dd HH:mm:ss";
    /*TEST PLACEHOLDER*/
}


SimpleName:IDENTIFIER 32 expected expected

SimpleName:IDENTIFIER 32 ConverterException ConverterException

SimpleName:IDENTIFIER 33 testStringToRError testStringToRError

SimpleName:IDENTIFIER 33 ConverterException ConverterException

SimpleName:IDENTIFIER 34 converter converter

SimpleName:IDENTIFIER 34 stringToR stringToR

StringLiteralExpr:LITERAL 34 "abc" "abc"

@Test(expected = ConverterException.class)
public void testStringToRError() throws ConverterException {
    converter.stringToR("abc");
}

package io.github.biezhi.excel.plus.converter;

import io.github.biezhi.excel.plus.conveter.BigIntConverter;
import io.github.biezhi.excel.plus.conveter.Converter;
import io.github.biezhi.excel.plus.exception.ConverterException;
import org.junit.Test;
import java.math.BigInteger;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;

public class adhoc_BigIntConverterTest {

    private Converter<String, BigInteger> converter = new BigIntConverter();
    /*TEST PLACEHOLDER*/
}


SimpleName:IDENTIFIER 12 expected expected

SimpleName:IDENTIFIER 12 RuntimeException RuntimeException

SimpleName:IDENTIFIER 13 testStringToR testStringToR

SimpleName:IDENTIFIER 14 NullConverter NullConverter

SimpleName:IDENTIFIER 14 stringToR stringToR

StringLiteralExpr:LITERAL 14 "hello" "hello"

@Test(expected = RuntimeException.class)
public void testStringToR() {
    new NullConverter().stringToR("hello");
}

package io.github.biezhi.excel.plus.converter;

import io.github.biezhi.excel.plus.conveter.NullConverter;
import org.junit.Test;

public class adhoc_NullConverterTest {
    /*TEST PLACEHOLDER*/
}


SimpleName:IDENTIFIER 66 expected expected

SimpleName:IDENTIFIER 66 IllegalArgumentException IllegalArgumentException

SimpleName:IDENTIFIER 67 testReaderFileAndStreamIsNull testReaderFileAndStreamIsNull

SimpleName:IDENTIFIER 67 ReaderException ReaderException

SimpleName:IDENTIFIER 68 asStream asStream

@Test(expected = IllegalArgumentException.class)
public void testReaderFileAndStreamIsNull() throws ReaderException {
    Reader.create(Sample.class).asStream();
}

package io.github.biezhi.excel.plus;

import io.github.biezhi.excel.plus.exception.ReaderException;
import io.github.biezhi.excel.plus.model.Sample;
import org.junit.Test;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.util.List;
import java.util.stream.Stream;
import static org.junit.Assert.*;

public class adhoc_ReaderTest extends BaseTest {
    /*TEST PLACEHOLDER*/
}


SimpleName:IDENTIFIER 87 expected expected

SimpleName:IDENTIFIER 87 IllegalArgumentException IllegalArgumentException

SimpleName:IDENTIFIER 88 testStartRowError testStartRowError

@Test(expected = IllegalArgumentException.class)
public void testStartRowError() {
    Reader.create(null).start(-1);
}


SimpleName:IDENTIFIER 92 expected expected

SimpleName:IDENTIFIER 92 IllegalArgumentException IllegalArgumentException

SimpleName:IDENTIFIER 93 testSheetIndexError testSheetIndexError

@Test(expected = IllegalArgumentException.class)
public void testSheetIndexError() {
    Reader.create(null).sheet(-1);
}


SimpleName:IDENTIFIER 97 expected expected

SimpleName:IDENTIFIER 97 IllegalArgumentException IllegalArgumentException

SimpleName:IDENTIFIER 98 testSheetNameError testSheetNameError

{
    Reader.create(null).sheet(null);
}

@Test(expected = IllegalArgumentException.class)
public void testSheetNameError() {
    Reader.create(null).sheet(null);
}

{
    Reader.create(null).sheet(null);
}


SimpleName:IDENTIFIER 72 expected expected

SimpleName:IDENTIFIER 72 IllegalArgumentException IllegalArgumentException

SimpleName:IDENTIFIER 73 testNullTemplate testNullTemplate

SimpleName:IDENTIFIER 74 withTemplate withTemplate

@Test(expected = IllegalArgumentException.class)
public void testNullTemplate() {
    Writer.create().withTemplate((File) null);
}

package io.github.biezhi.excel.plus;

import io.github.biezhi.excel.plus.enums.ExcelType;
import io.github.biezhi.excel.plus.exception.WriterException;
import org.junit.Test;
import java.io.File;
import java.util.stream.Stream;
import static org.junit.Assert.*;

public class adhoc_WriterTest extends BaseTest {
    /*TEST PLACEHOLDER*/
}

SimpleName:IDENTIFIER 77 expected expected

SimpleName:IDENTIFIER 77 IllegalArgumentException IllegalArgumentException

SimpleName:IDENTIFIER 78 testNotExistTemplate testNotExistTemplate

SimpleName:IDENTIFIER 79 withTemplate withTemplate

@Test(expected = IllegalArgumentException.class)
public void testNotExistTemplate() {
    Writer.create().withTemplate(new File("abcd.12346"));
}


SimpleName:IDENTIFIER 143 expected expected

SimpleName:IDENTIFIER 143 IllegalArgumentException IllegalArgumentException

SimpleName:IDENTIFIER 144 testStartRowError testStartRowError

@Test(expected = IllegalArgumentException.class)
public void testStartRowError() {
    Writer.create().start(-1);
}


SimpleName:IDENTIFIER 148 expected expected

SimpleName:IDENTIFIER 148 IllegalArgumentException IllegalArgumentException

SimpleName:IDENTIFIER 149 testSheetNameError testSheetNameError

@Test(expected = IllegalArgumentException.class)
public void testSheetNameError() {
    Writer.create().sheet(null);
}


SimpleName:IDENTIFIER 100 testGetMessageSelectorNotSupported testGetMessageSelectorNotSupported

SimpleName:IDENTIFIER 103 consumer consumer

SimpleName:IDENTIFIER 103 getMessageSelector getMessageSelector

@Test
public void testGetMessageSelectorNotSupported() {
    consumer.getMessageSelector();
}

@Test(expected = JMSException.class)
public void testGetMessageSelectorNotSupported() {
    consumer.getMessageSelector();
}

package com.amazon.sqs.javamessaging;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import javax.jms.JMSException;
import javax.jms.MessageListener;
import com.amazon.sqs.javamessaging.SQSConnection;
import com.amazon.sqs.javamessaging.SQSMessageConsumer;
import com.amazon.sqs.javamessaging.SQSMessageConsumerPrefetch;
import com.amazon.sqs.javamessaging.SQSQueueDestination;
import com.amazon.sqs.javamessaging.SQSSession;
import com.amazon.sqs.javamessaging.SQSSessionCallbackScheduler;
import com.amazon.sqs.javamessaging.acknowledge.AcknowledgeMode;
import com.amazon.sqs.javamessaging.acknowledge.Acknowledger;
import com.amazon.sqs.javamessaging.acknowledge.NegativeAcknowledger;
import com.amazon.sqs.javamessaging.acknowledge.SQSMessageIdentifier;
import com.amazon.sqs.javamessaging.util.SQSMessagingClientThreadFactory;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.mockito.Mockito.when;

public class adhoc_SQSMessageConsumerTest {

    private static final String QUEUE_URL_1 = "QueueUrl1";

    private static final String QUEUE_URL_2 = "queueUrl2";

    private static final String QUEUE_NAME = "QueueName";

    private SQSMessageConsumer consumer;

    private SQSConnection sqsConnection;

    private SQSSession sqsSession;

    private SQSSessionCallbackScheduler sqsSessionRunnable;

    private Acknowledger acknowledger;

    private ScheduledExecutorService executorService = Executors.newScheduledThreadPool(5);

    private SQSMessageConsumerPrefetch sqsMessageConsumerPrefetch;

    private NegativeAcknowledger negativeAcknowledger;

    private SQSMessagingClientThreadFactory threadFactory;

    private SQSQueueDestination destination;

    @Before
    public void setup() throws JMSException {
        sqsConnection = mock(SQSConnection.class);
        sqsSession = spy(new SQSSession(sqsConnection, AcknowledgeMode.ACK_AUTO));
        sqsSessionRunnable = mock(SQSSessionCallbackScheduler.class);
        acknowledger = mock(Acknowledger.class);
        negativeAcknowledger = mock(NegativeAcknowledger.class);
        threadFactory = new SQSMessagingClientThreadFactory("testTask", true);
        destination = new SQSQueueDestination(QUEUE_NAME, QUEUE_URL_1);
        consumer = spy(new SQSMessageConsumer(sqsConnection, sqsSession, sqsSessionRunnable, destination, acknowledger, negativeAcknowledger, threadFactory));
        sqsMessageConsumerPrefetch = mock(SQSMessageConsumerPrefetch.class);
    }
    /*TEST PLACEHOLDER*/
}

Test the message selector is not supported


SimpleName:IDENTIFIER 85 expected expected

SimpleName:IDENTIFIER 85 JMSException JMSException

SimpleName:IDENTIFIER 86 JMSException JMSException

SimpleName:IDENTIFIER 88 endpoint endpoint

StringLiteralExpr:LITERAL 88 "endpoint" "endpoint"

SimpleName:IDENTIFIER 89 doThrow doThrow

SimpleName:IDENTIFIER 89 IllegalArgumentException IllegalArgumentException

StringLiteralExpr:LITERAL 89 "iae" "iae"

SimpleName:IDENTIFIER 90 amazonSQSClient amazonSQSClient

SimpleName:IDENTIFIER 90 setEndpoint setEndpoint

SimpleName:IDENTIFIER 90 endpoint endpoint

SimpleName:IDENTIFIER 92 wrapper wrapper

SimpleName:IDENTIFIER 92 setEndpoint setEndpoint

SimpleName:IDENTIFIER 92 endpoint endpoint

@Test(expected = JMSException.class)
public void testSetEndpointThrowIllegalArgumentException() throws JMSException {
    String endpoint = "endpoint";
    doThrow(new IllegalArgumentException("iae")).when(amazonSQSClient).setEndpoint(eq(endpoint));
    wrapper.setEndpoint(endpoint);
}

package com.amazon.sqs.javamessaging;

import com.amazon.sqs.javamessaging.AmazonSQSMessagingClientWrapper;
import com.amazonaws.AmazonClientException;
import com.amazonaws.AmazonServiceException;
import com.amazonaws.regions.Region;
import com.amazonaws.regions.Regions;
import com.amazonaws.services.sqs.AmazonSQSClient;
import com.amazonaws.services.sqs.model.ChangeMessageVisibilityBatchRequest;
import com.amazonaws.services.sqs.model.ChangeMessageVisibilityRequest;
import com.amazonaws.services.sqs.model.CreateQueueRequest;
import com.amazonaws.services.sqs.model.DeleteMessageBatchRequest;
import com.amazonaws.services.sqs.model.DeleteMessageRequest;
import com.amazonaws.services.sqs.model.GetQueueUrlRequest;
import com.amazonaws.services.sqs.model.QueueDoesNotExistException;
import com.amazonaws.services.sqs.model.ReceiveMessageRequest;
import com.amazonaws.services.sqs.model.SendMessageRequest;
import javax.jms.InvalidDestinationException;
import javax.jms.JMSException;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;

public class adhoc_AmazonSQSMessagingClientWrapperTest {

    private final static String QUEUE_NAME = "queueName";

    private static final String OWNER_ACCOUNT_ID = "accountId";

    private AmazonSQSClient amazonSQSClient;

    private AmazonSQSMessagingClientWrapper wrapper;

    @Before
    public void setup() throws JMSException {
        amazonSQSClient = mock(AmazonSQSClient.class);
        wrapper = new AmazonSQSMessagingClientWrapper(amazonSQSClient);
    }
    /*TEST PLACEHOLDER*/
}


SimpleName:IDENTIFIER 109 expected expected

SimpleName:IDENTIFIER 109 JMSException JMSException

SimpleName:IDENTIFIER 110 JMSException JMSException

SimpleName:IDENTIFIER 112 getRegion getRegion

SimpleName:IDENTIFIER 112 Regions Regions

SimpleName:IDENTIFIER 113 doThrow doThrow

SimpleName:IDENTIFIER 113 IllegalArgumentException IllegalArgumentException

StringLiteralExpr:LITERAL 113 "iae" "iae"

SimpleName:IDENTIFIER 114 amazonSQSClient amazonSQSClient

SimpleName:IDENTIFIER 114 setRegion setRegion

SimpleName:IDENTIFIER 116 wrapper wrapper

SimpleName:IDENTIFIER 116 setRegion setRegion

@Test(expected = JMSException.class)
public void testSetRegionThrowIllegalArgumentException() throws JMSException {
    Region region = Region.getRegion(Regions.DEFAULT_REGION);
    doThrow(new IllegalArgumentException("iae")).when(amazonSQSClient).setRegion(eq(region));
    wrapper.setRegion(region);
}


SimpleName:IDENTIFIER 122 expected expected

SimpleName:IDENTIFIER 122 JMSException JMSException

SimpleName:IDENTIFIER 123 JMSException JMSException

SimpleName:IDENTIFIER 125 deleteMessageRequest deleteMessageRequest

SimpleName:IDENTIFIER 125 DeleteMessageRequest DeleteMessageRequest

SimpleName:IDENTIFIER 126 doThrow doThrow

SimpleName:IDENTIFIER 126 AmazonClientException AmazonClientException

StringLiteralExpr:LITERAL 126 "ace" "ace"

SimpleName:IDENTIFIER 127 amazonSQSClient amazonSQSClient

SimpleName:IDENTIFIER 127 deleteMessage deleteMessage

SimpleName:IDENTIFIER 127 deleteMessageRequest deleteMessageRequest

SimpleName:IDENTIFIER 129 wrapper wrapper

SimpleName:IDENTIFIER 129 deleteMessage deleteMessage

SimpleName:IDENTIFIER 129 deleteMessageRequest deleteMessageRequest

@Test(expected = JMSException.class)
public void testDeleteMessageThrowAmazonClientException() throws JMSException {
    DeleteMessageRequest deleteMessageRequest = new DeleteMessageRequest();
    doThrow(new AmazonClientException("ace")).when(amazonSQSClient).deleteMessage(eq(deleteMessageRequest));
    wrapper.deleteMessage(deleteMessageRequest);
}

SimpleName:IDENTIFIER 135 expected expected

SimpleName:IDENTIFIER 135 JMSException JMSException

SimpleName:IDENTIFIER 136 JMSException JMSException

SimpleName:IDENTIFIER 138 deleteMessageRequest deleteMessageRequest

SimpleName:IDENTIFIER 138 DeleteMessageRequest DeleteMessageRequest

SimpleName:IDENTIFIER 139 doThrow doThrow

SimpleName:IDENTIFIER 139 AmazonServiceException AmazonServiceException

StringLiteralExpr:LITERAL 139 "ase" "ase"

SimpleName:IDENTIFIER 140 amazonSQSClient amazonSQSClient

SimpleName:IDENTIFIER 140 deleteMessage deleteMessage

SimpleName:IDENTIFIER 140 deleteMessageRequest deleteMessageRequest

SimpleName:IDENTIFIER 142 wrapper wrapper

SimpleName:IDENTIFIER 142 deleteMessage deleteMessage

SimpleName:IDENTIFIER 142 deleteMessageRequest deleteMessageRequest

@Test(expected = JMSException.class)
public void testDeleteMessageThrowAmazonServiceException() throws JMSException {
    DeleteMessageRequest deleteMessageRequest = new DeleteMessageRequest();
    doThrow(new AmazonServiceException("ase")).when(amazonSQSClient).deleteMessage(eq(deleteMessageRequest));
    wrapper.deleteMessage(deleteMessageRequest);
}


SimpleName:IDENTIFIER 148 expected expected

SimpleName:IDENTIFIER 148 JMSException JMSException

SimpleName:IDENTIFIER 149 JMSException JMSException

SimpleName:IDENTIFIER 151 deleteMessageBatchRequest deleteMessageBatchRequest

SimpleName:IDENTIFIER 151 DeleteMessageBatchRequest DeleteMessageBatchRequest

SimpleName:IDENTIFIER 152 doThrow doThrow

SimpleName:IDENTIFIER 152 AmazonClientException AmazonClientException

StringLiteralExpr:LITERAL 152 "ace" "ace"

SimpleName:IDENTIFIER 153 amazonSQSClient amazonSQSClient

SimpleName:IDENTIFIER 153 deleteMessageBatch deleteMessageBatch

SimpleName:IDENTIFIER 153 deleteMessageBatchRequest deleteMessageBatchRequest

SimpleName:IDENTIFIER 155 wrapper wrapper

SimpleName:IDENTIFIER 155 deleteMessageBatch deleteMessageBatch

SimpleName:IDENTIFIER 155 deleteMessageBatchRequest deleteMessageBatchRequest

@Test(expected = JMSException.class)
public void testDeleteMessageBatchThrowAmazonClientException() throws JMSException {
    DeleteMessageBatchRequest deleteMessageBatchRequest = new DeleteMessageBatchRequest();
    doThrow(new AmazonClientException("ace")).when(amazonSQSClient).deleteMessageBatch(eq(deleteMessageBatchRequest));
    wrapper.deleteMessageBatch(deleteMessageBatchRequest);
}

SimpleName:IDENTIFIER 161 expected expected

SimpleName:IDENTIFIER 161 JMSException JMSException

SimpleName:IDENTIFIER 162 JMSException JMSException

SimpleName:IDENTIFIER 164 deleteMessageBatchRequest deleteMessageBatchRequest

SimpleName:IDENTIFIER 164 DeleteMessageBatchRequest DeleteMessageBatchRequest

SimpleName:IDENTIFIER 165 doThrow doThrow

SimpleName:IDENTIFIER 165 AmazonServiceException AmazonServiceException

StringLiteralExpr:LITERAL 165 "ase" "ase"

SimpleName:IDENTIFIER 166 amazonSQSClient amazonSQSClient

SimpleName:IDENTIFIER 166 deleteMessageBatch deleteMessageBatch

SimpleName:IDENTIFIER 166 deleteMessageBatchRequest deleteMessageBatchRequest

SimpleName:IDENTIFIER 168 wrapper wrapper

SimpleName:IDENTIFIER 168 deleteMessageBatch deleteMessageBatch

SimpleName:IDENTIFIER 168 deleteMessageBatchRequest deleteMessageBatchRequest

@Test(expected = JMSException.class)
public void testDeleteMessageBatchThrowAmazonServiceException() throws JMSException {
    DeleteMessageBatchRequest deleteMessageBatchRequest = new DeleteMessageBatchRequest();
    doThrow(new AmazonServiceException("ase")).when(amazonSQSClient).deleteMessageBatch(eq(deleteMessageBatchRequest));
    wrapper.deleteMessageBatch(deleteMessageBatchRequest);
}


SimpleName:IDENTIFIER 174 expected expected

SimpleName:IDENTIFIER 174 JMSException JMSException

SimpleName:IDENTIFIER 175 JMSException JMSException

SimpleName:IDENTIFIER 177 sendMessageRequest sendMessageRequest

SimpleName:IDENTIFIER 177 SendMessageRequest SendMessageRequest

SimpleName:IDENTIFIER 178 doThrow doThrow

SimpleName:IDENTIFIER 178 AmazonClientException AmazonClientException

StringLiteralExpr:LITERAL 178 "ace" "ace"

SimpleName:IDENTIFIER 179 amazonSQSClient amazonSQSClient

SimpleName:IDENTIFIER 179 sendMessage sendMessage

SimpleName:IDENTIFIER 179 sendMessageRequest sendMessageRequest

SimpleName:IDENTIFIER 181 wrapper wrapper

SimpleName:IDENTIFIER 181 sendMessage sendMessage

SimpleName:IDENTIFIER 181 sendMessageRequest sendMessageRequest

@Test(expected = JMSException.class)
public void testSendMessageThrowAmazonClientException() throws JMSException {
    SendMessageRequest sendMessageRequest = new SendMessageRequest();
    doThrow(new AmazonClientException("ace")).when(amazonSQSClient).sendMessage(eq(sendMessageRequest));
    wrapper.sendMessage(sendMessageRequest);
}

SimpleName:IDENTIFIER 187 expected expected

SimpleName:IDENTIFIER 187 JMSException JMSException

SimpleName:IDENTIFIER 188 JMSException JMSException

SimpleName:IDENTIFIER 190 sendMessageRequest sendMessageRequest

SimpleName:IDENTIFIER 190 SendMessageRequest SendMessageRequest

SimpleName:IDENTIFIER 191 doThrow doThrow

SimpleName:IDENTIFIER 191 AmazonServiceException AmazonServiceException

StringLiteralExpr:LITERAL 191 "ase" "ase"

SimpleName:IDENTIFIER 192 amazonSQSClient amazonSQSClient

SimpleName:IDENTIFIER 192 sendMessage sendMessage

SimpleName:IDENTIFIER 192 sendMessageRequest sendMessageRequest

SimpleName:IDENTIFIER 194 wrapper wrapper

SimpleName:IDENTIFIER 194 sendMessage sendMessage

SimpleName:IDENTIFIER 194 sendMessageRequest sendMessageRequest

@Test(expected = JMSException.class)
public void testSendMessageThrowAmazonServiceException() throws JMSException {
    SendMessageRequest sendMessageRequest = new SendMessageRequest();
    doThrow(new AmazonServiceException("ase")).when(amazonSQSClient).sendMessage(eq(sendMessageRequest));
    wrapper.sendMessage(sendMessageRequest);
}


SimpleName:IDENTIFIER 290 expected expected

SimpleName:IDENTIFIER 290 JMSException JMSException

SimpleName:IDENTIFIER 291 JMSException JMSException

SimpleName:IDENTIFIER 293 getQueueUrlRequest getQueueUrlRequest

SimpleName:IDENTIFIER 293 GetQueueUrlRequest GetQueueUrlRequest

SimpleName:IDENTIFIER 294 doThrow doThrow

SimpleName:IDENTIFIER 294 AmazonClientException AmazonClientException

StringLiteralExpr:LITERAL 294 "ace" "ace"

SimpleName:IDENTIFIER 295 amazonSQSClient amazonSQSClient

SimpleName:IDENTIFIER 295 getQueueUrl getQueueUrl

SimpleName:IDENTIFIER 295 getQueueUrlRequest getQueueUrlRequest

SimpleName:IDENTIFIER 297 wrapper wrapper

SimpleName:IDENTIFIER 297 getQueueUrl getQueueUrl

SimpleName:IDENTIFIER 297 getQueueUrlRequest getQueueUrlRequest

@Test(expected = JMSException.class)
public void testGetQueueUrlThrowAmazonClientException() throws JMSException {
    GetQueueUrlRequest getQueueUrlRequest = new GetQueueUrlRequest(QUEUE_NAME);
    doThrow(new AmazonClientException("ace")).when(amazonSQSClient).getQueueUrl(eq(getQueueUrlRequest));
    wrapper.getQueueUrl(getQueueUrlRequest);
}


SimpleName:IDENTIFIER 339 expected expected

SimpleName:IDENTIFIER 339 JMSException JMSException

SimpleName:IDENTIFIER 340 JMSException JMSException

SimpleName:IDENTIFIER 342 getQueueUrlRequest getQueueUrlRequest

SimpleName:IDENTIFIER 342 GetQueueUrlRequest GetQueueUrlRequest

SimpleName:IDENTIFIER 343 doThrow doThrow

SimpleName:IDENTIFIER 343 AmazonClientException AmazonClientException

StringLiteralExpr:LITERAL 343 "ace" "ace"

SimpleName:IDENTIFIER 344 amazonSQSClient amazonSQSClient

SimpleName:IDENTIFIER 344 getQueueUrl getQueueUrl

SimpleName:IDENTIFIER 344 getQueueUrlRequest getQueueUrlRequest

SimpleName:IDENTIFIER 346 wrapper wrapper

SimpleName:IDENTIFIER 346 queueExists queueExists

@Test(expected = JMSException.class)
public void testQueueExistsThrowAmazonClientException() throws JMSException {
    GetQueueUrlRequest getQueueUrlRequest = new GetQueueUrlRequest(QUEUE_NAME);
    doThrow(new AmazonClientException("ace")).when(amazonSQSClient).getQueueUrl(eq(getQueueUrlRequest));
    wrapper.queueExists(QUEUE_NAME);
}

SimpleName:IDENTIFIER 352 expected expected

SimpleName:IDENTIFIER 352 JMSException JMSException

SimpleName:IDENTIFIER 353 JMSException JMSException

SimpleName:IDENTIFIER 355 getQueueUrlRequest getQueueUrlRequest

SimpleName:IDENTIFIER 355 GetQueueUrlRequest GetQueueUrlRequest

SimpleName:IDENTIFIER 356 doThrow doThrow

SimpleName:IDENTIFIER 356 AmazonServiceException AmazonServiceException

StringLiteralExpr:LITERAL 356 "ase" "ase"

SimpleName:IDENTIFIER 357 amazonSQSClient amazonSQSClient

SimpleName:IDENTIFIER 357 getQueueUrl getQueueUrl

SimpleName:IDENTIFIER 357 getQueueUrlRequest getQueueUrlRequest

SimpleName:IDENTIFIER 359 wrapper wrapper

SimpleName:IDENTIFIER 359 queueExists queueExists

@Test(expected = JMSException.class)
public void testQueueExistsThrowAmazonServiceException() throws JMSException {
    GetQueueUrlRequest getQueueUrlRequest = new GetQueueUrlRequest(QUEUE_NAME);
    doThrow(new AmazonServiceException("ase")).when(amazonSQSClient).getQueueUrl(eq(getQueueUrlRequest));
    wrapper.queueExists(QUEUE_NAME);
}


SimpleName:IDENTIFIER 411 expected expected

SimpleName:IDENTIFIER 411 JMSException JMSException

SimpleName:IDENTIFIER 412 JMSException JMSException

SimpleName:IDENTIFIER 414 createQueueRequest createQueueRequest

SimpleName:IDENTIFIER 414 CreateQueueRequest CreateQueueRequest

SimpleName:IDENTIFIER 415 doThrow doThrow

SimpleName:IDENTIFIER 415 AmazonClientException AmazonClientException

StringLiteralExpr:LITERAL 415 "ace" "ace"

SimpleName:IDENTIFIER 416 amazonSQSClient amazonSQSClient

SimpleName:IDENTIFIER 416 createQueue createQueue

SimpleName:IDENTIFIER 416 createQueueRequest createQueueRequest

SimpleName:IDENTIFIER 418 wrapper wrapper

SimpleName:IDENTIFIER 418 createQueue createQueue

SimpleName:IDENTIFIER 418 createQueueRequest createQueueRequest

@Test(expected = JMSException.class)
public void testCreateQueueThrowAmazonClientException() throws JMSException {
    CreateQueueRequest createQueueRequest = new CreateQueueRequest(QUEUE_NAME);
    doThrow(new AmazonClientException("ace")).when(amazonSQSClient).createQueue(eq(createQueueRequest));
    wrapper.createQueue(createQueueRequest);
}

SimpleName:IDENTIFIER 424 expected expected

SimpleName:IDENTIFIER 424 JMSException JMSException

SimpleName:IDENTIFIER 425 JMSException JMSException

SimpleName:IDENTIFIER 428 createQueueRequest createQueueRequest

SimpleName:IDENTIFIER 428 CreateQueueRequest CreateQueueRequest

SimpleName:IDENTIFIER 429 doThrow doThrow

SimpleName:IDENTIFIER 429 AmazonServiceException AmazonServiceException

StringLiteralExpr:LITERAL 429 "ase" "ase"

SimpleName:IDENTIFIER 430 amazonSQSClient amazonSQSClient

SimpleName:IDENTIFIER 430 createQueue createQueue

SimpleName:IDENTIFIER 430 createQueueRequest createQueueRequest

SimpleName:IDENTIFIER 432 wrapper wrapper

SimpleName:IDENTIFIER 432 createQueue createQueue

SimpleName:IDENTIFIER 432 createQueueRequest createQueueRequest

@Test(expected = JMSException.class)
public void testCreateQueueThrowAmazonServiceException() throws JMSException {
    CreateQueueRequest createQueueRequest = new CreateQueueRequest(QUEUE_NAME);
    doThrow(new AmazonServiceException("ase")).when(amazonSQSClient).createQueue(eq(createQueueRequest));
    wrapper.createQueue(createQueueRequest);
}


SimpleName:IDENTIFIER 449 expected expected

SimpleName:IDENTIFIER 449 JMSException JMSException

SimpleName:IDENTIFIER 450 JMSException JMSException

SimpleName:IDENTIFIER 452 getQueueUrlRequest getQueueUrlRequest

SimpleName:IDENTIFIER 452 ReceiveMessageRequest ReceiveMessageRequest

SimpleName:IDENTIFIER 453 doThrow doThrow

SimpleName:IDENTIFIER 453 AmazonClientException AmazonClientException

StringLiteralExpr:LITERAL 453 "ace" "ace"

SimpleName:IDENTIFIER 454 amazonSQSClient amazonSQSClient

SimpleName:IDENTIFIER 454 receiveMessage receiveMessage

SimpleName:IDENTIFIER 454 getQueueUrlRequest getQueueUrlRequest

SimpleName:IDENTIFIER 456 wrapper wrapper

SimpleName:IDENTIFIER 456 receiveMessage receiveMessage

SimpleName:IDENTIFIER 456 getQueueUrlRequest getQueueUrlRequest

@Test(expected = JMSException.class)
public void testReceiveMessageThrowAmazonClientException() throws JMSException {
    ReceiveMessageRequest getQueueUrlRequest = new ReceiveMessageRequest();
    doThrow(new AmazonClientException("ace")).when(amazonSQSClient).receiveMessage(eq(getQueueUrlRequest));
    wrapper.receiveMessage(getQueueUrlRequest);
}

SimpleName:IDENTIFIER 462 expected expected

SimpleName:IDENTIFIER 462 JMSException JMSException

SimpleName:IDENTIFIER 463 JMSException JMSException

SimpleName:IDENTIFIER 465 getQueueUrlRequest getQueueUrlRequest

SimpleName:IDENTIFIER 465 ReceiveMessageRequest ReceiveMessageRequest

SimpleName:IDENTIFIER 466 doThrow doThrow

SimpleName:IDENTIFIER 466 AmazonServiceException AmazonServiceException

StringLiteralExpr:LITERAL 466 "ase" "ase"

SimpleName:IDENTIFIER 467 amazonSQSClient amazonSQSClient

SimpleName:IDENTIFIER 467 receiveMessage receiveMessage

SimpleName:IDENTIFIER 467 getQueueUrlRequest getQueueUrlRequest

SimpleName:IDENTIFIER 469 wrapper wrapper

SimpleName:IDENTIFIER 469 receiveMessage receiveMessage

SimpleName:IDENTIFIER 469 getQueueUrlRequest getQueueUrlRequest

@Test(expected = JMSException.class)
public void testReceiveMessageThrowAmazonServiceException() throws JMSException {
    ReceiveMessageRequest getQueueUrlRequest = new ReceiveMessageRequest();
    doThrow(new AmazonServiceException("ase")).when(amazonSQSClient).receiveMessage(eq(getQueueUrlRequest));
    wrapper.receiveMessage(getQueueUrlRequest);
}


SimpleName:IDENTIFIER 486 expected expected

SimpleName:IDENTIFIER 486 JMSException JMSException

SimpleName:IDENTIFIER 487 JMSException JMSException

SimpleName:IDENTIFIER 489 changeMessageVisibilityRequest changeMessageVisibilityRequest

SimpleName:IDENTIFIER 489 ChangeMessageVisibilityRequest ChangeMessageVisibilityRequest

SimpleName:IDENTIFIER 490 doThrow doThrow

SimpleName:IDENTIFIER 490 AmazonClientException AmazonClientException

StringLiteralExpr:LITERAL 490 "ace" "ace"

SimpleName:IDENTIFIER 491 amazonSQSClient amazonSQSClient

SimpleName:IDENTIFIER 491 changeMessageVisibility changeMessageVisibility

SimpleName:IDENTIFIER 491 changeMessageVisibilityRequest changeMessageVisibilityRequest

SimpleName:IDENTIFIER 493 wrapper wrapper

SimpleName:IDENTIFIER 493 changeMessageVisibility changeMessageVisibility

SimpleName:IDENTIFIER 493 changeMessageVisibilityRequest changeMessageVisibilityRequest

@Test(expected = JMSException.class)
public void testChangeMessageVisibilityThrowAmazonClientException() throws JMSException {
    ChangeMessageVisibilityRequest changeMessageVisibilityRequest = new ChangeMessageVisibilityRequest();
    doThrow(new AmazonClientException("ace")).when(amazonSQSClient).changeMessageVisibility(eq(changeMessageVisibilityRequest));
    wrapper.changeMessageVisibility(changeMessageVisibilityRequest);
}

SimpleName:IDENTIFIER 499 expected expected

SimpleName:IDENTIFIER 499 JMSException JMSException

SimpleName:IDENTIFIER 500 JMSException JMSException

SimpleName:IDENTIFIER 502 changeMessageVisibilityRequest changeMessageVisibilityRequest

SimpleName:IDENTIFIER 502 ChangeMessageVisibilityRequest ChangeMessageVisibilityRequest

SimpleName:IDENTIFIER 503 doThrow doThrow

SimpleName:IDENTIFIER 503 AmazonServiceException AmazonServiceException

StringLiteralExpr:LITERAL 503 "ase" "ase"

SimpleName:IDENTIFIER 504 amazonSQSClient amazonSQSClient

SimpleName:IDENTIFIER 504 changeMessageVisibility changeMessageVisibility

SimpleName:IDENTIFIER 504 changeMessageVisibilityRequest changeMessageVisibilityRequest

SimpleName:IDENTIFIER 506 wrapper wrapper

SimpleName:IDENTIFIER 506 changeMessageVisibility changeMessageVisibility

SimpleName:IDENTIFIER 506 changeMessageVisibilityRequest changeMessageVisibilityRequest

@Test(expected = JMSException.class)
public void testChangeMessageVisibilityThrowAmazonServiceException() throws JMSException {
    ChangeMessageVisibilityRequest changeMessageVisibilityRequest = new ChangeMessageVisibilityRequest();
    doThrow(new AmazonServiceException("ase")).when(amazonSQSClient).changeMessageVisibility(eq(changeMessageVisibilityRequest));
    wrapper.changeMessageVisibility(changeMessageVisibilityRequest);
}


SimpleName:IDENTIFIER 523 expected expected

SimpleName:IDENTIFIER 523 JMSException JMSException

SimpleName:IDENTIFIER 524 JMSException JMSException

SimpleName:IDENTIFIER 526 changeMessageVisibilityBatchRequest changeMessageVisibilityBatchRequest

SimpleName:IDENTIFIER 526 ChangeMessageVisibilityBatchRequest ChangeMessageVisibilityBatchRequest

SimpleName:IDENTIFIER 527 doThrow doThrow

SimpleName:IDENTIFIER 527 AmazonClientException AmazonClientException

StringLiteralExpr:LITERAL 527 "ace" "ace"

SimpleName:IDENTIFIER 528 amazonSQSClient amazonSQSClient

SimpleName:IDENTIFIER 528 changeMessageVisibilityBatch changeMessageVisibilityBatch

SimpleName:IDENTIFIER 528 changeMessageVisibilityBatchRequest changeMessageVisibilityBatchRequest

SimpleName:IDENTIFIER 530 wrapper wrapper

SimpleName:IDENTIFIER 530 changeMessageVisibilityBatch changeMessageVisibilityBatch

SimpleName:IDENTIFIER 530 changeMessageVisibilityBatchRequest changeMessageVisibilityBatchRequest

@Test(expected = JMSException.class)
public void testChangeMessageVisibilityBatchThrowAmazonClientException() throws JMSException {
    ChangeMessageVisibilityBatchRequest changeMessageVisibilityBatchRequest = new ChangeMessageVisibilityBatchRequest();
    doThrow(new AmazonClientException("ace")).when(amazonSQSClient).changeMessageVisibilityBatch(eq(changeMessageVisibilityBatchRequest));
    wrapper.changeMessageVisibilityBatch(changeMessageVisibilityBatchRequest);
}

SimpleName:IDENTIFIER 536 expected expected

SimpleName:IDENTIFIER 536 JMSException JMSException

SimpleName:IDENTIFIER 537 JMSException JMSException

SimpleName:IDENTIFIER 539 changeMessageVisibilityBatchRequest changeMessageVisibilityBatchRequest

SimpleName:IDENTIFIER 539 ChangeMessageVisibilityBatchRequest ChangeMessageVisibilityBatchRequest

SimpleName:IDENTIFIER 540 doThrow doThrow

SimpleName:IDENTIFIER 540 AmazonServiceException AmazonServiceException

StringLiteralExpr:LITERAL 540 "ase" "ase"

SimpleName:IDENTIFIER 541 amazonSQSClient amazonSQSClient

SimpleName:IDENTIFIER 541 changeMessageVisibilityBatch changeMessageVisibilityBatch

SimpleName:IDENTIFIER 541 changeMessageVisibilityBatchRequest changeMessageVisibilityBatchRequest

SimpleName:IDENTIFIER 543 wrapper wrapper

SimpleName:IDENTIFIER 543 changeMessageVisibilityBatch changeMessageVisibilityBatch

SimpleName:IDENTIFIER 543 changeMessageVisibilityBatchRequest changeMessageVisibilityBatchRequest

@Test(expected = JMSException.class)
public void testChangeMessageVisibilityBatchThrowAmazonServiceException() throws JMSException {
    ChangeMessageVisibilityBatchRequest changeMessageVisibilityBatchRequest = new ChangeMessageVisibilityBatchRequest();
    doThrow(new AmazonServiceException("ase")).when(amazonSQSClient).changeMessageVisibilityBatch(eq(changeMessageVisibilityBatchRequest));
    wrapper.changeMessageVisibilityBatch(changeMessageVisibilityBatchRequest);
}


SimpleName:IDENTIFIER 275 testSendInternalNonSQSMessage testSendInternalNonSQSMessage

SimpleName:IDENTIFIER 275 JMSException JMSException

SimpleName:IDENTIFIER 277 Message Message

SimpleName:IDENTIFIER 280 producer producer

SimpleName:IDENTIFIER 280 sendInternal sendInternal

SimpleName:IDENTIFIER 280 destination destination

@Test
public void testSendInternalNonSQSMessage() throws JMSException {
    Message msg = mock(Message.class);
    producer.sendInternal(destination, msg);
}

@Test(expected = JMSException.class)
public void testSendInternalNonSQSMessage() throws JMSException {
    Message msg = mock(Message.class);
    producer.sendInternal(destination, msg);
}

package com.amazon.sqs.javamessaging;

import com.amazon.sqs.javamessaging.AmazonSQSMessagingClientWrapper;
import com.amazon.sqs.javamessaging.SQSConnection;
import com.amazon.sqs.javamessaging.SQSMessageProducer;
import com.amazon.sqs.javamessaging.SQSQueueDestination;
import com.amazon.sqs.javamessaging.SQSSession;
import com.amazon.sqs.javamessaging.acknowledge.Acknowledger;
import com.amazon.sqs.javamessaging.message.SQSBytesMessage;
import com.amazon.sqs.javamessaging.message.SQSMessage;
import com.amazon.sqs.javamessaging.message.SQSObjectMessage;
import com.amazon.sqs.javamessaging.message.SQSTextMessage;
import com.amazonaws.services.sqs.model.DeleteMessageRequest;
import com.amazonaws.services.sqs.model.MessageAttributeValue;
import com.amazonaws.services.sqs.model.SendMessageRequest;
import com.amazonaws.services.sqs.model.SendMessageResult;
import com.amazonaws.util.Base64;
import javax.jms.InvalidDestinationException;
import javax.jms.JMSException;
import javax.jms.IllegalStateException;
import javax.jms.Message;
import javax.jms.Queue;
import javax.jms.Destination;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import org.junit.Before;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
import org.mockito.ArgumentMatcher;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.argThat;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

public class adhoc_SQSMessageProducerTest {

    public static final String QUEUE_URL = "QueueUrl";

    public static final String QUEUE_NAME = "QueueName";

    public static final String MESSAGE_ID_1 = "MessageId1";

    public static final String MESSAGE_ID_2 = "MessageId2";

    private SQSMessageProducer producer;

    private SQSQueueDestination destination;

    private SQSSession sqsSession;

    private SQSConnection sqsConnection;

    private AmazonSQSMessagingClientWrapper amazonSQSClient;

    private Acknowledger acknowledger;

    @Before
    public void setup() throws JMSException {
        amazonSQSClient = mock(AmazonSQSMessagingClientWrapper.class);
        sqsConnection = mock(SQSConnection.class);
        acknowledger = mock(Acknowledger.class);
        sqsSession = mock(SQSSession.class);
        destination = new SQSQueueDestination(QUEUE_NAME, QUEUE_URL);
        producer = spy(new SQSMessageProducer(amazonSQSClient, sqsSession, destination));
    }

    public void internalTestPropertyToMessageAttribute(SQSMessage sqsText) throws JMSException {
        String booleanProperty = "BooleanProperty";
        String byteProperty = "ByteProperty";
        String shortProperty = "ShortProperty";
        String intProperty = "IntProperty";
        String longProperty = "LongProperty";
        String floatProperty = "FloatProperty";
        String doubleProperty = "DoubleProperty";
        String stringProperty = "StringProperty";
        String objectProperty = "ObjectProperty";
        sqsText.setBooleanProperty(booleanProperty, true);
        sqsText.setByteProperty(byteProperty, (byte) 1);
        sqsText.setShortProperty(shortProperty, (short) 2);
        sqsText.setIntProperty(intProperty, 3);
        sqsText.setLongProperty(longProperty, 4L);
        sqsText.setFloatProperty(floatProperty, (float) 5.0);
        sqsText.setDoubleProperty(doubleProperty, 6.0);
        sqsText.setStringProperty(stringProperty, "seven");
        sqsText.setObjectProperty(objectProperty, new Integer(8));
        MessageAttributeValue messageAttributeValueBoolean = new MessageAttributeValue();
        messageAttributeValueBoolean.setDataType("Number.Boolean");
        messageAttributeValueBoolean.setStringValue("1");
        MessageAttributeValue messageAttributeValueByte = new MessageAttributeValue();
        messageAttributeValueByte.setDataType("Number.byte");
        messageAttributeValueByte.setStringValue("1");
        MessageAttributeValue messageAttributeValueShort = new MessageAttributeValue();
        messageAttributeValueShort.setDataType("Number.short");
        messageAttributeValueShort.setStringValue("2");
        MessageAttributeValue messageAttributeValueInt = new MessageAttributeValue();
        messageAttributeValueInt.setDataType("Number.int");
        messageAttributeValueInt.setStringValue("3");
        MessageAttributeValue messageAttributeValueLong = new MessageAttributeValue();
        messageAttributeValueLong.setDataType("Number.long");
        messageAttributeValueLong.setStringValue("4");
        MessageAttributeValue messageAttributeValueFloat = new MessageAttributeValue();
        messageAttributeValueFloat.setDataType("Number.float");
        messageAttributeValueFloat.setStringValue("5.0");
        MessageAttributeValue messageAttributeValueDouble = new MessageAttributeValue();
        messageAttributeValueDouble.setDataType("Number.double");
        messageAttributeValueDouble.setStringValue("6.0");
        MessageAttributeValue messageAttributeValueString = new MessageAttributeValue();
        messageAttributeValueString.setDataType("String");
        messageAttributeValueString.setStringValue("seven");
        MessageAttributeValue messageAttributeValueObject = new MessageAttributeValue();
        messageAttributeValueObject.setDataType("Number.int");
        messageAttributeValueObject.setStringValue("8");
        MessageAttributeValue messageAttributeValueJMSSQSMessageType = new MessageAttributeValue();
        messageAttributeValueJMSSQSMessageType.setDataType("String");
        messageAttributeValueJMSSQSMessageType.setStringValue("text");
        Map<String, MessageAttributeValue> messageAttribute = producer.propertyToMessageAttribute(sqsText);
        assertEquals(messageAttributeValueBoolean, messageAttribute.get(booleanProperty));
        assertEquals(messageAttributeValueByte, messageAttribute.get(byteProperty));
        assertEquals(messageAttributeValueShort, messageAttribute.get(shortProperty));
        assertEquals(messageAttributeValueInt, messageAttribute.get(intProperty));
        assertEquals(messageAttributeValueLong, messageAttribute.get(longProperty));
        assertEquals(messageAttributeValueFloat, messageAttribute.get(floatProperty));
        assertEquals(messageAttributeValueDouble, messageAttribute.get(doubleProperty));
        assertEquals(messageAttributeValueString, messageAttribute.get(stringProperty));
        assertEquals(messageAttributeValueObject, messageAttribute.get(objectProperty));
    }

    private Map<String, MessageAttributeValue> createMessageAttribute(String type) {
        MessageAttributeValue messageAttributeValue = new MessageAttributeValue();
        messageAttributeValue.setDataType("String");
        messageAttributeValue.setStringValue(type);
        Map<String, MessageAttributeValue> messageAttributes = new HashMap<String, MessageAttributeValue>();
        messageAttributes.put(SQSMessage.JMS_SQS_MESSAGE_TYPE, messageAttributeValue);
        return messageAttributes;
    }

    private class sendMessageRequestMatcher extends ArgumentMatcher<SendMessageRequest> {

        private String queueUrl;

        private List<String> messagesBody;

        private Map<String, MessageAttributeValue> messageAttributes;

        private sendMessageRequestMatcher(String queueUrl, List<String> messagesBody, Map<String, MessageAttributeValue> messageAttributes) {
            this.queueUrl = queueUrl;
            this.messagesBody = messagesBody;
            this.messageAttributes = messageAttributes;
        }

        @Override
        public boolean matches(Object argument) {
            if (!(argument instanceof SendMessageRequest)) {
                return false;
            }
            SendMessageRequest reqeust = (SendMessageRequest) argument;
            assertEquals(queueUrl, reqeust.getQueueUrl());
            assertTrue(messagesBody.contains(reqeust.getMessageBody()));
            assertEquals(messageAttributes, reqeust.getMessageAttributes());
            return true;
        }
    }
    /*TEST PLACEHOLDER*/
}

Test sendInternal input of Non SQS message

SimpleName:IDENTIFIER 308 testSendInternalNoMessageBody testSendInternalNoMessageBody

SimpleName:IDENTIFIER 308 JMSException JMSException

SimpleName:IDENTIFIER 310 SQSMessage SQSMessage

SimpleName:IDENTIFIER 313 producer producer

SimpleName:IDENTIFIER 313 sendInternal sendInternal

SimpleName:IDENTIFIER 313 destination destination

@Test
public void testSendInternalNoMessageBody() throws JMSException {
    SQSMessage msg = mock(SQSMessage.class);
    producer.sendInternal(destination, msg);
}

@Test(expected = JMSException.class)
public void testSendInternalNoMessageBody() throws JMSException {
    SQSMessage msg = mock(SQSMessage.class);
    producer.sendInternal(destination, msg);
}

Test sendInternal input that SQSMessage is not a valid input


SimpleName:IDENTIFIER 577 testSendNonSQSDestination testSendNonSQSDestination

SimpleName:IDENTIFIER 577 JMSException JMSException

SimpleName:IDENTIFIER 581 SQSTextMessage SQSTextMessage

StringLiteralExpr:LITERAL 581 "MyText" "MyText"

SimpleName:IDENTIFIER 584 producer producer

@Test
public void testSendNonSQSDestination() throws JMSException {
    Queue queue = mock(Queue.class);
    SQSTextMessage msg = spy(new SQSTextMessage("MyText"));
    producer.send(queue, msg);
}

@Test(expected = InvalidDestinationException.class)
public void testSendNonSQSDestination() throws JMSException {
    Queue queue = mock(Queue.class);
    SQSTextMessage msg = spy(new SQSTextMessage("MyText"));
    producer.send(queue, msg);
}

Test send with non SQSDestination


SimpleName:IDENTIFIER 610 testSendDestinationAlreadySpecified testSendDestinationAlreadySpecified

SimpleName:IDENTIFIER 610 JMSException JMSException

SimpleName:IDENTIFIER 612 SQSTextMessage SQSTextMessage

StringLiteralExpr:LITERAL 612 "MyText" "MyText"

SimpleName:IDENTIFIER 615 producer producer

SimpleName:IDENTIFIER 615 destination destination

@Test
public void testSendDestinationAlreadySpecified() throws JMSException {
    SQSTextMessage msg = spy(new SQSTextMessage("MyText"));
    producer.send(destination, msg);
}

@Test(expected = UnsupportedOperationException.class)
public void testSendDestinationAlreadySpecified() throws JMSException {
    SQSTextMessage msg = spy(new SQSTextMessage("MyText"));
    producer.send(destination, msg);
}

Test send when destination already specified


SimpleName:IDENTIFIER 724 testSetDeliveryDelayInvalidDelays testSetDeliveryDelayInvalidDelays

SimpleName:IDENTIFIER 724 JMSException JMSException

SimpleName:IDENTIFIER 726 producer producer

SimpleName:IDENTIFIER 726 setDeliveryDelay setDeliveryDelay

@Test
public void testSetDeliveryDelayInvalidDelays() throws JMSException {
    producer.setDeliveryDelay(-1);
}

@Test(expected = IllegalArgumentException.class)
public void testSetDeliveryDelayInvalidDelays() throws JMSException {
    producer.setDeliveryDelay(-1);
}


SimpleName:IDENTIFIER 401 testWriteObject testWriteObject

SimpleName:IDENTIFIER 401 JMSException JMSException

SimpleName:IDENTIFIER 401 IOException IOException

SimpleName:IDENTIFIER 402 SQSBytesMessage SQSBytesMessage

SQSBytesMessage msg = new SQSBytesMessage()

SimpleName:IDENTIFIER 404 byteArray byteArray

byteArray = new byte[] { 1, 0, 'a', 65 }

SimpleName:IDENTIFIER 405 byteData byteData

SimpleName:IDENTIFIER 406 shortVal shortVal

SimpleName:IDENTIFIER 408 writeObject writeObject

SimpleName:IDENTIFIER 408 byteArray byteArray

SimpleName:IDENTIFIER 409 writeObject writeObject

SimpleName:IDENTIFIER 410 writeObject writeObject

BooleanLiteralExpr:LITERAL 410 true true

SimpleName:IDENTIFIER 411 writeObject writeObject

SimpleName:IDENTIFIER 412 writeObject writeObject

SimpleName:IDENTIFIER 413 writeObject writeObject

SimpleName:IDENTIFIER 414 writeObject writeObject

SimpleName:IDENTIFIER 415 writeObject writeObject

SimpleName:IDENTIFIER 415 shortVal shortVal

SimpleName:IDENTIFIER 416 writeObject writeObject

SimpleName:IDENTIFIER 416 byteData byteData

SimpleName:IDENTIFIER 417 writeObject writeObject

StringLiteralExpr:LITERAL 417 "test" "test"

SimpleName:IDENTIFIER 421 getBodyLength getBodyLength

SimpleName:IDENTIFIER 423 readBytes readBytes

StringLiteralExpr:LITERAL
425
"failed to readByte"
"failed to readByte"

SimpleName:IDENTIFIER 428 message message

SimpleName:IDENTIFIER 428 Message Message

SimpleName:IDENTIFIER 429 message message

SimpleName:IDENTIFIER 429 setBody setBody

SimpleName:IDENTIFIER 429 encodeAsString encodeAsString

SimpleName:IDENTIFIER 431 message message

SimpleName:IDENTIFIER 431 setAttributes setAttributes

SimpleName:IDENTIFIER 432 receivedByteMsg receivedByteMsg

SimpleName:IDENTIFIER 432 SQSBytesMessage SQSBytesMessage

SimpleName:IDENTIFIER 432 message message

SimpleName:IDENTIFIER 434 receivedByteMsg receivedByteMsg

SimpleName:IDENTIFIER 434 readBytes readBytes

SimpleName:IDENTIFIER 436 assertEquals assertEquals

SimpleName:IDENTIFIER 437 assertEquals assertEquals

SimpleName:IDENTIFIER 438 assertEquals assertEquals

SimpleName:IDENTIFIER 439 assertEquals assertEquals

SimpleName:IDENTIFIER 440 assertEquals assertEquals

SimpleName:IDENTIFIER 440 receivedByteMsg receivedByteMsg

SimpleName:IDENTIFIER 440 readChar readChar

SimpleName:IDENTIFIER 441 assertTrue assertTrue

SimpleName:IDENTIFIER 441 receivedByteMsg receivedByteMsg

SimpleName:IDENTIFIER 441 readBoolean readBoolean

SimpleName:IDENTIFIER 442 assertEquals assertEquals

SimpleName:IDENTIFIER 442 receivedByteMsg receivedByteMsg

SimpleName:IDENTIFIER 442 readInt readInt

SimpleName:IDENTIFIER 443 assertEquals assertEquals

SimpleName:IDENTIFIER 443 receivedByteMsg receivedByteMsg

SimpleName:IDENTIFIER 443 readDouble readDouble

SimpleName:IDENTIFIER 444 assertEquals assertEquals

SimpleName:IDENTIFIER 444 receivedByteMsg receivedByteMsg

SimpleName:IDENTIFIER 444 readFloat readFloat

SimpleName:IDENTIFIER 445 assertEquals assertEquals

SimpleName:IDENTIFIER 445 receivedByteMsg receivedByteMsg

SimpleName:IDENTIFIER 445 readLong readLong

SimpleName:IDENTIFIER 446 assertEquals assertEquals

SimpleName:IDENTIFIER 446 shortVal shortVal

SimpleName:IDENTIFIER 446 receivedByteMsg receivedByteMsg

SimpleName:IDENTIFIER 446 readShort readShort

SimpleName:IDENTIFIER 447 assertEquals assertEquals

SimpleName:IDENTIFIER 447 receivedByteMsg receivedByteMsg

SimpleName:IDENTIFIER 447 readByte readByte

SimpleName:IDENTIFIER 448 assertEquals assertEquals

StringLiteralExpr:LITERAL 448 "test" "test"

SimpleName:IDENTIFIER 448 receivedByteMsg receivedByteMsg

SimpleName:IDENTIFIER 448 readUTF readUTF

SimpleName:IDENTIFIER 454 writeObject writeObject

SimpleName:IDENTIFIER 454 HashSet HashSet

@Test
public void testWriteObject() throws JMSException, IOException {
    SQSBytesMessage msg = new SQSBytesMessage();
    byte[] byteArray = new byte[] { 1, 0, 'a', 65 };
    byte byteData = 'a';
    short shortVal = 123;
    msg.writeObject(byteArray);
    msg.writeObject('b');
    msg.writeObject(true);
    msg.writeObject(100);
    msg.writeObject(2.1768);
    msg.writeObject(3.1457f);
    msg.writeObject(1290772974281L);
    msg.writeObject(shortVal);
    msg.writeObject(byteData);
    msg.writeObject("test");
    msg.reset();
    int length = (int) msg.getBodyLength();
    byte[] body = new byte[length];
    int i = msg.readBytes(body);
    if (i == -1) {
        fail("failed to readByte");
    }
    Message message = new Message();
    message.setBody(Base64.encodeAsString(body));
    message.setAttributes(MESSAGE_SYSTEM_ATTRIBUTES);
    SQSBytesMessage receivedByteMsg = new SQSBytesMessage(null, "", message);
    byte[] byteArray1 = new byte[4];
    receivedByteMsg.readBytes(byteArray1);
    assertEquals(1, byteArray1[0]);
    assertEquals(0, byteArray1[1]);
    assertEquals('a', byteArray1[2]);
    assertEquals(65, byteArray1[3]);
    assertEquals('b', receivedByteMsg.readChar());
    assertTrue(receivedByteMsg.readBoolean());
    assertEquals(100, receivedByteMsg.readInt());
    assertEquals(2.1768, receivedByteMsg.readDouble(), 0);
    assertEquals(3.1457f, receivedByteMsg.readFloat(), 0);
    assertEquals(1290772974281L, receivedByteMsg.readLong());
    assertEquals(shortVal, receivedByteMsg.readShort());
    assertEquals(97, receivedByteMsg.readByte());
    assertEquals("test", receivedByteMsg.readUTF());
    msg.writeObject(new HashSet<String>());
}

@Test(expected = MessageFormatException.class)
public void testWriteObject() throws JMSException, IOException {
    SQSBytesMessage msg = new SQSBytesMessage();
    byte[] byteArray = new byte[] { 1, 0, 'a', 65 };
    byte byteData = 'a';
    short shortVal = 123;
    msg.writeObject(byteArray);
    msg.writeObject('b');
    msg.writeObject(true);
    msg.writeObject(100);
    msg.writeObject(2.1768);
    msg.writeObject(3.1457f);
    msg.writeObject(1290772974281L);
    msg.writeObject(shortVal);
    msg.writeObject(byteData);
    msg.writeObject("test");
    msg.reset();
    int length = (int) msg.getBodyLength();
    byte[] body = new byte[length];
    int i = msg.readBytes(body);
    if (i == -1) {
        fail("failed to readByte");
    }
    Message message = new Message();
    message.setBody(Base64.encodeAsString(body));
    message.setAttributes(MESSAGE_SYSTEM_ATTRIBUTES);
    SQSBytesMessage receivedByteMsg = new SQSBytesMessage(null, "", message);
    byte[] byteArray1 = new byte[4];
    receivedByteMsg.readBytes(byteArray1);
    assertEquals(1, byteArray1[0]);
    assertEquals(0, byteArray1[1]);
    assertEquals('a', byteArray1[2]);
    assertEquals(65, byteArray1[3]);
    assertEquals('b', receivedByteMsg.readChar());
    assertTrue(receivedByteMsg.readBoolean());
    assertEquals(100, receivedByteMsg.readInt());
    assertEquals(2.1768, receivedByteMsg.readDouble(), 0);
    assertEquals(3.1457f, receivedByteMsg.readFloat(), 0);
    assertEquals(1290772974281L, receivedByteMsg.readLong());
    assertEquals(shortVal, receivedByteMsg.readShort());
    assertEquals(97, receivedByteMsg.readByte());
    assertEquals("test", receivedByteMsg.readUTF());
    msg.writeObject(new HashSet<String>());
}

package com.amazon.sqs.javamessaging.message;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyBoolean;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.when;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import javax.jms.JMSException;
import javax.jms.MessageEOFException;
import javax.jms.MessageFormatException;
import javax.jms.MessageNotReadableException;
import javax.jms.MessageNotWriteableException;
import org.junit.Before;
import org.junit.Test;
import com.amazon.sqs.javamessaging.SQSMessagingClientConstants;
import com.amazon.sqs.javamessaging.SQSSession;
import com.amazon.sqs.javamessaging.message.SQSBytesMessage;
import com.amazonaws.util.Base64;
import com.amazonaws.services.sqs.model.Message;

public class adhoc_SQSBytesMessageTest {

    private SQSSession mockSQSSession;

    private final static Map<String, String> MESSAGE_SYSTEM_ATTRIBUTES;

    static {
        MESSAGE_SYSTEM_ATTRIBUTES = new HashMap<String, String>();
        MESSAGE_SYSTEM_ATTRIBUTES.put(SQSMessagingClientConstants.APPROXIMATE_RECEIVE_COUNT, "1");
    }

    @Before
    public void setUp() {
        mockSQSSession = mock(SQSSession.class);
    }
    /*TEST PLACEHOLDER*/
}

Test write object function


SimpleName:IDENTIFIER 71 testUnsupportedFeatures testUnsupportedFeatures

SimpleName:IDENTIFIER 74 sqsConnection sqsConnection

SimpleName:IDENTIFIER 74 createConnectionConsumer createConnectionConsumer

SimpleName:IDENTIFIER 74 destination destination

StringLiteralExpr:LITERAL 74 "messageSelector" "messageSelector"

@Test
public void testUnsupportedFeatures() {
    sqsConnection.createConnectionConsumer(destination, "messageSelector", null, 10);
}

@Test(expected = JMSException.class)
public void testUnsupportedFeatures() {
    sqsConnection.createConnectionConsumer(destination, "messageSelector", null, 10);
}

package com.amazon.sqs.javamessaging;

import javax.jms.*;
import javax.jms.IllegalStateException;
import org.junit.Before;
import org.junit.Test;
import com.amazon.sqs.javamessaging.AmazonSQSMessagingClientWrapper;
import com.amazon.sqs.javamessaging.SQSConnection;
import com.amazon.sqs.javamessaging.SQSQueueDestination;
import com.amazon.sqs.javamessaging.SQSSession;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import static org.junit.Assert.*;
import static org.mockito.Mockito.*;

public class adhoc_SQSConnectionTest {

    public static final String QUEUE_URL = "QueueUrl";

    public static final String QUEUE_NAME = "QueueName";

    private AmazonSQSMessagingClientWrapper amazonSQSClientJMSWrapper;

    private SQSConnection sqsConnection;

    private SQSQueueDestination destination;

    private ScheduledExecutorService executorService = Executors.newScheduledThreadPool(2);

    private SQSSession session1;

    private SQSSession session2;

    @Before
    public void setup() throws JMSException {
        destination = new SQSQueueDestination(QUEUE_NAME, QUEUE_URL);
        int numberOfMessagesToPrefetch = 10;
        amazonSQSClientJMSWrapper = mock(AmazonSQSMessagingClientWrapper.class);
        sqsConnection = spy(new SQSConnection(amazonSQSClientJMSWrapper, numberOfMessagesToPrefetch));
        session1 = mock(SQSSession.class);
        session2 = mock(SQSSession.class);
        sqsConnection.getSessions().add(session1);
        sqsConnection.getSessions().add(session2);
    }
    /*TEST PLACEHOLDER*/
}

Test unsupported features


SimpleName:IDENTIFIER 101 testSetClientIdWhenClosing testSetClientIdWhenClosing

SimpleName:IDENTIFIER 101 JMSException JMSException

SimpleName:IDENTIFIER 103 sqsConnection sqsConnection

SimpleName:IDENTIFIER 103 setClosing setClosing

BooleanLiteralExpr:LITERAL 103 true true

SimpleName:IDENTIFIER 106 sqsConnection sqsConnection

SimpleName:IDENTIFIER 106 setClientID setClientID

StringLiteralExpr:LITERAL 106 "clientId" "clientId"

@Test
public void testSetClientIdWhenClosing() throws JMSException {
    sqsConnection.setClosing(true);
    sqsConnection.setClientID("clientId");
}

@Test(expected = IllegalStateException.class)
public void testSetClientIdWhenClosing() throws JMSException {
    sqsConnection.setClosing(true);
    sqsConnection.setClientID("clientId");
}

Test set client id when connection is closing

SimpleName:IDENTIFIER 170 testClosing testClosing

SimpleName:IDENTIFIER 170 JMSException JMSException

SimpleName:IDENTIFIER 172 sqsConnection sqsConnection

SimpleName:IDENTIFIER 172 checkClosing checkClosing

SimpleName:IDENTIFIER 174 sqsConnection sqsConnection

SimpleName:IDENTIFIER 174 setClosing setClosing

BooleanLiteralExpr:LITERAL 174 true true

SimpleName:IDENTIFIER 176 sqsConnection sqsConnection

SimpleName:IDENTIFIER 176 checkClosing checkClosing

@Test
public void testClosing() throws JMSException {
    sqsConnection.checkClosing();
    sqsConnection.setClosing(true);
    sqsConnection.checkClosing();
}

@Test(expected = IllegalStateException.class)
public void testClosing() throws JMSException {
    sqsConnection.checkClosing();
    sqsConnection.setClosing(true);
    sqsConnection.checkClosing();
}

Test closing

SimpleName:IDENTIFIER 434 testStopWhenClosing testStopWhenClosing

SimpleName:IDENTIFIER 434 JMSException JMSException

SimpleName:IDENTIFIER 434 InterruptedException InterruptedException

SimpleName:IDENTIFIER 439 sqsConnection sqsConnection

SimpleName:IDENTIFIER 439 setClosing setClosing

BooleanLiteralExpr:LITERAL 439 true true

SimpleName:IDENTIFIER 440 sqsConnection sqsConnection

SimpleName:IDENTIFIER 440 setRunning setRunning

BooleanLiteralExpr:LITERAL 440 true true

SimpleName:IDENTIFIER 443 sqsConnection sqsConnection

@Test
public void testStopWhenClosing() throws JMSException, InterruptedException {
    sqsConnection.setClosing(true);
    sqsConnection.setRunning(true);
    sqsConnection.stop();
}

@Test(expected = IllegalStateException.class)
public void testStopWhenClosing() throws JMSException, InterruptedException {
    sqsConnection.setClosing(true);
    sqsConnection.setRunning(true);
    sqsConnection.stop();
}

Test stop when connection is closing

SimpleName:IDENTIFIER 552 testStartNoOpIfClosing testStartNoOpIfClosing

SimpleName:IDENTIFIER 552 JMSException JMSException

SimpleName:IDENTIFIER 557 sqsConnection sqsConnection

SimpleName:IDENTIFIER 557 setClosing setClosing

BooleanLiteralExpr:LITERAL 557 true true

SimpleName:IDENTIFIER 563 sqsConnection sqsConnection

@Test
public void testStartNoOpIfClosing() throws JMSException {
    sqsConnection.setClosing(true);
    sqsConnection.start();
}

@Test(expected = IllegalStateException.class)
public void testStartNoOpIfClosing() throws JMSException {
    sqsConnection.setClosing(true);
    sqsConnection.start();
}

Test start is a no op if closing

SimpleName:IDENTIFIER 728 testCreateSessionWhenClosing testCreateSessionWhenClosing

SimpleName:IDENTIFIER 728 JMSException JMSException

SimpleName:IDENTIFIER 733 sqsConnection sqsConnection

SimpleName:IDENTIFIER 733 setClosing setClosing

BooleanLiteralExpr:LITERAL 733 true true

SimpleName:IDENTIFIER 739 sqsConnection sqsConnection

SimpleName:IDENTIFIER 739 createSession createSession

BooleanLiteralExpr:LITERAL 739 false false

SimpleName:IDENTIFIER 739 Session Session

@Test
public void testCreateSessionWhenClosing() throws JMSException {
    sqsConnection.setClosing(true);
    sqsConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
}

@Test(expected = IllegalStateException.class)
public void testCreateSessionWhenClosing() throws JMSException {
    sqsConnection.setClosing(true);
    sqsConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
}

Test create session when connection is closing


SimpleName:IDENTIFIER 117 testSetClientIdInvalidClientId testSetClientIdInvalidClientId

SimpleName:IDENTIFIER 117 JMSException JMSException

SimpleName:IDENTIFIER 120 sqsConnection sqsConnection

SimpleName:IDENTIFIER 120 setClientID setClientID

{
    sqsConnection.setClientID(null);
}

@Test
public void testSetClientIdInvalidClientId() throws JMSException {
    sqsConnection.setClientID(null);
}

@Test(expected = InvalidClientIDException.class)
public void testSetClientIdInvalidClientId() throws JMSException {
    sqsConnection.setClientID(null);
}

{
    sqsConnection.setClientID(null);
}

Test set client id on an invalid client id

SimpleName:IDENTIFIER 138 testSetClientIdActionTaken testSetClientIdActionTaken

SimpleName:IDENTIFIER 138 JMSException JMSException

SimpleName:IDENTIFIER 140 sqsConnection sqsConnection

SimpleName:IDENTIFIER 140 setActionOnConnectionTaken setActionOnConnectionTaken

BooleanLiteralExpr:LITERAL 140 true true

SimpleName:IDENTIFIER 142 sqsConnection sqsConnection

SimpleName:IDENTIFIER 142 setClientID setClientID

"Client ID cannot be set after any action on the connection is taken"

@Test
public void testSetClientIdActionTaken() throws JMSException {
    sqsConnection.setActionOnConnectionTaken(true);
    sqsConnection.setClientID("id");
}

@Test(expected = IllegalStateException.class)
public void testSetClientIdActionTaken() throws JMSException {
    sqsConnection.setActionOnConnectionTaken(true);
    sqsConnection.setClientID("id");
}

Test set client id when action on connection is already made

SimpleName:IDENTIFIER 153 testSetClientId testSetClientId

SimpleName:IDENTIFIER 153 JMSException JMSException

SimpleName:IDENTIFIER 155 sqsConnection sqsConnection

SimpleName:IDENTIFIER 155 setClientID setClientID

SimpleName:IDENTIFIER 157 sqsConnection sqsConnection

SimpleName:IDENTIFIER 157 setClientID setClientID

@Test
public void testSetClientId() throws JMSException {
    sqsConnection.setClientID("id");
    sqsConnection.setClientID("id2");
}

@Test(expected = IllegalStateException.class)
public void testSetClientId() throws JMSException {
    sqsConnection.setClientID("id");
    sqsConnection.setClientID("id2");
}

Test set client id


SimpleName:IDENTIFIER 187 testCheckClosed testCheckClosed

SimpleName:IDENTIFIER 187 JMSException JMSException

SimpleName:IDENTIFIER 189 sqsConnection sqsConnection

SimpleName:IDENTIFIER 189 checkClosed checkClosed

SimpleName:IDENTIFIER 191 sqsConnection sqsConnection

SimpleName:IDENTIFIER 191 setClosed setClosed

BooleanLiteralExpr:LITERAL 191 true true

SimpleName:IDENTIFIER 193 sqsConnection sqsConnection

SimpleName:IDENTIFIER 193 checkClosed checkClosed

@Test
public void testCheckClosed() throws JMSException {
    sqsConnection.checkClosed();
    sqsConnection.setClosed(true);
    sqsConnection.checkClosed();
}

@Test(expected = IllegalStateException.class)
public void testCheckClosed() throws JMSException {
    sqsConnection.checkClosed();
    sqsConnection.setClosed(true);
    sqsConnection.checkClosed();
}

Test check closed

SimpleName:IDENTIFIER 344 testStopNoOpIfAlreadyClosed testStopNoOpIfAlreadyClosed

SimpleName:IDENTIFIER 344 JMSException JMSException

SimpleName:IDENTIFIER 349 sqsConnection sqsConnection

SimpleName:IDENTIFIER 355 sqsConnection sqsConnection

@Test
public void testStopNoOpIfAlreadyClosed() throws JMSException {
    sqsConnection.close();
    sqsConnection.stop();
}

@Test(expected = IllegalStateException.class)
public void testStopNoOpIfAlreadyClosed() throws JMSException {
    sqsConnection.close();
    sqsConnection.stop();
}

Test stop is a no op if already closed

SimpleName:IDENTIFIER 524 testStartNoOpIfAlreadyClosed testStartNoOpIfAlreadyClosed

SimpleName:IDENTIFIER 524 JMSException JMSException

SimpleName:IDENTIFIER 529 sqsConnection sqsConnection

SimpleName:IDENTIFIER 535 sqsConnection sqsConnection

@Test
public void testStartNoOpIfAlreadyClosed() throws JMSException {
    sqsConnection.close();
    sqsConnection.start();
}

@Test(expected = IllegalStateException.class)
public void testStartNoOpIfAlreadyClosed() throws JMSException {
    sqsConnection.close();
    sqsConnection.start();
}

Test start is a no op if already closed

SimpleName:IDENTIFIER 666 testCreateSessionNoOpIfAlreadyClosed testCreateSessionNoOpIfAlreadyClosed

SimpleName:IDENTIFIER 666 JMSException JMSException

SimpleName:IDENTIFIER 671 sqsConnection sqsConnection

SimpleName:IDENTIFIER 671 setClosed setClosed

BooleanLiteralExpr:LITERAL 671 true true

SimpleName:IDENTIFIER 677 sqsConnection sqsConnection

SimpleName:IDENTIFIER 677 createSession createSession

BooleanLiteralExpr:LITERAL 677 true true

@Test
public void testCreateSessionNoOpIfAlreadyClosed() throws JMSException {
    sqsConnection.setClosed(true);
    sqsConnection.createSession(true, 1);
}

@Test(expected = IllegalStateException.class)
public void testCreateSessionNoOpIfAlreadyClosed() throws JMSException {
    sqsConnection.setClosed(true);
    sqsConnection.createSession(true, 1);
}

Test create session is a no op if already closed