DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones Build AI Agents That Are Ready for Production
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
Build AI Agents That Are Ready for Production

LIVE: “Cognitive Databases, Intelligent Data: Unified Infrastructure for Vector Search, AI-Optimized Queries, & Hybrid Workloads" Report

Live Webinar: Exclusive practitioner summit on AI-powered CDN operations and real-world automation strategies

The Latest Java Topics

article thumbnail
Is Polyglot Programming Practical?
This article discusses the history of polyglot programming, and considers whether it's still a valid premise.
May 10, 2016
by Keith Gregory
· 26,199 Views · 46 Likes
article thumbnail
Understanding the Java Garbage Collection Log
To diagnose any memory problems, the Garbage Collection log file is the best place to start. Take a look at the anatomy of a GC log file in this helpful article.
Updated May 5, 2016
by Ram Lakshmanan DZone Core CORE
· 200,017 Views · 39 Likes
article thumbnail
Java 8: Lambda Functions—Usage and Examples
One of the major new language features in Java 8 is the lambda function. In fact, it is one of the biggest changes since the Java 1 release. Take a look at this introduction to Java 8's lambda function.
May 4, 2016
by Hari Kiran G
· 216,781 Views · 10 Likes
article thumbnail
Custom SecurityContext in JAX-RS
An article about how to override the default security-related information associated with a JAX-RS request using a custom SecurityContext.
May 3, 2016
by Abhishek Gupta DZone Core CORE
· 31,147 Views · 9 Likes
article thumbnail
Simple, Secure Role Based Access Control (RBAC) For REST APIs
There are a lot of ways to implement Access Controls, and some are slightly complicated. Have you considered using REST?
April 30, 2016
by Sharone Zitzman
· 73,896 Views · 10 Likes
article thumbnail
Sharing Test Classes Between Multiple Modules in a Multi-module Maven Project
Using Maven to effectively test software when test classes are not already packaged by Maven.
April 28, 2016
by Dave Turner
· 56,308 Views · 6 Likes
article thumbnail
Testing Java EE (or Why Integration Tests Are Overrated)
Testing that goes beyond just unit testing and integration testing. Why we should be doing full system testing.
April 27, 2016
by Sebastian Daschner
· 26,085 Views · 7 Likes
article thumbnail
Mocking Method with Wildcard Generic Return Type
[Ivan Zerin provides a primer on mocking methods that contain generic return types.] There are several cases where construction when().thenReturn is not suitable during Unit tests. One of then generic return type. I have faced such issue, let's take a look. There is a method in interface declaration: public interface FooInterface { public Iterable getList(); ... } Implementation looks like this: public class Foo implements FooInterface { public List getList() { ... } ... } At first mocking of such method should not be something unusual: public class UnitTest { @Mock private FooInterface mockFoo; @Test public void someUnitTest() { ... List testList = generateTestList(); when(mockFoo.getList()) .thenReturn(testList); } } But this code won't compile with error: Cannot resolve method 'thenReturn(List). Seems to be some mistake, cause returned type are correct from the interface point of view. This error happening cause compiler can not gurantee that returned type of method getList() will be List. Actually return type of method getList() in this case is Iterable and this means "Return some Iterable object with any objects that extends SomeClass". Let's rename this type as 'X'. So when(mockFoo.getList()) will create object OngoingStubbing> and it has method thenReturn(Iterable). Compiler can not tell what type X before runtime and cannot perform safe cast from List to Iterable (we perfrom actuall call of method thenReturn(List)). Sounds a little tricky but let's assume that SomeClass is standard Java class Number. Then classes Integer and Double are both fulfill the criteria of List. Let's say that as return type of mock we will use List, in this case, compiler should be ready that actual work with code during runtime will be performed with List too, but it is clearly that cast from Double to Integer will be incorrect (try to cast double value 12.6 to int). You could argue that in the case of mockito compiler won't need to bother about the casting of returned type because call of original method would not produce anything, but it is known by mockito. From compiler point of view, it is only Java code, that should be checked for safety and correctness before compiling. Ok, so how we should deal with such cases in mockito? Use doReturn() method: doReturn(testList).when(mockFoo).getList(); Such expression is not type safe, so it were designed for exceprional cases, so use it only when you cannot use standart when().thenReturn(), which is the type-safe, elegant and more readable syntax.
April 27, 2016
by Ivan Zerin
· 44,457 Views · 4 Likes
article thumbnail
Collaborators and Libraries: Java Design Patterns for Success
Should constructors throw exceptions? What can the 1815 Congress of Vienna teach us about good Java design?
April 26, 2016
by Alan Hohn
· 10,678 Views · 7 Likes
article thumbnail
Spring OAuth2 With JWT Sample
Spring Security is an extensible framework for authentication, including support for OAuth 2 and JSON Web Token, two popular choices.
April 26, 2016
by Anh Tuan Nguyen
· 79,090 Views · 11 Likes
article thumbnail
Java 8 New Date And Time Overview
A practical introduction to the new and improved Date & Time API in Java 8. If you've not had chance to review or use it yet then start here!
April 22, 2016
by Siva Prasad Rao Janapati
· 14,873 Views · 5 Likes
article thumbnail
Deploy to WildFly and Docker From IntelliJ Using Management API
When you are new to both Docker and IntelliJ how do you deploy your Java EE applications? Steve Favez shows you how.
April 21, 2016
by Steve Favez
· 27,454 Views · 11 Likes
article thumbnail
Using Spring Session for Concurrent Session Control in a Clustered Environment
How a new feature in Spring lets you manage sessions without relying on external repositories.
Updated April 20, 2016
by Joris Kuipers
· 30,311 Views · 17 Likes
article thumbnail
Java Champions Get IntelliJ IDEA Ultimate for Free
Are you a Java Champion? Now you can get IntelliJ IDEA Ultimate as yet another reward.
April 18, 2016
by Robert Demmer
· 24,749 Views · 2 Likes
article thumbnail
Default HotSpot Maximum Direct Memory Size
Working with off-heap storage can make a big difference when working with large data sets. But how do you know how much memory you have at your disposal? Read this article and find out!
April 18, 2016
by Dustin Marx
· 41,599 Views · 7 Likes
article thumbnail
Protect Your Immutable Object Invariants in More Complex Java Objects
Learn the basics on how to write robust immutable Java objects and reap the benefits of immutable objects in your code.
April 17, 2016
by Per-Åke Minborg
· 12,587 Views · 11 Likes
article thumbnail
Yes, Java Has Flaws. But...
Is Java the new Cobol? Probably, but Cobol is still running. Java will be in enterprises for at least 20 more years.
April 15, 2016
by Tim Spann DZone Core CORE
· 25,410 Views · 39 Likes
article thumbnail
Properly Shutting Down An ExecutorService
This tutorial will teach you that you don't need to pilot an A-Wing to shut down these ExecutorServices.
Updated April 14, 2016
by T Tak
· 75,420 Views · 11 Likes
article thumbnail
An Introduction to Logback: a Logging Framework From the Creator of Log4J
Monitoring, diagnosing, and troubleshooting are key activities in any enterprise application lifecycle, and logging is the core part of these activities. Meet Logback, a logging framework from the creator of Log4J.
April 14, 2016
by John Thompson
· 14,798 Views · 8 Likes
article thumbnail
Creating Immutable Classes in Java
An introduction to immutable classes in Java, such as a String class.
Updated April 14, 2016
by Hari Kiran G
· 43,041 Views · 29 Likes
  • Previous
  • ...
  • 194
  • 195
  • 196
  • 197
  • 198
  • 199
  • 200
  • 201
  • 202
  • 203
  • ...
  • Next
  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook
×