@Test public void testSingleAsmMethod() { String[] lines = SINGLE_ASSEMBLY_METHOD; performAssemblyParsingOn(lines); IMetaMember member = map.get("org.adoptopenjdk.jitwatch.demo.SandboxTestLoad main ([Ljava.lang.String;)V"); assertNotNull(member); AssemblyMethod assemblyMethod = member.getAssembly(); assertNotNull(assemblyMethod); List<AssemblyBlock> asmBlocks = assemblyMethod.getBlocks(); assertEquals(1, asmBlocks.size()); AssemblyBlock block = asmBlocks.get(0); List<AssemblyInstruction> instructions = block.getInstructions(); assertEquals(5, instructions.size()); }
@Test public void onCustomer() { Result<Customer> customerResult = gateway.customer().create(new CustomerRequest().paymentMethodNonce(Nonce.Coinbase)); assertTrue(customerResult.isSuccess()); Customer customer = customerResult.getTarget(); List<CoinbaseAccount> accounts = gateway.customer().find(customer.getId()).getCoinbaseAccounts(); assertEquals(1, accounts.size()); CoinbaseAccount account = accounts.get(0); assertNotNull(account); assertNotNull(account.getToken()); assertNotNull(account.getUserId()); assertThat(account.getUserId(), not(equalTo(""))); assertNotNull(account.getUserName()); assertThat(account.getUserName(), not(equalTo(""))); assertNotNull(account.getUserEmail()); assertThat(account.getUserEmail(), not(equalTo(""))); String token = account.getToken(); gateway.paymentMethod().delete(token); exception.expect(NotFoundException.class); gateway.paymentMethod().find(token); }
@Test public void testLoadRepositoryShouldPass() throws Exception { assertNotNull(applicantRepository); assertNotNull(masCoreSkillRepository); assertNotNull(masJobLevelRepository); assertNotNull(masTechnologyRepository); }
@Test public void simpleMessageListener() { ConfigurableApplicationContext context = new AnnotationConfigApplicationContext(Config.class, SimpleMessageListenerTestBean.class); JmsListenerContainerTestFactory factory = context.getBean(JmsListenerContainerTestFactory.class); assertEquals( "One container should have been registered", 1, factory.getListenerContainers().size()); MessageListenerTestContainer container = factory.getListenerContainers().get(0); JmsListenerEndpoint endpoint = container.getEndpoint(); assertEquals("Wrong endpoint type", MethodJmsListenerEndpoint.class, endpoint.getClass()); MethodJmsListenerEndpoint methodEndpoint = (MethodJmsListenerEndpoint) endpoint; assertNotNull(methodEndpoint.getBean()); assertNotNull(methodEndpoint.getMethod()); SimpleMessageListenerContainer listenerContainer = new SimpleMessageListenerContainer(); methodEndpoint.setupListenerContainer(listenerContainer); assertNotNull(listenerContainer.getMessageListener()); assertTrue("Should have been started " + container, container.isStarted()); context.close(); // Close and stop the listeners assertTrue("Should have been stopped " + container, container.isStopped()); }
@Test public void canVaultOnTransactionCreate() { TransactionRequest request = new TransactionRequest() .amount(TransactionAmount.AUTHORIZE.amount) .paymentMethodNonce(Nonce.Coinbase) .options() .submitForSettlement(true) .storeInVaultOnSuccess(true) .done(); Result<Transaction> authResult = gateway.transaction().sale(request); assertTrue(authResult.isSuccess()); Transaction transaction = authResult.getTarget(); assertNotNull(transaction); CoinbaseDetails details = transaction.getCoinbaseDetails(); assertNotNull(details); String token = details.getToken(); assertNotNull(token); PaymentMethod account = gateway.paymentMethod().find(token); assertTrue(account instanceof CoinbaseAccount); assertNotNull(account); }
@Test public void testExecuteAndFetchWithNulls() { String sql = "create table testExecWithNullsTbl (" + "id int identity primary key, " + "text varchar(255), " + "aNumber int, " + "aLongNumber bigint)"; sql2o.createQuery(sql, "testExecuteAndFetchWithNulls").executeUpdate(); Connection connection = sql2o.beginTransaction(); Query insQuery = connection.createQuery( "insert into testExecWithNullsTbl (text, aNumber, aLongNumber) values(:text, :number, :lnum)"); insQuery .addParameter("text", "some text") .addParameter("number", 2) .addParameter("lnum", 10L) .executeUpdate(); insQuery .addParameter("text", "some text") .addParameter("number", (Integer) null) .addParameter("lnum", 10L) .executeUpdate(); insQuery .addParameter("text", (String) null) .addParameter("number", 21) .addParameter("lnum", (Long) null) .executeUpdate(); insQuery .addParameter("text", "some text") .addParameter("number", 1221) .addParameter("lnum", 10) .executeUpdate(); insQuery .addParameter("text", "some text") .addParameter("number", 2311) .addParameter("lnum", 12) .executeUpdate(); connection.commit(); List<Entity> fetched = sql2o.createQuery("select * from testExecWithNullsTbl").executeAndFetch(Entity.class); assertTrue(fetched.size() == 5); assertNull(fetched.get(2).text); assertNotNull(fetched.get(3).text); assertNull(fetched.get(1).aNumber); assertNotNull(fetched.get(2).aNumber); assertNull(fetched.get(2).aLongNumber); assertNotNull(fetched.get(3).aLongNumber); }
@Test public void testLongProfiling() throws Exception { Logger logger = Logger.getLogger(getClass()); MDC.put(GelfUtil.MDC_REQUEST_START_MS, "" + (System.currentTimeMillis() - 2000)); logger.info(LOG_MESSAGE); assertEquals(1, GelfTestSender.getMessages().size()); GelfMessage gelfMessage = GelfTestSender.getMessages().get(0); assertNotNull(gelfMessage.getField(GelfUtil.MDC_REQUEST_DURATION)); assertNotNull(gelfMessage.getField(GelfUtil.MDC_REQUEST_END)); }
@Test public void testRegistListAndDeleteList() throws Exception { Attendance a = null; Member m = null; Practice p = null; List<Attendance> attendanceList = new ArrayList<Attendance>(); a = new Attendance(); a.setAttendance(1); a.setFinished(false); a.setRacital("It's racital, too."); m = memberSvc.searchFromId("test3"); a.setMemberKey(m.getKey()); p = practiceSvc.searchFromStartDateTime( DateUtil.toDate("2010-10-01T10:00:00", DateUtil.ISO_DATE_TIME_PATTERN)); a.setPracticeKey(p.getKey()); attendanceList.add(a); a = new Attendance(); a.setAttendance(0); a.setFinished(true); a.setRacital("It's racital, too."); m = memberSvc.searchFromId("test3"); a.setMemberKey(m.getKey()); p = practiceSvc.searchFromStartDateTime( DateUtil.toDate("2010-12-01T10:00:00", DateUtil.ISO_DATE_TIME_PATTERN)); a.setPracticeKey(p.getKey()); attendanceList.add(a); attendanceList = service.registList(attendanceList); assertNotNull( service.searchFromMemberIdAndPracticeDate( "test3", DateUtil.toDate("2010-10-01T10:00:00", DateUtil.ISO_DATE_TIME_PATTERN))); assertNotNull( service.searchFromMemberIdAndPracticeDate( "test3", DateUtil.toDate("2010-10-01T10:00:00", DateUtil.ISO_DATE_TIME_PATTERN))); service.deleteList(attendanceList); assertNull( service.searchFromMemberIdAndPracticeDate( "test3", DateUtil.toDate("2010-10-01T10:00:00", DateUtil.ISO_DATE_TIME_PATTERN))); assertNull( service.searchFromMemberIdAndPracticeDate( "test3", DateUtil.toDate("2010-10-01T10:00:00", DateUtil.ISO_DATE_TIME_PATTERN))); }
@Test public void testCheckTagWithApplicantRepositoryShouldReturnListOfJobLevelThatHaveTagSameSetup() throws Exception { List<JoblevelDto> result = applicantRepository.checkTag(applicant.getJobLevel().getTag()); assertNotNull(result); assertThat(result.get(0).getTag(), is("t")); }
@Test public void testReportApplicantWithApplicantRepositoryShouldReturnListOfReportApplicant() throws Exception { List<ReportApplicantDto> result = applicantRepository.reportApplicant(); assertNotNull(result); assertThat(result.size(), is(new GreaterOrEqual<>(1))); }
@Test public void testFindAll() { List<TestEntity> values = Arrays.asList(1, 2) .stream() .map( v -> { TestEntity t = new TestEntity(); t.setStringProperty(String.format("Hello %s time(s)", v)); return t; }) .collect(Collectors.toList()); repository.save(values); List<TestEntity> actual = (List<TestEntity>) repository.findAll(); assertNotNull("Checking that the result is not null.", actual); assertEquals(2, actual.size()); Map<String, TestEntity> expected = values.stream().collect(toMap(TestEntity::getId, Function.identity())); actual.forEach( testEntity -> assertEquals( expected.get(testEntity.getId()).getStringProperty(), testEntity.getStringProperty())); }
@Test public void testFindOne() { List<TestEntity> values = Arrays.asList(1, 2) .stream() .map( v -> { TestEntity t = new TestEntity(); t.setStringProperty(String.format("Hello %s time(s)", v)); return t; }) .collect(Collectors.toList()); repository.save(values); TestEntity actual = repository.findOne(values.get(1).getId()); assertNotNull("Checking that the result is not null.", actual); assertEquals( "Checking that the list is the expected size.", values.get(1).getId(), actual.getId()); assertEquals( "Checking that the list is the expected size.", values.get(1).getStringProperty(), actual.getStringProperty()); }
@Test public void testFindReportByMonthWithApplicantRepositoryShouldReturnListOfReportApplicant() throws Exception { List<ReportApplicantDto> result = applicantRepository.findReportByMonth(startDate, endDate); assertNotNull(result); assertThat(result.size(), is(new GreaterOrEqual<>(1))); }
@Test public void testFields() throws Exception { Logger logger = Logger.getLogger(getClass()); MDC.put("mdcField1", "a value"); MDC.remove(GelfUtil.MDC_REQUEST_START_MS); logger.info(LOG_MESSAGE); assertEquals(1, GelfTestSender.getMessages().size()); GelfMessage gelfMessage = GelfTestSender.getMessages().get(0); assertEquals("fieldValue1", gelfMessage.getField("fieldName1")); assertEquals("fieldValue2", gelfMessage.getField("fieldName2")); assertEquals("a value", gelfMessage.getField("mdcField1")); assertNotNull(gelfMessage.getField(LogMessageField.NamedLogField.SourceLineNumber.name())); assertEquals( "testFields", gelfMessage.getField(LogMessageField.NamedLogField.SourceMethodName.name())); assertEquals( AbstractGelfLogAppenderTest.class.getName(), gelfMessage.getField(LogMessageField.NamedLogField.SourceClassName.name())); assertEquals("a value", gelfMessage.getField("mdcField1")); assertNull(gelfMessage.getField("mdcField2")); assertNull(gelfMessage.getField(GelfUtil.MDC_REQUEST_DURATION)); assertNull(gelfMessage.getField(GelfUtil.MDC_REQUEST_END)); }
@Test public void testFindApplicantByIdWithApplicantRepositoryShouldReturnSetupApplicant() throws Exception { ApplicantDto result = applicantRepository.findApplicantById(applicant.getId()); assertNotNull(result); assertThat(result.getFirstNameEN(), is("Anat")); }
@Override public void testAddService() throws Exception { super.testAddService(); // ensure s.getGeoServer() != null ServiceInfo s = geoServer.getServiceByName("foo", ServiceInfo.class); assertNotNull(s.getGeoServer()); }
@Test public void testSingleAsmMethodInterrupted() { String[] lines = new String[] { "Decoding compiled method 0x00007f7d73363f90:", "Code:", "[Entry Point]", "[Constants]", " # {method} 'add' '(II)I' in 'org", "<writer thread='140176877946624'/>", "<uncommon_trap thread='140176877946624' reason='unloaded' action='reinterpret' index='39' compile_id='2' compile_kind='osr' compiler='C2' unresolved='1' name='java/lang/System' stamp='0.374'>", "<jvms bci='31' method='org/adoptopenjdk/jitwatch/demo/SandboxTestLoad main ([Ljava/lang/String;)V' bytes='57' count='10000' backedge_count='6024' iicount='1'/>", "</uncommon_trap>", "<writer thread='140176736904960'/>", "/adoptopenjdk/jitwatch/demo/SandboxTest'", " # this: rsi:rsi = 'org/adoptopenjdk/jitwatch/demo/SandboxTest'", " # parm0: rdx = int", " # parm1: rcx = int", " # [sp+0x20] (sp of caller)", " 0x00007f7d733640c0: mov 0x8(%rsi),%r10d", " 0x00007f7d733640c4: cmp %r10,%rax", " 0x00007f7d733640c7: jne 0x00007f7d7333b960 ; {runtime_call}", " 0x00007f7d733640cd: data32 xchg %ax,%ax" }; performAssemblyParsingOn(lines); IMetaMember member = map.get("org.adoptopenjdk.jitwatch.demo.SandboxTest add (II)I"); assertNotNull(member); AssemblyMethod assemblyMethod = member.getAssembly(); assertNotNull(assemblyMethod); List<AssemblyBlock> asmBlocks = assemblyMethod.getBlocks(); assertEquals(1, asmBlocks.size()); AssemblyBlock block = asmBlocks.get(0); List<AssemblyInstruction> instructions = block.getInstructions(); assertEquals(4, instructions.size()); }
@Test public void testFindByTrackingStatusWithApplicantRepositoryShouldReturnListOfApplicantThatHaveTrackingStatusSameSetup() throws Exception { List<ApplicantDto> result = applicantRepository.findByTrackingStatus(applicant.getTrackingStatus()); assertNotNull(result); assertThat(result.get(0).getTrackingStatus(), is("Interview")); }
@Test public void testFindByJobLevelWithApplicantRepositoryShouldReturnListOfApplicantThatHaveSetupJobLevel() throws Exception { List<ApplicantDto> result = applicantRepository.findByJoblevel(applicant.getJobLevel().getName()); assertNotNull(result); assertThat(result.get(0).getJoblevelStr(), is("Consultant")); }
@Test public void testFindDefaultVersion() { recreateVersions(); Version version = versionRepository.findDefault(docId); assertNotNull(version); assertThat(version.getDocId(), is(docId)); assertThat(version.getNo(), is(3)); }
@Test public void testSearchFromKey() throws Exception { Member m = memberSvc.searchFromId("test1"); Practice p = practiceSvc.searchFromStartDateTime( DateUtil.toDate("2010-10-01T10:00:00", DateUtil.ISO_DATE_TIME_PATTERN)); assertNotNull(service.searchFromKey(service.generateKey(m.getKey(), p.getKey()))); assertNull(service.searchFromKey(Datastore.createKey(Attendance.class, "XXX"))); assertNull(service.searchFromKey(null)); }
@Test public void testSave() { TestEntity testEntity = new TestEntity(); testEntity.setStringProperty("Hello World!"); TestEntity result = repository.save(testEntity); assertNotNull("Checking that the result is not null.", result); }
@Test public void testUpdateWithApplicantRepositoryShouldReturnApplicantThatUpdated() throws Exception { Applicant update = applicantRepository.find(applicant.getId()); update.setFirstNameEN("AnatUpdate"); applicantRepository.update(update); Applicant result = applicantRepository.find(update.getId()); assertNotNull(result); assertThat(result.getId(), is(update.getId())); assertThat(result.getFirstNameEN(), is("AnatUpdate")); }
@Test public void testCreate() { recreateVersions(); Version version = versionRepository.create(docId, userId); assertNotNull(version); assertThat(version.getDocId(), is(docId)); assertThat(version.getNo(), is(6)); assertThat(version.getCreatedBy(), equalTo(userRepository.findOne(userId))); }
@Test public void canCreateTransaction() { TransactionRequest request = new TransactionRequest() .amount(TransactionAmount.AUTHORIZE.amount) .paymentMethodNonce(Nonce.Coinbase); Result<Transaction> authResult = gateway.transaction().sale(request); assertTrue(authResult.isSuccess()); CoinbaseDetails details = authResult.getTarget().getCoinbaseDetails(); assertNotNull(details); assertNull(details.getToken()); assertNotNull(details.getUserId()); assertThat(details.getUserId(), not(equalTo(""))); assertNotNull(details.getUserName()); assertThat(details.getUserName(), not(equalTo(""))); assertNotNull(details.getUserEmail()); assertThat(details.getUserEmail(), not(equalTo(""))); }
/** Tests the "getBufferFor" method */ @Test public void testComponentAtOffset() { CompositeByteBuf buf = (CompositeByteBuf) wrappedBuffer(new byte[] {1, 2, 3, 4, 5}, new byte[] {4, 5, 6, 7, 8, 9, 26}); // Ensure that a random place will be fine assertEquals(5, buf.componentAtOffset(2).capacity()); // Loop through each byte byte index = 0; while (index < buf.capacity()) { ByteBuf _buf = buf.componentAtOffset(index++); assertNotNull(_buf); assertTrue(_buf.capacity() > 0); assertNotNull(_buf.getByte(0)); assertNotNull(_buf.getByte(_buf.readableBytes() - 1)); } }
@Test public void testFullConsolidation() { CompositeByteBuf buf = freeLater(compositeBuffer(Integer.MAX_VALUE)); buf.addComponent(wrappedBuffer(new byte[] {1})); buf.addComponent(wrappedBuffer(new byte[] {2, 3})); buf.addComponent(wrappedBuffer(new byte[] {4, 5, 6})); buf.consolidate(); assertEquals(1, buf.numComponents()); assertTrue(buf.hasArray()); assertNotNull(buf.array()); assertEquals(0, buf.arrayOffset()); }
@Test public void findField() { Field field = ReflectionUtils.findField( TestObjectSubclassWithPublicField.class, "publicField", String.class); assertNotNull(field); assertEquals("publicField", field.getName()); assertEquals(String.class, field.getType()); assertTrue("Field should be public.", Modifier.isPublic(field.getModifiers())); field = ReflectionUtils.findField(TestObjectSubclassWithNewField.class, "prot", String.class); assertNotNull(field); assertEquals("prot", field.getName()); assertEquals(String.class, field.getType()); assertTrue("Field should be protected.", Modifier.isProtected(field.getModifiers())); field = ReflectionUtils.findField(TestObjectSubclassWithNewField.class, "name", String.class); assertNotNull(field); assertEquals("name", field.getName()); assertEquals(String.class, field.getType()); assertTrue("Field should be private.", Modifier.isPrivate(field.getModifiers())); }
@Test public void testEmptyPolygon() { // alle Punkte ermitteln ArrayList<Point> points = poly.getPoints(); // Darf nicht null sein assertNotNull(points); // Größe muss 0 sein assertEquals(points.size(), 0); // draw sollte auch funktionieren poly.draw(); }
@Test public void testBasicAttach() throws Exception { try (JnaService service = factory.serviceConnect(connectionInfo)) { service.attach(); assertTrue("Expected isAttached() to return true", service.isAttached()); assertThat("Expected non-zero connection handle", service.getHandle(), not(equalTo(0))); assertNotNull("Expected version string to be not null", service.getServerVersion()); assertNotEquals( "Expected version should not be invalid", GDSServerVersion.INVALID_VERSION, service.getServerVersion()); } }