NETBEANS’ FATE 03 | DESIGN PATTERNS IN JAVA 8 55 | CLOUD PROGRAMMING 63 magazine By and for the Java community JUnit 5 Arrives! 14 20 25 36 43 SPECIAL ISSUE WHAT’S NEW RUNNING JUNIT 5 KENT BECK ON MUTATION IN JUNIT 5? TESTS FROM EXTENSIONS HIS EVOLVING TESTING JUNIT 4 AND 5 VIEWS OF TESTING NOVEMBER/DECEMBER 2016 ORACLE.COM/JAVAMAGAZINE ////ttaabbllee ooff ccoonntteennttss // 20 25 36 43 PART 2: A DEEP DIVE INTERVIEW MUTATION TESTING: USING JUNIT 5 INTO JUNIT 5’S WITH KENT BECK AUTOMATE THE EXTENSION MODEL SEARCH FOR By Mert Çalişkan By Andrew Binstock IMPERFECT TESTS Integrating with build The parent of JUnit and By Nicolai Parlog tools and IDEs and The lowdown on how creator of TDD discusses By Henry Coles running JUnit 5 tests JUnit runs tests and how programming and testing— Locate incorrect and 14 with earlier versions it interacts with libraries and how his views on incomplete unit tests and frameworks testing have evolved. with pitest. PART 1: A FIRST LOOK AT JUNIT 5 By Mert Çalişkan The long-awaited release of JUnit 5 is a complete redesign with many useful additions. COVER ART BY I-HUA CHEN 03 11 61 67 From the Editor JavaOne 2016 Community Participation Fix This NetBeans Gets a New Life— The news, the videos, and the Contribute to Java By Simon Roberts or Does It? Duke’s Choice Awards by Adopting a JSR Our latest code quiz 06 55 By Martijn Verburg 54 How to stand out in the community Letters to the Editor New to Java Java Proposals of Interest by contributing to Java standards Comments, questions, suggestions, Implementing Design JSR 367: JSON Binding and kudos Patterns with Lambdas 63 73 07 By Raoul-Gabriel Urma, Mario Fusco, Cloud User Groups Events and Alan Mycroft Getting Started with Agile Istanbul JUG Astute use of lambdas can greatly Java Development in the Cloud Upcoming Java conferences and events reduce the complexity of implementing 74 By Shay Shmeltzer standard coding patterns. Avoid endless setup with Oracle Contact Us Have a comment? Suggestion? Developer Cloud Service’s integrated Git, Want to submit an article proposal? build, deploy, code review, and project Here’s how. management tools. 01 ORACLE.COM/JAVAMAGAZINE /////////////////////////////// NOVEMBER/DECEMBER 2016 EDITORIAL PUBLISHING Editor in Chief Publisher Andrew Binstock Jennifer Hamilton +1.650.506.3794 Managing Editor Associate Publisher and Audience 13 Billion Claire Breen Development Director Copy Editors Karin Kinnear +1.650.506.1985 Karen Perkins, Jim Donahue Audience Development Manager Technical Reviewer Jennifer Kurtz Stephen Chin ADVERTISING SALES DESIGN Sales Director Devices Run Java Senior Creative Director Tom Cometa Francisco G Delgadillo Account Manager Design Director Mark Makinney Richard Merchán Account Manager Senior Designer Marcin Gamza Arianna Pucherelli Advertising Sales Assistant Designer Cindy Elhaj +1.626.396.9400 x 201 Jaime Ferrand Mailing-List Rentals Senior Production Manager Contact your sales representative. Sheila Brennan Production Designer ATMs, Smartcards, POS Terminals, Blu-ray Players, RESOURCES Kathy Cygnarowicz Oracle Products +1.800.367.8674 (US/Canada) Set Top Boxes, Multifunction Printers, PCs, Servers, Oracle Services +1.888.283.0591 (US) Routers, Switches, Parking Meters, Smart Meters, Lottery Systems, Airplane Systems, IoT Gateways, Programmable Logic Controllers, Optical Sensors, ARTICLE SUBMISSION If you are interested in submitting an article, please email the editors. Wireless M2M Modules, Access Control Systems, SUBSCRIPTION INFORMATION Subscriptions are complimentary for qualified individuals who complete the subscription form. Medical Devices, Building Controls, Automobiles… MAGAZINE CUSTOMER SERVICE [email protected] Phone +1.847.763.9635 PRIVACY Oracle Publishing allows sharing of its mailing list with selected third parties. If you prefer that your mailing address or email address not be included in this program, contact Customer Service. Copyright © 2016, Oracle and/or its affiliates. All Rights Reserved. No part of this publication may be reprinted or otherwise reproduced without permission from the editors. JAVA MAGAZINE IS PROVIDED ON AN “AS IS” BASIS. ORACLE EXPRESSLY #1 Development Platform DISCLAIMS ALL WARRANTIES, WHETHER EXPRESS OR IMPLIED. IN NO EVENT SHALL ORACLE BE LIABLE FOR ANY DAMAGES OF ANY KIND ARISING FROM YOUR USE OF OR RELIANCE ON ANY INFORMATION PROVIDED HEREIN. Opinions expressed by authors, editors, and interviewees—even if they are Oracle employees—do not necessarily reflect the views of Oracle. The information is intended to outline our general product direction. It is intended for information purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. The development, release, and timing of any features or functionality described for Oracle’s products remains at the sole discretion of Oracle. Oracle and Java are registered trademarks of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Java Magazine is published bimonthly and made available at no cost to qualified subscribers by Oracle, 500 Oracle Parkway, MS OPL-3A, Redwood City, CA 94065-1600. 02 ORACLE.COM/JAVAMAGAZINE /////////////////////////////// NOVEMBER/DECEMBER 2016 //from the editor / Java in the Cloud NetBeans Gets a New Life—or Does It? Oracle Cloud delivers The transition from Oracle to the Apache Software Foundation marks the high-performance and beginning of an uncertain new era for the Java IDE. battle-tested platform and infrastructure services for the most demanding A Java apps. t JavaOne this year, the NetBeans commu- from Oracle). What few readers might know is nity announced that the project was moving that NetBeans was the irst of these products— Oracle Cloud. from its longtime home at Oracle to the Apache beating Borland’s JBuilder by a year. (JDeveloper, Built for modern app dev. Software Foundation (ASF). In a history that which was based on JBuilder, was next, followed Built for you. dates back some 20 years, this will be NetBeans’ years later by Eclipse and IntelliJ.) ifth new home, showing the product’s remark- NetBeans became a popular Java IDE because able power of endurance. An important question of several features, most especially the lightness is whether working under the aegis of the ASF of its use. While competing products had a long will bring NetBeans new life and new aiciona- setup cycle for new projects and a comparatively dos, or whether it signals the inal chapter of a “heavy” feel, NetBeans was great for coding storied lifeline. on the ly and always felt light and responsive. As many readers know, NetBeans is one of While it lacked some of its competitors’ code- the four principal Java IDEs. The others are the management features, it was the irst to ofer a Start here: open source Eclipse from the Eclipse Foundation, built-in execution proiler and, if I recall correctly, developer.oracle.com IntelliJ IDEA from JetBrains (consisting of an open the only one to include a small-scale J2EE server, source version and a higher-end closed source OC4J, to quickly test web projects locally. It was #developersrule version), and JDeveloper (a free, closed source IDE also the irst IDE to ofer a top-quality Swing- PHOTOGRAPH BY BOB ADLER/GETTY IMAGES 03 ORACLE.COM/JAVAMAGAZINE /////////////////////////////// NOVEMBER/DECEMBER 2016 //from the editor / based GUI-development tool, ment for two more releases: the I expect—but obviously I don’t called Matisse. upcoming 8.x version and the know—that they will contrib- That’s a lot of quality to 9.0 release. ute either directly or by engag- come from what was originally If you were to view NetBeans ing NetBeans’ current cohort of a student project at Charles purely as a programming envi- developers to continue develop- University in Prague. (The core ronment, its fate after Oracle’s ing the platform. In addition, development team for NetBeans commitment expires would be the community of users, many Level Up at has remained primarily based in most uncertain. Although many of whom are truly dedicated to Prague, although marketing and projects under the ASF aegis NetBeans, might well step up and Oracle Code other functions have been based have lourished (Maven, Hadoop, begin contributing. It’s diicult at various times in the United Spark, and others), more than a to project the extent of partici- States and elsewhere.) few projects have migrated to the pation because very few projects Step up to modern cloud Eventually, NetBeans was ASF only to die there. (See the with so large a user base have development. At the acquired by Sun, where it was Apache Attic for a list of defunct been migrated to the ASF, and so Oracle Code roadshow, open sourced. And through the projects.) However, over the there is little history to provide expert developers lead 2011 acquisition of Sun, NetBeans years, NetBeans evolved from an guidance. labs and sessions on PaaS, became part of Oracle. At that IDE into a platform consisting of For users of NetBeans, Java, mobile, and more. point, I was quite surprised to large-scale components that can though, nothing need be done read of Oracle’s commitment to be assembled in diferent ways to for now or in the near term. Get on the list continue developing NetBeans. form desktop applications. This The 9.0 release is scheduled for for event updates: After all, the company already architecture uses a rather dif- August 2017 and will cover Java 9. go.oracle.com/oraclecoderoadshow ofered JDeveloper for free and ferent approach than Eclipse’s By that time, we will surely have sponsored Oracle-speciic pack- OSGi-based system of modules more insight into the transition ages and extensions for Eclipse. and bundles. (This page compares of NetBeans, the level of activ- But actually, Oracle did more the Eclipse and NetBeans archi- ity, and the level of support from than just commit to supporting tectures.) Numerous companies— both commercial users and the the platform’s development and including Oracle—have exploited developer community. promotion; it also began using the beneits of NetBeans’ archi- portions of NetBeans in its own tecture and built applications Andrew Binstock, Editor in Chief products, speciically JDeveloper whose runtime includes the [email protected] and VisualVM, and eventually platform components. @platypusguy developer.oracle.com a variety of other development These companies have an tools. For this reason, even with interest in continuing the for- #developersrule the move to the ASF, NetBeans ward direction of NetBeans, and has secured a commitment from some have committed to work Oracle to underwrite its develop- on NetBeans in its new home. 04 ORACLE.COM/JAVAMAGAZINE /////////////////////////////// NOVEMBER/DECEMBER 2016 rr...... aa ss tt ee oo tt ff ss tt gg aa jjuu aa vv JJ //letters to the editor / Limited Language Choices For my own use, when I need a full set of well-reasoned JAX-RS 39 | JAVA INTERFACES 47 | FANTOM 53 SEPTEMBER/OCTOBER 2016 I enjoyed the Java Magazine article “Appreciating Java coding guidelines, I generally turn to the Google magazine Limited Choice in Languages” (September/October Java Style Guide.” By and for the Java community 2016), which discusses the beneits that Java enjoys Devices over other languages (such as C) in having a reason- Regarding your editorial, Python dominates UNIX IoT and able amount of standardization. However, there’s installation and infrastructure. Talk about a language 14INTERACTING a problem: Oracle’s recommended style guidelines needing “prescriptive” control! WITH SENSORS 24CONTROLLING CNC ROUTING for Java are hopelessly out of date—and have been —Richard Elkins FROM A RASPBERRY PI 32IOT AND for years. Dallas, TX THE CLOUD ORACLE.COM/JAVAMAGAZINE One huge indicator of this problem: The manual Back Issues Prior to 2015 on Java language style (which should be the bible SEPTEMBER/OCTOBER 2016 here) has not been updated since 1999. I was reading something on the web that mentioned The article says, “The convenience and beneits an article in an older version of Java Magazine. How- of such strictures that ensure uniform syntax are ever, when I look on the magazine home page it does widely recognized.” I agree. So, when will Oracle not show any issues before 2015. Is there any way to update the Java language style manual and ofer guid- access the back issues? Even if they’re just in PDF ance to developers and organizations? format, that would be helpful. —Alan Zeichick —Michael Szela Phoenix, AZ Palatine, IL Andrew Binstock responds: “I contacted the Java team to Andrew Binstock responds: “We recently made the 2015 get more detail on this. They told me that the document and 2016 back issues available for viewing on the web you’re referring to was not posted as an attempt to codify and downloading as PDF iles. We plan to make the previ- the language and therefore be a regularly updated docu- ous issues of Java Magazine available soon, most likely as ment. Rather, it was a set of internal coding guidelines downloadable PDF iles for subscribers. We’ll announce the published in response to a community request. The team availability of each year in the letter that goes out to sub- suggested that the most normative examples of Java style scribers with each new issue of the magazine. We grate- are those used in Oracle’s Java Tutorials. fully appreciate your patience.” “Most books available today on Java style were writ- Contact Us ten a long time ago, alas. A volume from 2014 that’s a worthy reference is Java Coding Guidelines, by Fred Long We welcome your comments and suggestions. Write and a group of security experts. It not so much deines a to us at [email protected]. For other ways to style as provides coding guidelines for writing secure code. reach us, see the last page of this issue. 06 ORACLE.COM/JAVAMAGAZINE /////////////////////////////// NOVEMBER/DECEMBER 2016 //events / ArchConf in English. Several tracks are DECEMBER 12–15, 2016 usually devoted speciically to CLEARWATER, FLORIDA Java EE, and the conference ArchConf is an educational can be attended online. event for software archi- DevNexus tects, technical leaders, and FEBRUARY 20–22 senior developers presented ATLANTA, GEORGIA by the No Fluf Just Stuf soft- ware symposium. Among the DevNexus is devoted to con- slated sessions are Modularity, necting developers from all Microservices, and Modern over the world, providing Architectural Paradigms, led afordable education, and pro- by Kirk Knoernschild, author of moting open source values. Prentice-Hall’s Java Application The 2017 conference will take Architecture, and Cloud-Native place at the Georgia World Application Architecture, Congress Center in down- led by Matt Stine, author of town Atlanta. Presenters will O’Reilly’s Migrating to Cloud- include Josh Long, author of Native Application Architectures. O’Reilly’s upcoming Cloud Native Java: Designing Resilient DevConf.cz 2017 Systems with Spring Boot, Spring Jfokus FEBRUARY 6, UNIVERSITY DAY; FEBRUARY 7–8, CONFERENCE JANUARY 27–29 Cloud, and Cloud Foundry, STOCKHOLM, SWEDEN BRNO, CZECH REPUBLIC and Venkat Subramaniam, Jfokus is the largest annual Java developer conference in Sweden. DevConf.cz 2017 is a free author of Pragmatic’s Conference topics include Java SE and Java EE, continuous delivery and three-day open-source Fedora Functional Programming in Java: DevOps, IoT, cloud and big data, trends, and JVM languages. This year, Linux and JBoss community Harnessing the Power of Java 8 the irst day of the event will include a VM Tech Summit, which is an conference for Red Hat and Lambda Expressions. open technical collaboration among language designers, compiler writ- community developers, ers, tool builders, runtime engineers, and VM architects. The schedule DevOps professionals, testers, Voxxed Days Zürich will be divided equally between traditional presentations of 45 minutes and documentation writers. FEBRUARY 23 and informal, facilitated deep-dive discussion groups among smaller, Set to be hosted at the Brno ZÜRICH, SWITZERLAND self-selected participants. Space is limited, as this summit is organized University of Technology, Sharing the Devoxx philoso- around a single classroom-style room to support direct communication all talks, presentations, and phy that content comes irst, between participants. workshops will be conducted Voxxed Days events see both 07 PHOTOGRAPH BY CHAS B/FLICKR ORACLE.COM/JAVAMAGAZINE /////////////////////////////// NOVEMBER/DECEMBER 2016 //events / spread of knowledge and innova- gathering of embedded system tion in the developer commu- developers is Securely Connecting nity. Scheduled tracks this year the Embedded World. Topics include Performance Mythbusting include IoT, connectivity, software and Every Last Nanosecond: Low engineering, and security. Latency Java. Devoxx US jDays MARCH 21–23 MARCH 7–8 SAN JOSE, CALIFORNIA GOTHENBURG, SWEDEN Devoxx US focuses on Java, web, jDays brings together software mobile, and JVM languages. The engineers around the world to conference includes more than share their experiences in difer- 100 sessions in total, with tracks ent areas such as Java, software devoted to server-side Java, archi- engineering, IoT, digital trends, tecture and security, cloud and testing, agile methodologies, containers, big data, IoT, and more. and security. JavaLand ConFoo Montreal 2017 MARCH 28–30 MARCH 8–10 BRÜHL, GERMANY internationally renowned and and agile development. Presen- MONTREAL, QUEBEC, CANADA This annual conference features local speakers converge. Past pre- tations this year include Java ConFoo Montreal is a multi- more than 100 lectures on sub- sentations have included Bringing Libraries You Can’t Aford to technology conference for web jects such as core Java and JVM the Performance of Structs to Java Miss, 8 Akka Antipatterns developers that promises 155 languages, enterprise Java and (Sort Of) by Simon Ritter and Java You’d Better Be Aware Of, and presentations by popular inter- cloud technologies, IoT, front-end Security Architecture Demystiied Spring Framework 5: Reactive national speakers. Past ConFoo and mobile computing, and much by Martin Toshev. Microservices on JDK 9. topics have included how to write more. Scheduled presentations Topconf Linz 2017 QCon London 2017 better streams with Java 8 and an include Multiplexing and Server FEBRUARY 28, WORKSHOPS MARCH 6–8, CONFERENCE introduction to Java 9. Push: HTTP/2 in Java 9, The Dark MARCH 1–2, CONFERENCE MARCH 9–10, WORKSHOPS and Light Side of JavaFX, JDK 8 Embedded World LINZ, AUSTRIA LONDON, ENGLAND Lambdas: Cool Code that Doesn’t MARCH 14–16 Topconf covers Java and JVM, For more than a decade, QCon Use Streams, Migrating to Java 9 NUREMBERG, GERMANY DevOps, reactive architecture, London has empowered software Modules, and Java EE 8: Java EE innovative languages, UX/UI, development by facilitating the The theme for the 15th annual Security API. 08 PHOTOGRAPH BY CRALVAREZ/FLICKR ORACLE.COM/JAVAMAGAZINE /////////////////////////////// NOVEMBER/DECEMBER 2016 //events / O’Reilly Software Architecture J On The Beach JCrete the Java and JVM ecosystem, Conference MAY 17 AND 20, WORKSHOPS JULY 17–21 DevOps, and agile development APRIL 2–3, TRAINING MAY 18–19, TALKS KOLYMBARI, GREECE environments. APRIL 3–5, TUTORIALS MALAGA, SPAIN This loosely structured “uncon- AND CONFERENCE JavaOne JOTB is an international rendez- ference” involves morning ses- NEW YORK, NEW YORK OCTOBER 1–5 vous for developers interested in sions discussing all things Java, This event promises four days of big data technologies. JVM and combined with afternoons spent SAN FRANCISCO, CALIFORNIA in-depth professional training .NET technologies, embedded and socializing, touring, and enjoy- Whether you are a seasoned that covers software architecture IoT development functional pro- ing the local scene. There is also a coder or a new Java programmer, fundamentals; real-world case gramming, and data visualization JCrete4Kids component for intro- JavaOne is the ultimate source of studies; and the latest trends in will all be discussed. Scheduled ducing youngsters to program- technical information and learn- technologies, frameworks, and speakers include longtime Java ming and Java. Attendees often ing about Java. For ive days, Java techniques. Past presentations Champion Martin Thompson and bring their families. developers gather from around have included Introduction to Red Hat Director of Developer the world to talk about upcom- ̈berConf Reactive Applications, Reactive Experience Edson Yanaga. ing releases of Java SE, Java EE, JULY 18–21 Streams, and Options for the and JavaFX; JVM languages; new QCon New York DENVER, COLORADO JVM, as well as Microservice development tools; insights into JUNE 26–28, CONFERENCE Standardization. ÜberConf 2017 will be held at the recent trends in programming; JUNE 29–30, WORKSHOPS Westin Westminster in down- and tutorials on numerous related Devoxx France NEW YORK, NEW YORK town Denver. Topics include Java and JVM topics. APRIL 5, WORKSHOPS QCon is a practitioner-driven Java 8, microservice architectures, APRIL 6–7, CONFERENCE conference for technical team Docker, cloud, security, Scala, Have an upcoming conference PARIS, FRANCE leads, architects, engineering Groovy, Spring, Android, iOS, you’d like to add to our listing? Devoxx France presents keynotes directors, and project manag- NoSQL, and much more. Send us a link and a description of from prestigious speakers, then ers who inluence innovation your event four months in advance NFJS Boston a cycle of eight mini conferences in their teams. Past speakers at [email protected]. SEPTEMBER 29–OCTOBER 1 every 50 minutes. You can build include Chris Richardson, author BOSTON, MASSACHUSETTS your own calendar and follow the of POJOs in Action, and Frank sessions as you wish. Founded by Greco, organizer of the largest Since 2001, the No Fluf Just Stuf developers for developers, Devoxx Java user group in North America (NFJS) Software Symposium Tour France covers topics ranging from (NYJavaSIG). has delivered more than 450 web security to cloud computing. events with more than 70,000 (No English page available.) attendees. This event in Boston covers the latest trends within 09 ORACLE.COM/JAVAMAGAZINE /////////////////////////////// NOVEMBER/DECEMBER 2016
Description: