PowerMock is an open source Java framework that allows mocking of static methods, final classes, and private methods. It extends EasyMock and JUnit to enable these additional types of mocking. The document provides details on how to add PowerMock dependencies to Maven and Ant projects, examples of unit testing with and without mocks, and techniques like capturing arguments and emulating code in mock objects. It also discusses skipping static initialization and the F.I.R.S.T. properties that unit tests should have.
Vielseitiges In-Memory Computing mit Apache Ignite und KubernetesQAware GmbH
IT-Tage 2017, Frankfurt am Main: Vortrag von Mario-Leander Reimer (@LeanderReimer, Cheftechnologe bei QAware)
Abstract:
Mit Apache Ignite steht eine hochperformante, integrierte und verteilte In-Memory-Plattform bereit, die im Zusammenspiel mit Kubernetes zu wahrer Hochform aufläuft. In dieser Kombination lassen sich flexibel skalierbare In-Memory Computing-Systeme elegant realisieren.
In diesem Vortrag stellen wir die wesentlichen Features und die Architektur von Apache Ignite vor. Anhand von anschaulichen Beispielen zeigen wir mögliche Use Cases, wie etwa den Einsatz als Kommunikations-Backbone einer Microservice-Architektur oder als Plattform zur Verarbeitung von kontinuierlichen Event-Daten. Zur Demonstration von Resilienz und Skalierbarkeit des In-Memory Data-Grids werden die Beispiele auf einem Kubernetes Cluster ausgeführt.
Presentation from GWT.create 2015 on how to easily build a REST API that can be consumed via GWT or native mobile clients. Presentation video here: http://gwtcreate.com/videos/#rpc-jersey-resty-gwt
Vielseitiges In-Memory Computing mit Apache Ignite und KubernetesQAware GmbH
IT-Tage 2017, Frankfurt am Main: Vortrag von Mario-Leander Reimer (@LeanderReimer, Cheftechnologe bei QAware)
Abstract:
Mit Apache Ignite steht eine hochperformante, integrierte und verteilte In-Memory-Plattform bereit, die im Zusammenspiel mit Kubernetes zu wahrer Hochform aufläuft. In dieser Kombination lassen sich flexibel skalierbare In-Memory Computing-Systeme elegant realisieren.
In diesem Vortrag stellen wir die wesentlichen Features und die Architektur von Apache Ignite vor. Anhand von anschaulichen Beispielen zeigen wir mögliche Use Cases, wie etwa den Einsatz als Kommunikations-Backbone einer Microservice-Architektur oder als Plattform zur Verarbeitung von kontinuierlichen Event-Daten. Zur Demonstration von Resilienz und Skalierbarkeit des In-Memory Data-Grids werden die Beispiele auf einem Kubernetes Cluster ausgeführt.
Presentation from GWT.create 2015 on how to easily build a REST API that can be consumed via GWT or native mobile clients. Presentation video here: http://gwtcreate.com/videos/#rpc-jersey-resty-gwt
Introduction to Reactive Extensions (Rx)Tamir Dresher
Presentations from the june meeting of IDNDUG
http://ariely.info/Communities/IDNDUG/IDNDUG19thJune2013/tabid/171
The Reactive Extensions (Rx) is a library for composing asynchronous and event-based programs using observable sequences and LINQ-style query operators. Using Rx, developers represent asynchronous data streams with Observables, query asynchronous data streams using LINQ operators, andparameterize the concurrency in the asynchronous data streams using Schedulers. Simply put, Rx = Observables + LINQ + Schedulers
This presentation explains parameterized tests, theory tests, and generative testing. It also explains single mode faults and double mode faults and shows how to reduce the number of test cases when there's an combinatorial explosion. Lot's of JUnit examples.
Building responsive application with Rx - confoo - tamir dresherTamir Dresher
Code examples can be found here: https://github.com/tamirdresher/Rx101
Reactive applications are designed to handle asynchronous events in a way that maximizes responsiveness, resiliency, and elasticity. Reactive Extensions (Rx) is a library that abstracts away the sources of events and provides tools to handle them in a reactive way.
With Rx, filtering events, composing event sources, transforming events, and dealing with errors all become much simpler than with traditional tools and paradigms.
Introduction to Reactive Extensions (Rx)Tamir Dresher
Presentations from the june meeting of IDNDUG
http://ariely.info/Communities/IDNDUG/IDNDUG19thJune2013/tabid/171
The Reactive Extensions (Rx) is a library for composing asynchronous and event-based programs using observable sequences and LINQ-style query operators. Using Rx, developers represent asynchronous data streams with Observables, query asynchronous data streams using LINQ operators, andparameterize the concurrency in the asynchronous data streams using Schedulers. Simply put, Rx = Observables + LINQ + Schedulers
This presentation explains parameterized tests, theory tests, and generative testing. It also explains single mode faults and double mode faults and shows how to reduce the number of test cases when there's an combinatorial explosion. Lot's of JUnit examples.
Building responsive application with Rx - confoo - tamir dresherTamir Dresher
Code examples can be found here: https://github.com/tamirdresher/Rx101
Reactive applications are designed to handle asynchronous events in a way that maximizes responsiveness, resiliency, and elasticity. Reactive Extensions (Rx) is a library that abstracts away the sources of events and provides tools to handle them in a reactive way.
With Rx, filtering events, composing event sources, transforming events, and dealing with errors all become much simpler than with traditional tools and paradigms.
Unit testing your code can be hard and confusing. Particularly, for complex object structures you mock away functionality of collaborators and stub in expected return values, but covering every interaction seems difficult and pointless. In all your code, some parts call APIs to implement a functionality while they also provide an interface that can be used by others. A class' interface can be seen as a boundary with a contract to distinguish client code that uses the class, from service code that implements it's interface. Following this distinction, unit tests can be separated into collaboration and contract tests. In this talk, you'll see examples for different APIs and learn what is tested by existing tests to distinguish between collaboration and contract tests. You'll learn how to use mock objects to implement collaboration and contract tests, and see how integrated tests can be replaced with selected unit tests.
Poche chiacchiere e tanto codice per cercare rendere la nostra vita di
sviluppatori più divertente.
Parleremo di JAX-RS, le annotazioni, l'MVC che mette a disposizione e
l'integrazione di Jersey con Guice.
Useremo AOP per gestire log, transazioni e con l'aiuto di Infinispan
limiteremo le chamate concorrenti sul nostro cluster.
Dependency Injection for Android @ Ciklum speakers corner Kiev 29. May 2014First Tuesday Bergen
We are happy to invite you to the Speakers’ Corner today, on Thursday May 29, from 18.30 till 19.30 at SkyPoint to meet Thomas Vervik, Head of Development Bipper Communications who will talk on “How to save money on QA - Dependency Injection and automated testing on Android”
Thomas is Head of Development for Bipper Communications, and has been managing the company's team in Kiev since February 2012. Originally a seasoned Java server backend/frontend developer, he has the last two years started mobile development, first with HTML 5 and later Android.
Mobile development has since its birth around 2008 gone from simple apps to more complex enterprise similar software. The increase in size and complexity yields the need for structuring the code differently in order to handle the new complexity. The tools used to handle this complexity has been applied to server side development for years, but mobile development has been lagging behind.
But not anymore. New frameworks built on proven paradigms are emerging, and in this Speakers Corner we will introduce Dependency Injection for Android, the motivation for its use, and one of the implementations - Dagger. Dependency Injection has several advantages, but in this presentation we will focus on how it enables to write proper automated tests.
We are happy to invite you to the Speakers’ Corner today, on Thursday May 29, from 18.30 till 19.30 at SkyPoint to meet Thomas Vervik, Head of Development Bipper Communications who will talk on “How to save money on QA - Dependency Injection and automated testing on Android”
Thomas is Head of Development for Bipper Communications, and has been managing the company's team in Kiev since February 2012. Originally a seasoned Java server backend/frontend developer, he has the last two years started mobile development, first with HTML 5 and later Android.
Mobile development has since its birth around 2008 gone from simple apps to more complex enterprise similar software. The increase in size and complexity yields the need for structuring the code differently in order to handle the new complexity. The tools used to handle this complexity has been applied to server side development for years, but mobile development has been lagging behind.
But not anymore. New frameworks built on proven paradigms are emerging, and in this Speakers Corner we will introduce Dependency Injection for Android, the motivation for its use, and one of the implementations - Dagger. Dependency Injection has several advantages, but in this presentation we will focus on how it enables to write proper automated tests.
탑크리에듀교육센터(www.topcredu.co.kr)제공
스프링프레임워크 & 마이바티스(Spring Framework, MyBatis)
18번째 자료입니다. 참고하시어 많은 도움되셨길 바랍니다.
교육 및 수강문의/기타문의사항은 홈페이지(www.topcredu.co.kr)를 통하여 하실 수 있습니다.^^
Solit 2013, Автоматизация тестирования сложных систем: mixed mode automated t...solit
Виктор Короневич, Минск. Senior Software Test Automation Engineer with 3+ years of experience specializing in automation on Java, http://www.linkedin.com/in/agileseph
«Автоматизация тестирования сложных систем: mixed mode automated test case.» Использование Selenium + jUnit + Frank + custom java tools для тестирования Web + DB + Web Services + iOS. Development секция.
Introduction
Spring Boot testing features
Example of microservices with Spring Cloud
Component & Integration testing with Hoverfly
Contract testing with Pact or Spring Cloud Contract
Load testing with Gatling
Integration & end-to-end testing with Arquillian Cube
Summary
The Rule of 10,000 Spark Jobs - Learning from Exceptions and Serializing Your...Matthew Tovbin
Spark + AI Summit, 2019 - Mastering complex software stacks, such as Spark or Hadoop, is a challenging process. Incompatible dependencies, new programming paradigms, runtime errors, outdated documentation, scaling, tuning - this is just a short list of skills we must acquire. How do we make sure that we are not wasting time and making progress learning? How do we share our knowledge efficiently? This talk walks you through a journey of scaling Salesforce Einstein AI platform to serve 6B+ predictions per day and provides you with a scale to measure learning progress.
The Rule of 10,000 Spark Jobs: Learning From Exceptions and Serializing Your ...Databricks
Mastering complex software stacks, such as Spark or Hadoop, is a challenging process. Incompatible dependencies, new programming paradigms, runtime errors, outdated documentation, scaling, tuning - this is just a short list of skills we must acquire. How do we make sure that we are not wasting time and making progress learning? How do we share our knowledge efficiently? This talk walks you through a journey of scaling Salesforce Einstein AI platform to serve 3B+ predictions per day and provides you with a scale to measure learning progress.
Speaker: Matthew Tovbin
1. Unit testing with PowerMock
Open source project:
http ://code.google.com/p/powermock/
2. PowerMock features
Mocking static methods
Mocking final methods or classes
Mocking private methods
Mock construction of new objects
Partial Mocking
Replay and verify all
Mock Policies
Test listeners
4. Add to ant project
Copy jars to the test folder:
cglib-nodep-2.2.2.jar
easymock-3.1.jar
javassist-3.16.1-GA.jar
powermock-easymock-1.4.12-full.jar
objenesis-1.2.jar
Add jars to the classpath for junit task:
<path id="test.classpath">
<path refid="plugin.classpath" />
<fileset dir="${app.server.lib.portal.dir}" includes="commons-io.jar" />
<fileset dir="${project.dir}/lib" includes="junit.jar" />
<fileset dir="${project.dir}/lib/test" includes="*.jar" />
<pathelement location="test-classes" />
</path>
5. Class under test example
public class ClassUnderTest {
private MyService myService;
public String getMaxAmountForTemplate() {
String template = TemplateUtil.getTemplate("1");
BigDecimal maxAmount = myService.getMaxAmount();
return TemplateUtil.applyTemplate(template, maxAmount);
}
}
interface MyService {
BigDecimal getMaxAmount();
}
class TemplateUtil {
public static String getTemplate(String templateId) {
return "ID";
}
public static String applyTemplate(String template, Object ... params) {
return template + params.toString();
}
}
6. Unit test implementation
import java.math.BigDecimal;
public class ClassUnderTestTest {
private ClassUnderTest classUnderTest;
@org.junit.Test
public void getMaxAmountForTemplate() {
classUnderTest = new ClassUnderTest();
org.junit.Assert.assertEquals("Should be ID100", "ID100",
classUnderTest.getMaxAmountForTemplate());
}
}
7. Unit test implementation with mocks
@PrepareForTest({TemplateUtil.class })
@RunWith(PowerMockRunner.class)
public class ClassUnderTestTest {
private ClassUnderTest classUnderTest;
@org.junit.Test
public void getMaxAmountForTemplate() throws Exception {
classUnderTest = new ClassUnderTest();
PowerMock.mockStatic(TemplateUtil.class);
EasyMock.expect(TemplateUtil.getTemplate(EasyMock.eq("1"))).andReturn("ID");
EasyMock.expect(TemplateUtil.applyTemplate(EasyMock.eq("ID"), (BigDecimal)
EasyMock.anyObject())).andReturn("IDMOCK");
MyService myService = EasyMock.createMock(MyService.class);
Field field = classUnderTest.getClass().getDeclaredField("myService");
field.setAccessible(true);
field.set(classUnderTest, myService);
EasyMock.expect(myService.getMaxAmount()).andReturn(new BigDecimal("100"));
PowerMock.replayAll();
EasyMock.replay(myService);
org.junit.Assert.assertEquals("Should be IDMOCK", "IDMOCK",
classUnderTest.getMaxAmountForTemplate());
EasyMock.verify(myService);
PowerMock.verifyAll();
}
}
8. Use capture with EasyMock
public void getMaxAmountForTemplate() throws Exception {
classUnderTest = new ClassUnderTest();
PowerMock.mockStatic(TemplateUtil.class);
EasyMock.expect(TemplateUtil.getTemplate(EasyMock.eq("1"))).andReturn("ID");
Capture<BigDecimal> capturedMaxAmount = new Capture<BigDecimal>();
EasyMock.expect(TemplateUtil.applyTemplate(EasyMock.eq("ID"),
EasyMock.capture(capturedMaxAmount))).andReturn("IDMOCK");
MyService myService = EasyMock.createMock(MyService.class);
...
EasyMock.replay(myService);
org.junit.Assert.assertEquals("Should be IDMOCK", "IDMOCK",
classUnderTest.getMaxAmountForTemplate());
org.junit.Assert.assertEquals("100",
capturedMaxAmount.getValue().toString() );
EasyMock.verify(myService);
PowerMock.verifyAll();
}
9. Code emulation in mock objects
@org.junit.Test
public void getMaxAmountForTemplate() throws Exception {
classUnderTest = new ClassUnderTest();
PowerMock.mockStatic(TemplateUtil.class);
EasyMock.expect(TemplateUtil.getTemplate(EasyMock.eq("1"))).andReturn("ID");
EasyMock.expect(TemplateUtil.applyTemplate(EasyMock.eq("ID"), (BigDecimal)
EasyMock.anyObject())).andAnswer(new IAnswer<String>() {
public String answer() throws Throwable {
return EasyMock.getCurrentArguments()[0].toString() +
EasyMock.getCurrentArguments()[1].toString();
}
});
MyService myService = EasyMock.createMock(MyService.class);
Field field = classUnderTest.getClass().getDeclaredField("myService");
field.setAccessible(true);
field.set(classUnderTest, myService);
EasyMock.expect(myService.getMaxAmount()).andReturn(new BigDecimal("100"));
PowerMock.replayAll();
EasyMock.replay(myService);
org.junit.Assert.assertEquals("Should be ID100", "ID100",
classUnderTest.getMaxAmountForTemplate());
10. Skip static initialization for classes under test
public class TemplateUtil {
static {
initDatabase();
}
public static String getTemplate(String templateId) {
return "ID";
}
public static String applyTemplate(String template, Object ... params) {
return template + params[0].toString();
}
}
@SuppressStaticInitializationFor("TemplateUtil")
@RunWith(PowerMockRunner.class)
public class ClassUnderTestTest {
private ClassUnderTest classUnderTest;
11. F.I.R.S.T. properties of unit tests
Fast
Many hundreds or thousands per second
Isolates
Failure reasons became obvious
Repeatable
Run repeatedly in any order, any time
Self-validating
No manual validation required
Timely
Written before the code