diff --git a/.gitignore b/.gitignore index b981a473f6..50cb889e5b 100644 --- a/.gitignore +++ b/.gitignore @@ -76,4 +76,5 @@ persistence-modules/hibernate5/transaction.log apache-avro/src/main/java/com/baeldung/avro/model/ jta/transaction-logs/ software-security/sql-injection-samples/derby.log -spring-soap/src/main/java/com/baeldung/springsoap/gen/ \ No newline at end of file +spring-soap/src/main/java/com/baeldung/springsoap/gen/ +/report-*.json \ No newline at end of file diff --git a/apache-meecrowave/pom.xml b/apache-meecrowave/pom.xml index bb851577e2..4eb1094f94 100644 --- a/apache-meecrowave/pom.xml +++ b/apache-meecrowave/pom.xml @@ -60,7 +60,6 @@ 1.8 1.8 - 4.10 1.2.0 3.10.0 1.2.1 diff --git a/apache-olingo/Samples.md b/apache-olingo/Samples.md new file mode 100644 index 0000000000..def8971d64 --- /dev/null +++ b/apache-olingo/Samples.md @@ -0,0 +1,21 @@ +## OData test URLs + +This following table contains test URLs that can be used with the Olingo V2 demo project. + +| URL | Description | +|------------------------------------------|-------------------------------------------------| +| `http://localhost:8180/odata/$metadata` | fetch OData metadata document | +| `http://localhost:8180/odata/CarMakers?$top=10&$skip=10` | Get 10 entities starting at offset 10 | +| `http://localhost:8180/odata/CarMakers?$count` | Return total count of entities in this set | +| `http://localhost:8180/odata/CarMakers?$filter=startswith(Name,'B')` | Return entities where the *Name* property starts with 'B' | +| `http://localhost:8180/odata/CarModels?$filter=Year eq 2008 and CarMakerDetails/Name eq 'BWM'` | Return *CarModel* entities where the *Name* property of its maker starts with 'B' | +| `http://localhost:8180/odata/CarModels(1L)?$expand=CarMakerDetails` | Return the *CarModel* with primary key '1', along with its maker| +| `http://localhost:8180/odata/CarModels(1L)?$select=Name,Sku` | Return the *CarModel* with primary key '1', returing only its *Name* and *Sku* properties | +| `http://localhost:8180/odata/CarModels?$orderBy=Name asc,Sku desc` | Return *CarModel* entities, ordered by the their *Name* and *Sku* properties | +| `http://localhost:8180/odata/CarModels?$format=json` | Return *CarModel* entities, using a JSON representation| + + + + + + diff --git a/apache-olingo/olingo2/.gitignore b/apache-olingo/olingo2/.gitignore new file mode 100644 index 0000000000..153c9335eb --- /dev/null +++ b/apache-olingo/olingo2/.gitignore @@ -0,0 +1,29 @@ +HELP.md +/target/ +!.mvn/wrapper/maven-wrapper.jar + +### STS ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache + +### IntelliJ IDEA ### +.idea +*.iws +*.iml +*.ipr + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ +/build/ + +### VS Code ### +.vscode/ diff --git a/apache-olingo/olingo2/pom.xml b/apache-olingo/olingo2/pom.xml new file mode 100644 index 0000000000..4fc81e5e49 --- /dev/null +++ b/apache-olingo/olingo2/pom.xml @@ -0,0 +1,108 @@ + + + 4.0.0 + + org.springframework.boot + spring-boot-starter-parent + 2.1.3.RELEASE + + + org.baeldung.examples.olingo2 + olingo2-sample + 0.0.1-SNAPSHOT + olingo2-sample + Sample Olingo 2 Project + + + 1.8 + 2.0.11 + + + + + + org.springframework.boot + spring-boot-starter-jersey + + + + + org.springframework.boot + spring-boot-starter-data-jpa + + + + + com.h2database + h2 + runtime + + + org.springframework.boot + spring-boot-configuration-processor + true + + + org.projectlombok + lombok + true + + + org.springframework.boot + spring-boot-starter-test + test + + + + + org.apache.olingo + olingo-odata2-core + ${olingo2.version} + + + + javax.ws.rs + javax.ws.rs-api + + + + + org.apache.olingo + olingo-odata2-api + ${olingo2.version} + + + org.apache.olingo + olingo-odata2-jpa-processor-api + ${olingo2.version} + + + org.apache.olingo + olingo-odata2-jpa-processor-core + ${olingo2.version} + + + org.apache.olingo + olingo-odata2-jpa-processor-ref + ${olingo2.version} + + + org.eclipse.persistence + eclipselink + + + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + + diff --git a/apache-olingo/olingo2/src/main/java/org/baeldung/examples/olingo2/CarsODataJPAServiceFactory.java b/apache-olingo/olingo2/src/main/java/org/baeldung/examples/olingo2/CarsODataJPAServiceFactory.java new file mode 100644 index 0000000000..65a0428154 --- /dev/null +++ b/apache-olingo/olingo2/src/main/java/org/baeldung/examples/olingo2/CarsODataJPAServiceFactory.java @@ -0,0 +1,298 @@ +package org.baeldung.examples.olingo2; + +import java.util.List; +import java.util.Map; + +import javax.persistence.EntityGraph; +import javax.persistence.EntityManager; +import javax.persistence.EntityManagerFactory; +import javax.persistence.EntityTransaction; +import javax.persistence.FlushModeType; +import javax.persistence.LockModeType; +import javax.persistence.Persistence; +import javax.persistence.Query; +import javax.persistence.StoredProcedureQuery; +import javax.persistence.SynchronizationType; +import javax.persistence.TypedQuery; +import javax.persistence.criteria.CriteriaBuilder; +import javax.persistence.criteria.CriteriaDelete; +import javax.persistence.criteria.CriteriaQuery; +import javax.persistence.criteria.CriteriaUpdate; +import javax.persistence.metamodel.Metamodel; +import javax.servlet.http.HttpServletRequest; + +import org.apache.olingo.odata2.api.processor.ODataContext; +import org.apache.olingo.odata2.jpa.processor.api.ODataJPAContext; +import org.apache.olingo.odata2.jpa.processor.api.ODataJPAServiceFactory; +import org.apache.olingo.odata2.jpa.processor.api.exception.ODataJPARuntimeException; +import org.baeldung.examples.olingo2.JerseyConfig.EntityManagerFilter; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.orm.jpa.EntityManagerFactoryUtils; +import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; +import org.springframework.stereotype.Component; + +/** + * ODataJPAServiceFactory implementation for our sample domain + * @author Philippe + * + */ +@Component +public class CarsODataJPAServiceFactory extends ODataJPAServiceFactory { + + private static final Logger log = LoggerFactory.getLogger(CarsODataJPAServiceFactory.class); + + public CarsODataJPAServiceFactory() { + // Enable detailed error messages (useful for debugging) + setDetailErrors(true); + } + + /** + * This method will be called by Olingo on every request to + * initialize the ODataJPAContext that will be used. + */ + @Override + public ODataJPAContext initializeODataJPAContext() throws ODataJPARuntimeException { + + log.info("[I32] >>> initializeODataJPAContext()"); + ODataJPAContext ctx = getODataJPAContext(); + ODataContext octx = ctx.getODataContext(); + HttpServletRequest request = (HttpServletRequest)octx.getParameter(ODataContext.HTTP_SERVLET_REQUEST_OBJECT); + EntityManager em = (EntityManager)request.getAttribute(EntityManagerFilter.EM_REQUEST_ATTRIBUTE); + + // Here we're passing the EM that was created by the EntityManagerFilter (see JerseyConfig) + ctx.setEntityManager(new EntityManagerWrapper(em)); + ctx.setPersistenceUnitName("default"); + + // We're managing the EM's lifecycle, so we must inform Olingo that it should not + // try to manage transactions and/or persistence sessions + ctx.setContainerManaged(true); + return ctx; + } + + static class EntityManagerWrapper implements EntityManager { + + private EntityManager delegate; + + public void persist(Object entity) { + log.info("[I68] persist: entity.class=" + entity.getClass() + .getSimpleName()); + delegate.persist(entity); + // delegate.flush(); + } + + public T merge(T entity) { + log.info("[I74] merge: entity.class=" + entity.getClass() + .getSimpleName()); + return delegate.merge(entity); + } + + public void remove(Object entity) { + log.info("[I78] remove: entity.class=" + entity.getClass() + .getSimpleName()); + delegate.remove(entity); + } + + public T find(Class entityClass, Object primaryKey) { + return delegate.find(entityClass, primaryKey); + } + + public T find(Class entityClass, Object primaryKey, Map properties) { + return delegate.find(entityClass, primaryKey, properties); + } + + public T find(Class entityClass, Object primaryKey, LockModeType lockMode) { + return delegate.find(entityClass, primaryKey, lockMode); + } + + public T find(Class entityClass, Object primaryKey, LockModeType lockMode, Map properties) { + return delegate.find(entityClass, primaryKey, lockMode, properties); + } + + public T getReference(Class entityClass, Object primaryKey) { + return delegate.getReference(entityClass, primaryKey); + } + + public void flush() { + delegate.flush(); + } + + public void setFlushMode(FlushModeType flushMode) { + delegate.setFlushMode(flushMode); + } + + public FlushModeType getFlushMode() { + return delegate.getFlushMode(); + } + + public void lock(Object entity, LockModeType lockMode) { + delegate.lock(entity, lockMode); + } + + public void lock(Object entity, LockModeType lockMode, Map properties) { + delegate.lock(entity, lockMode, properties); + } + + public void refresh(Object entity) { + delegate.refresh(entity); + } + + public void refresh(Object entity, Map properties) { + delegate.refresh(entity, properties); + } + + public void refresh(Object entity, LockModeType lockMode) { + delegate.refresh(entity, lockMode); + } + + public void refresh(Object entity, LockModeType lockMode, Map properties) { + delegate.refresh(entity, lockMode, properties); + } + + public void clear() { + delegate.clear(); + } + + public void detach(Object entity) { + delegate.detach(entity); + } + + public boolean contains(Object entity) { + return delegate.contains(entity); + } + + public LockModeType getLockMode(Object entity) { + return delegate.getLockMode(entity); + } + + public void setProperty(String propertyName, Object value) { + delegate.setProperty(propertyName, value); + } + + public Map getProperties() { + return delegate.getProperties(); + } + + public Query createQuery(String qlString) { + return delegate.createQuery(qlString); + } + + public TypedQuery createQuery(CriteriaQuery criteriaQuery) { + return delegate.createQuery(criteriaQuery); + } + + public Query createQuery(CriteriaUpdate updateQuery) { + return delegate.createQuery(updateQuery); + } + + public Query createQuery(CriteriaDelete deleteQuery) { + return delegate.createQuery(deleteQuery); + } + + public TypedQuery createQuery(String qlString, Class resultClass) { + return delegate.createQuery(qlString, resultClass); + } + + public Query createNamedQuery(String name) { + return delegate.createNamedQuery(name); + } + + public TypedQuery createNamedQuery(String name, Class resultClass) { + return delegate.createNamedQuery(name, resultClass); + } + + public Query createNativeQuery(String sqlString) { + return delegate.createNativeQuery(sqlString); + } + + public Query createNativeQuery(String sqlString, Class resultClass) { + return delegate.createNativeQuery(sqlString, resultClass); + } + + public Query createNativeQuery(String sqlString, String resultSetMapping) { + return delegate.createNativeQuery(sqlString, resultSetMapping); + } + + public StoredProcedureQuery createNamedStoredProcedureQuery(String name) { + return delegate.createNamedStoredProcedureQuery(name); + } + + public StoredProcedureQuery createStoredProcedureQuery(String procedureName) { + return delegate.createStoredProcedureQuery(procedureName); + } + + public StoredProcedureQuery createStoredProcedureQuery(String procedureName, Class... resultClasses) { + return delegate.createStoredProcedureQuery(procedureName, resultClasses); + } + + public StoredProcedureQuery createStoredProcedureQuery(String procedureName, String... resultSetMappings) { + return delegate.createStoredProcedureQuery(procedureName, resultSetMappings); + } + + public void joinTransaction() { + delegate.joinTransaction(); + } + + public boolean isJoinedToTransaction() { + return delegate.isJoinedToTransaction(); + } + + public T unwrap(Class cls) { + return delegate.unwrap(cls); + } + + public Object getDelegate() { + return delegate.getDelegate(); + } + + public void close() { + log.info("[I229] close"); + delegate.close(); + } + + public boolean isOpen() { + boolean isOpen = delegate.isOpen(); + log.info("[I236] isOpen: " + isOpen); + return isOpen; + } + + public EntityTransaction getTransaction() { + log.info("[I240] getTransaction()"); + return delegate.getTransaction(); + } + + public EntityManagerFactory getEntityManagerFactory() { + return delegate.getEntityManagerFactory(); + } + + public CriteriaBuilder getCriteriaBuilder() { + return delegate.getCriteriaBuilder(); + } + + public Metamodel getMetamodel() { + return delegate.getMetamodel(); + } + + public EntityGraph createEntityGraph(Class rootType) { + return delegate.createEntityGraph(rootType); + } + + public EntityGraph createEntityGraph(String graphName) { + return delegate.createEntityGraph(graphName); + } + + public EntityGraph getEntityGraph(String graphName) { + return delegate.getEntityGraph(graphName); + } + + public List> getEntityGraphs(Class entityClass) { + return delegate.getEntityGraphs(entityClass); + } + + public EntityManagerWrapper(EntityManager delegate) { + this.delegate = delegate; + } + + } + +} diff --git a/apache-olingo/olingo2/src/main/java/org/baeldung/examples/olingo2/JerseyConfig.java b/apache-olingo/olingo2/src/main/java/org/baeldung/examples/olingo2/JerseyConfig.java new file mode 100644 index 0000000000..78caf99861 --- /dev/null +++ b/apache-olingo/olingo2/src/main/java/org/baeldung/examples/olingo2/JerseyConfig.java @@ -0,0 +1,125 @@ + package org.baeldung.examples.olingo2; + +import java.io.IOException; + +import javax.persistence.EntityManager; +import javax.persistence.EntityManagerFactory; +import javax.persistence.EntityTransaction; +import javax.servlet.ServletContext; +import javax.servlet.http.HttpServletRequest; +import javax.ws.rs.ApplicationPath; +import javax.ws.rs.Path; +import javax.ws.rs.container.ContainerRequestContext; +import javax.ws.rs.container.ContainerRequestFilter; +import javax.ws.rs.container.ContainerResponseContext; +import javax.ws.rs.container.ContainerResponseFilter; +import javax.ws.rs.core.Context; +import javax.ws.rs.ext.Provider; + +import org.apache.olingo.odata2.api.ODataServiceFactory; +import org.apache.olingo.odata2.core.rest.ODataRootLocator; +import org.apache.olingo.odata2.core.rest.app.ODataApplication; +import org.glassfish.jersey.server.ResourceConfig; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Component; + +/** + * Jersey JAX-RS configuration + * @author Philippe + * + */ +@Component +@ApplicationPath("/odata") +public class JerseyConfig extends ResourceConfig { + + + public JerseyConfig(CarsODataJPAServiceFactory serviceFactory, EntityManagerFactory emf) { + + ODataApplication app = new ODataApplication(); + + app + .getClasses() + .forEach( c -> { + // Avoid using the default RootLocator, as we want + // a Spring Managed one + if ( !ODataRootLocator.class.isAssignableFrom(c)) { + register(c); + } + }); + + register(new CarsRootLocator(serviceFactory)); + register( new EntityManagerFilter(emf)); + } + + /** + * This filter handles the EntityManager transaction lifecycle. + * @author Philippe + * + */ + @Provider + public static class EntityManagerFilter implements ContainerRequestFilter, ContainerResponseFilter { + + private static final Logger log = LoggerFactory.getLogger(EntityManagerFilter.class); + public static final String EM_REQUEST_ATTRIBUTE = EntityManagerFilter.class.getName() + "_ENTITY_MANAGER"; + + private final EntityManagerFactory emf; + + @Context + private HttpServletRequest httpRequest; + + public EntityManagerFilter(EntityManagerFactory emf) { + this.emf = emf; + } + + @Override + public void filter(ContainerRequestContext ctx) throws IOException { + log.info("[I60] >>> filter"); + EntityManager em = this.emf.createEntityManager(); + httpRequest.setAttribute(EM_REQUEST_ATTRIBUTE, em); + + // Start a new transaction unless we have a simple GET + if (!"GET".equalsIgnoreCase(ctx.getMethod())) { + em.getTransaction() + .begin(); + } + } + + @Override + public void filter(ContainerRequestContext requestContext, ContainerResponseContext responseContext) throws IOException { + + log.info("[I68] <<< filter"); + EntityManager em = (EntityManager) httpRequest.getAttribute(EM_REQUEST_ATTRIBUTE); + + if (!"GET".equalsIgnoreCase(requestContext.getMethod())) { + EntityTransaction t = em.getTransaction(); + if (t.isActive()) { + if (!t.getRollbackOnly()) { + t.commit(); + } + } + } + + em.close(); + + } + + } + + @Path("/") + public static class CarsRootLocator extends ODataRootLocator { + + private CarsODataJPAServiceFactory serviceFactory; + + public CarsRootLocator(CarsODataJPAServiceFactory serviceFactory) { + this.serviceFactory = serviceFactory; + } + + @Override + public ODataServiceFactory getServiceFactory() { + return this.serviceFactory; + } + + } + +} diff --git a/apache-olingo/olingo2/src/main/java/org/baeldung/examples/olingo2/Olingo2SampleApplication.java b/apache-olingo/olingo2/src/main/java/org/baeldung/examples/olingo2/Olingo2SampleApplication.java new file mode 100644 index 0000000000..fa58612088 --- /dev/null +++ b/apache-olingo/olingo2/src/main/java/org/baeldung/examples/olingo2/Olingo2SampleApplication.java @@ -0,0 +1,14 @@ +package org.baeldung.examples.olingo2; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.builder.SpringApplicationBuilder; +import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; + +@SpringBootApplication +public class Olingo2SampleApplication extends SpringBootServletInitializer { + + public static void main(String[] args) { + SpringApplication.run(Olingo2SampleApplication.class); + } +} diff --git a/apache-olingo/olingo2/src/main/java/org/baeldung/examples/olingo2/domain/CarMaker.java b/apache-olingo/olingo2/src/main/java/org/baeldung/examples/olingo2/domain/CarMaker.java new file mode 100644 index 0000000000..42a3eaa59d --- /dev/null +++ b/apache-olingo/olingo2/src/main/java/org/baeldung/examples/olingo2/domain/CarMaker.java @@ -0,0 +1,36 @@ +package org.baeldung.examples.olingo2.domain; + +import java.util.List; + +import javax.persistence.CascadeType; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.OneToMany; +import javax.persistence.Table; +import javax.validation.constraints.NotNull; + +import lombok.Data; + +@Entity +@Data +@Table(name="car_maker") +public class CarMaker { + + @Id + @GeneratedValue(strategy=GenerationType.IDENTITY) + private Long id; + + @NotNull + @Column(name="name") + private String name; + + @OneToMany(mappedBy="maker", + orphanRemoval = true, + cascade=CascadeType.ALL) + private List models; + + +} diff --git a/apache-olingo/olingo2/src/main/java/org/baeldung/examples/olingo2/domain/CarModel.java b/apache-olingo/olingo2/src/main/java/org/baeldung/examples/olingo2/domain/CarModel.java new file mode 100644 index 0000000000..a4f2a04f6e --- /dev/null +++ b/apache-olingo/olingo2/src/main/java/org/baeldung/examples/olingo2/domain/CarModel.java @@ -0,0 +1,38 @@ +package org.baeldung.examples.olingo2.domain; + + +import javax.persistence.Entity; +import javax.persistence.FetchType; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.Table; +import javax.validation.constraints.NotNull; + +import lombok.Data; + +@Entity +@Data +@Table(name="car_model") +public class CarModel { + + @Id + @GeneratedValue(strategy=GenerationType.AUTO) + private Long id; + + @NotNull + private String name; + + @NotNull + private Integer year; + + @NotNull + private String sku; + + @ManyToOne(optional=false, fetch= FetchType.LAZY) + @JoinColumn(name="maker_fk") + private CarMaker maker; + +} diff --git a/apache-olingo/olingo2/src/main/resources/application.yml b/apache-olingo/olingo2/src/main/resources/application.yml new file mode 100644 index 0000000000..21563a94fe --- /dev/null +++ b/apache-olingo/olingo2/src/main/resources/application.yml @@ -0,0 +1,12 @@ +server: + port: 8180 + +spring: + jersey: + application-path: /odata + + jpa: + show-sql: true + open-in-view: false + hibernate: + ddl-auto: update \ No newline at end of file diff --git a/apache-olingo/olingo2/src/main/resources/data.sql b/apache-olingo/olingo2/src/main/resources/data.sql new file mode 100644 index 0000000000..327f2688c5 --- /dev/null +++ b/apache-olingo/olingo2/src/main/resources/data.sql @@ -0,0 +1,12 @@ +insert into car_maker(id,name) values (1,'Special Motors'); +insert into car_maker(id,name) values (2,'BWM'); +insert into car_maker(id,name) values (3,'Dolores'); + +insert into car_model(id,maker_fk,name,sku,year) values(1,1,'Muze','SM001',2018); +insert into car_model(id,maker_fk,name,sku,year) values(2,1,'Empada','SM002',2008); + +insert into car_model(id,maker_fk,name,sku,year) values(4,2,'BWM-100','BWM100',2008); +insert into car_model(id,maker_fk,name,sku,year) values(5,2,'BWM-200','BWM200',2009); +insert into car_model(id,maker_fk,name,sku,year) values(6,2,'BWM-300','BWM300',2008); + +alter sequence hibernate_sequence restart with 100; \ No newline at end of file diff --git a/apache-olingo/olingo2/src/test/java/org/baeldung/examples/olingo2/Olingo2SampleApplicationTests.java b/apache-olingo/olingo2/src/test/java/org/baeldung/examples/olingo2/Olingo2SampleApplicationTests.java new file mode 100644 index 0000000000..687f6ab1ff --- /dev/null +++ b/apache-olingo/olingo2/src/test/java/org/baeldung/examples/olingo2/Olingo2SampleApplicationTests.java @@ -0,0 +1,16 @@ +package org.baeldung.examples.olingo2; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; + +@RunWith(SpringRunner.class) +@SpringBootTest +public class Olingo2SampleApplicationTests { + + @Test + public void contextLoads() { + } + +} diff --git a/apache-olingo/olingo2/src/test/resources/olingo2-queries.json b/apache-olingo/olingo2/src/test/resources/olingo2-queries.json new file mode 100644 index 0000000000..9fdade6d10 --- /dev/null +++ b/apache-olingo/olingo2/src/test/resources/olingo2-queries.json @@ -0,0 +1,256 @@ +{ + "info": { + "_postman_id": "afa8e1e5-ab0e-4f1d-8b99-b7d1f091f975", + "name": "OLingo2 - Cars", + "schema": "https://schema.getpostman.com/json/collection/v2.0.0/collection.json" + }, + "item": [ + { + "name": "GET Metadata", + "request": { + "method": "GET", + "header": [], + "body": { + "mode": "raw", + "raw": "" + }, + "url": "http://localhost:8080/odata/$metadata" + }, + "response": [] + }, + { + "name": "GET All CarMakers", + "request": { + "method": "GET", + "header": [], + "body": { + "mode": "raw", + "raw": "" + }, + "url": "http://localhost:8080/odata/CarMakers" + }, + "response": [] + }, + { + "name": "GET Makers with Pagination", + "request": { + "method": "GET", + "header": [], + "body": { + "mode": "raw", + "raw": "" + }, + "url": { + "raw": "http://localhost:8080/odata/CarMakers?$top=1&$orderby=Name&$skip=3", + "protocol": "http", + "host": [ + "localhost" + ], + "port": "8080", + "path": [ + "odata", + "CarMakers" + ], + "query": [ + { + "key": "$top", + "value": "1" + }, + { + "key": "$orderby", + "value": "Name" + }, + { + "key": "$skip", + "value": "3" + } + ] + } + }, + "response": [] + }, + { + "name": "GET Makers and Models", + "request": { + "method": "GET", + "header": [], + "body": { + "mode": "raw", + "raw": "" + }, + "url": { + "raw": "http://localhost:8080/odata/CarMakers?$expand=CarModelDetails", + "protocol": "http", + "host": [ + "localhost" + ], + "port": "8080", + "path": [ + "odata", + "CarMakers" + ], + "query": [ + { + "key": "$expand", + "value": "CarModelDetails" + } + ] + } + }, + "response": [] + }, + { + "name": "GET Makers with filter", + "request": { + "method": "GET", + "header": [ + { + "key": "Accept", + "value": "application/json", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "" + }, + "url": { + "raw": "http://localhost:8080/odata/CarMakers?$filter=Name eq 'BWM'&$expand=CarModelDetails", + "protocol": "http", + "host": [ + "localhost" + ], + "port": "8080", + "path": [ + "odata", + "CarMakers" + ], + "query": [ + { + "key": "$filter", + "value": "Name eq 'BWM'" + }, + { + "key": "$expand", + "value": "CarModelDetails" + } + ] + } + }, + "response": [] + }, + { + "name": "Create CarMaker", + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "name": "Content-Type", + "value": "application/atom+xml", + "type": "text" + }, + { + "key": "Accept", + "value": "application/atom+xml", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": " \r\n\r\n \r\n 2019-04-02T21:36:47Z\r\n \r\n \r\n \r\n \r\n \r\n \r\n Lucien\r\n \r\n \r\n" + }, + "url": "http://localhost:8080/odata/CarMakers" + }, + "response": [] + }, + { + "name": "Create CarModel", + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "name": "Content-Type", + "type": "text", + "value": "application/atom+xml" + }, + { + "key": "Accept", + "type": "text", + "value": "application/atom+xml" + } + ], + "body": { + "mode": "raw", + "raw": " \r\n\r\n \r\n 2019-04-02T21:36:47Z\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n\t Tata\r\n\t TT101\r\n\t 2018\r\n \r\n \r\n" + }, + "url": "http://localhost:8080/odata/CarModels" + }, + "response": [] + }, + { + "name": "Update CarMaker", + "request": { + "method": "PUT", + "header": [ + { + "key": "Content-Type", + "name": "Content-Type", + "type": "text", + "value": "application/atom+xml" + }, + { + "key": "Accept", + "type": "text", + "value": "application/atom+xml" + } + ], + "body": { + "mode": "raw", + "raw": " \r\n\r\n \r\n 2019-04-02T21:36:47Z\r\n \r\n \r\n \r\n \r\n \r\n \r\n 5\r\n KaiserWagen\r\n \r\n \r\n" + }, + "url": "http://localhost:8080/odata/CarMakers(5L)" + }, + "response": [] + }, + { + "name": "All CarModels", + "request": { + "method": "GET", + "header": [], + "body": { + "mode": "raw", + "raw": "" + }, + "url": "http://localhost:8080/odata/CarModels" + }, + "response": [] + }, + { + "name": "Delete CarModel", + "request": { + "method": "DELETE", + "header": [ + { + "key": "Content-Type", + "name": "Content-Type", + "type": "text", + "value": "application/atom+xml" + }, + { + "key": "Accept", + "type": "text", + "value": "application/atom+xml" + } + ], + "body": { + "mode": "raw", + "raw": "" + }, + "url": "http://localhost:8080/odata/CarModels(100L)" + }, + "response": [] + } + ] +} \ No newline at end of file diff --git a/apache-olingo/olingo4/.gitignore b/apache-olingo/olingo4/.gitignore new file mode 100644 index 0000000000..153c9335eb --- /dev/null +++ b/apache-olingo/olingo4/.gitignore @@ -0,0 +1,29 @@ +HELP.md +/target/ +!.mvn/wrapper/maven-wrapper.jar + +### STS ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache + +### IntelliJ IDEA ### +.idea +*.iws +*.iml +*.ipr + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ +/build/ + +### VS Code ### +.vscode/ diff --git a/apache-olingo/olingo4/pom.xml b/apache-olingo/olingo4/pom.xml new file mode 100644 index 0000000000..794aee0711 --- /dev/null +++ b/apache-olingo/olingo4/pom.xml @@ -0,0 +1,95 @@ + + + 4.0.0 + + org.springframework.boot + spring-boot-starter-parent + 2.1.3.RELEASE + + + org.baeldung.examples.olingo4 + olingo4-sample + 0.0.1-SNAPSHOT + olingo4-sample + Sample Olingo 4 Project + + + 1.8 + 4.5.0 + + + + + org.springframework.boot + spring-boot-starter-data-jpa + + + + org.springframework.boot + spring-boot-configuration-processor + true + + + + com.h2database + h2 + runtime + + + + org.projectlombok + lombok + true + + + org.springframework.boot + spring-boot-starter-test + test + + + org.springframework.boot + spring-boot-starter-web + + + + org.apache.olingo + odata-server-api + ${odata.version} + + + org.apache.olingo + odata-server-core + ${odata.version} + runtime + + + + org.apache.olingo + odata-commons-api + ${odata.version} + + + org.apache.olingo + odata-commons-core + ${odata.version} + + + + commons-beanutils + commons-beanutils + 1.9.3 + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + + diff --git a/apache-olingo/olingo4/src/main/java/org/baeldung/examples/olingo4/DefaultODataFactory.java b/apache-olingo/olingo4/src/main/java/org/baeldung/examples/olingo4/DefaultODataFactory.java new file mode 100644 index 0000000000..18f7f8ba24 --- /dev/null +++ b/apache-olingo/olingo4/src/main/java/org/baeldung/examples/olingo4/DefaultODataFactory.java @@ -0,0 +1,20 @@ +package org.baeldung.examples.olingo4; + +import org.apache.olingo.server.api.OData; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.stereotype.Component; + +/** + * Default implementation for ODataFactory + * @author Philippe + * + */ +@Component +public class DefaultODataFactory implements ODataFactory { + + @Override + public OData newInstance() { + return OData.newInstance(); + } + +} diff --git a/apache-olingo/olingo4/src/main/java/org/baeldung/examples/olingo4/ODataFactory.java b/apache-olingo/olingo4/src/main/java/org/baeldung/examples/olingo4/ODataFactory.java new file mode 100644 index 0000000000..9acb4b8c5e --- /dev/null +++ b/apache-olingo/olingo4/src/main/java/org/baeldung/examples/olingo4/ODataFactory.java @@ -0,0 +1,8 @@ +package org.baeldung.examples.olingo4; + +import org.apache.olingo.server.api.OData; + +public interface ODataFactory { + + public OData newInstance(); +} diff --git a/apache-olingo/olingo4/src/main/java/org/baeldung/examples/olingo4/ODataHttpHandlerFactory.java b/apache-olingo/olingo4/src/main/java/org/baeldung/examples/olingo4/ODataHttpHandlerFactory.java new file mode 100644 index 0000000000..27d0737c24 --- /dev/null +++ b/apache-olingo/olingo4/src/main/java/org/baeldung/examples/olingo4/ODataHttpHandlerFactory.java @@ -0,0 +1,8 @@ +package org.baeldung.examples.olingo4; + +import org.apache.olingo.server.api.ODataHttpHandler; + +public interface ODataHttpHandlerFactory { + + ODataHttpHandler newInstance(); +} diff --git a/apache-olingo/olingo4/src/main/java/org/baeldung/examples/olingo4/ODataHttpHandlerFactoryImpl.java b/apache-olingo/olingo4/src/main/java/org/baeldung/examples/olingo4/ODataHttpHandlerFactoryImpl.java new file mode 100644 index 0000000000..68d39dc052 --- /dev/null +++ b/apache-olingo/olingo4/src/main/java/org/baeldung/examples/olingo4/ODataHttpHandlerFactoryImpl.java @@ -0,0 +1,42 @@ +package org.baeldung.examples.olingo4; + +import java.util.Collections; +import java.util.List; + +import org.apache.olingo.commons.api.edm.provider.CsdlEdmProvider; +import org.apache.olingo.server.api.OData; +import org.apache.olingo.server.api.ODataHttpHandler; +import org.apache.olingo.server.api.ServiceMetadata; +import org.apache.olingo.server.api.processor.Processor; + +import lombok.Builder; + +@Builder +public class ODataHttpHandlerFactoryImpl implements ODataHttpHandlerFactory { + + + private final ODataFactory odataFactory; + private final CsdlEdmProvider edmProvider; + private final List processors; + + public ODataHttpHandlerFactoryImpl(ODataFactory odataFactory,CsdlEdmProvider edmProvider, List processors) { + this.odataFactory = odataFactory; + this.edmProvider = edmProvider; + this.processors = processors; + } + + @Override + public ODataHttpHandler newInstance() { + + OData odata = odataFactory.newInstance(); + ServiceMetadata metadata = odata.createServiceMetadata(edmProvider, Collections.emptyList()); + ODataHttpHandler handler = odata.createHandler(metadata); + + // Register all available processors + processors.forEach(p -> handler.register(p)); + + + return handler; + } + +} diff --git a/apache-olingo/olingo4/src/main/java/org/baeldung/examples/olingo4/ODataServiceConfiguration.java b/apache-olingo/olingo4/src/main/java/org/baeldung/examples/olingo4/ODataServiceConfiguration.java new file mode 100644 index 0000000000..0cde665359 --- /dev/null +++ b/apache-olingo/olingo4/src/main/java/org/baeldung/examples/olingo4/ODataServiceConfiguration.java @@ -0,0 +1,35 @@ +package org.baeldung.examples.olingo4; + +import java.util.List; + +import javax.persistence.EntityManagerFactory; +import javax.servlet.http.HttpServlet; + +import org.apache.olingo.commons.api.edm.provider.CsdlEdmProvider; +import org.apache.olingo.server.api.processor.Processor; +import org.baeldung.examples.olingo4.ODataHttpHandlerFactoryImpl.ODataHttpHandlerFactoryImplBuilder; +import org.springframework.boot.web.servlet.ServletRegistrationBean; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +@Configuration +public class ODataServiceConfiguration { + + @Bean + public ServletRegistrationBean odataServletRegistration(ODataHttpHandlerFactory factory) { + ServletRegistrationBean srb = + new ServletRegistrationBean<>(new ODataServlet(factory), "/odata/*"); + srb.setLoadOnStartup(1); + return srb; + } + + @Bean + public ODataHttpHandlerFactory httpHandlerFactory(CsdlEdmProvider edmProvider, ODataFactory odataFactory, List processors) { + return new ODataHttpHandlerFactoryImplBuilder() + .edmProvider(edmProvider) + .odataFactory(odataFactory) + .processors(processors) + .build(); + } + +} diff --git a/apache-olingo/olingo4/src/main/java/org/baeldung/examples/olingo4/ODataServlet.java b/apache-olingo/olingo4/src/main/java/org/baeldung/examples/olingo4/ODataServlet.java new file mode 100644 index 0000000000..c379124541 --- /dev/null +++ b/apache-olingo/olingo4/src/main/java/org/baeldung/examples/olingo4/ODataServlet.java @@ -0,0 +1,38 @@ +/** + * + */ +package org.baeldung.examples.olingo4; + +import java.io.IOException; + +import javax.persistence.EntityManager; +import javax.persistence.EntityManagerFactory; +import javax.persistence.EntityTransaction; +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.olingo.server.api.ODataHttpHandler; + +/** + * @author Philippe + * + */ +public class ODataServlet extends HttpServlet { + + private static final long serialVersionUID = 1L; + private final ODataHttpHandlerFactory odataHttpHandlerFactory; + + + public ODataServlet(ODataHttpHandlerFactory factory) { + this.odataHttpHandlerFactory = factory; + } + + @Override + protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { + + ODataHttpHandler handler = odataHttpHandlerFactory.newInstance(); + handler.process(req, resp); + } +} diff --git a/apache-olingo/olingo4/src/main/java/org/baeldung/examples/olingo4/Olingo4SampleApplication.java b/apache-olingo/olingo4/src/main/java/org/baeldung/examples/olingo4/Olingo4SampleApplication.java new file mode 100644 index 0000000000..1ac872ea0f --- /dev/null +++ b/apache-olingo/olingo4/src/main/java/org/baeldung/examples/olingo4/Olingo4SampleApplication.java @@ -0,0 +1,13 @@ +package org.baeldung.examples.olingo4; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class Olingo4SampleApplication { + + public static void main(String[] args) { + SpringApplication.run(Olingo4SampleApplication.class, args); + } + +} diff --git a/apache-olingo/olingo4/src/main/java/org/baeldung/examples/olingo4/domain/CarMaker.java b/apache-olingo/olingo4/src/main/java/org/baeldung/examples/olingo4/domain/CarMaker.java new file mode 100644 index 0000000000..79825b4556 --- /dev/null +++ b/apache-olingo/olingo4/src/main/java/org/baeldung/examples/olingo4/domain/CarMaker.java @@ -0,0 +1,36 @@ +package org.baeldung.examples.olingo4.domain; + +import java.util.List; + +import javax.persistence.CascadeType; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.OneToMany; +import javax.persistence.Table; +import javax.validation.constraints.NotNull; + +import lombok.Data; + +@Entity +@Data +@Table(name="car_maker") +public class CarMaker { + + @Id + @GeneratedValue(strategy=GenerationType.IDENTITY) + private Long id; + + @NotNull + @Column(name="name") + private String name; + + @OneToMany(mappedBy="maker", + orphanRemoval = true, + cascade=CascadeType.ALL) + private List models; + + +} diff --git a/apache-olingo/olingo4/src/main/java/org/baeldung/examples/olingo4/domain/CarModel.java b/apache-olingo/olingo4/src/main/java/org/baeldung/examples/olingo4/domain/CarModel.java new file mode 100644 index 0000000000..a9254e48b9 --- /dev/null +++ b/apache-olingo/olingo4/src/main/java/org/baeldung/examples/olingo4/domain/CarModel.java @@ -0,0 +1,38 @@ +package org.baeldung.examples.olingo4.domain; + + +import javax.persistence.Entity; +import javax.persistence.FetchType; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.Table; +import javax.validation.constraints.NotNull; + +import lombok.Data; + +@Entity +@Data +@Table(name="car_model") +public class CarModel { + + @Id + @GeneratedValue(strategy=GenerationType.AUTO) + private Long id; + + @NotNull + private String name; + + @NotNull + private Integer year; + + @NotNull + private String sku; + + @ManyToOne(optional=false, fetch= FetchType.EAGER ) + @JoinColumn(name="maker_fk") + private CarMaker maker; + +} diff --git a/apache-olingo/olingo4/src/main/java/org/baeldung/examples/olingo4/edm/EdmTypeMapper.java b/apache-olingo/olingo4/src/main/java/org/baeldung/examples/olingo4/edm/EdmTypeMapper.java new file mode 100644 index 0000000000..95797752a2 --- /dev/null +++ b/apache-olingo/olingo4/src/main/java/org/baeldung/examples/olingo4/edm/EdmTypeMapper.java @@ -0,0 +1,46 @@ +package org.baeldung.examples.olingo4.edm; + +import java.util.Collections; +import java.util.Date; +import java.util.Map; +import java.util.UUID; +import java.util.stream.Collectors; +import java.util.stream.Stream; +import java.sql.Time; +import java.util.AbstractMap.SimpleEntry; + +import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind; +import org.springframework.stereotype.Component; + +@Component +public class EdmTypeMapper { + + public EdmPrimitiveTypeKind java2edm(Class clazz) { + EdmPrimitiveTypeKind result = java2edm.get(clazz); + if ( result == null ) { + throw new IllegalArgumentException("[E19] Unsupported class mapping: class=" + clazz); + } + else { + return result; + } + } + + // Static map used generate attribute metadada based on Java types + static Map,EdmPrimitiveTypeKind> java2edm = Collections + .unmodifiableMap(Stream.of( + new SimpleEntry<>(Boolean.class,EdmPrimitiveTypeKind.Boolean), + new SimpleEntry<>(Byte.class,EdmPrimitiveTypeKind.SByte), + new SimpleEntry<>(Date.class,EdmPrimitiveTypeKind.Date), + new SimpleEntry<>(Time.class,EdmPrimitiveTypeKind.TimeOfDay), + new SimpleEntry<>(Number.class,EdmPrimitiveTypeKind.Decimal), + new SimpleEntry<>(Float.class,EdmPrimitiveTypeKind.Single), + new SimpleEntry<>(Double.class,EdmPrimitiveTypeKind.Double), + new SimpleEntry<>(UUID.class,EdmPrimitiveTypeKind.Guid), + new SimpleEntry<>(Short.class,EdmPrimitiveTypeKind.Int16), + new SimpleEntry<>(Integer.class,EdmPrimitiveTypeKind.Int32), + new SimpleEntry<>(Long.class,EdmPrimitiveTypeKind.Int64), + new SimpleEntry<>(String.class,EdmPrimitiveTypeKind.String) + + ).collect(Collectors.toMap((e)-> e.getKey(),(e)-> e.getValue()))); + +} diff --git a/apache-olingo/olingo4/src/main/java/org/baeldung/examples/olingo4/edm/JpaEdmProvider.java b/apache-olingo/olingo4/src/main/java/org/baeldung/examples/olingo4/edm/JpaEdmProvider.java new file mode 100644 index 0000000000..4cd979e931 --- /dev/null +++ b/apache-olingo/olingo4/src/main/java/org/baeldung/examples/olingo4/edm/JpaEdmProvider.java @@ -0,0 +1,269 @@ +package org.baeldung.examples.olingo4.edm; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +import javax.persistence.EntityManagerFactory; +import javax.persistence.metamodel.Attribute.PersistentAttributeType; +import javax.persistence.metamodel.EntityType; +import javax.persistence.metamodel.Metamodel; +import javax.persistence.metamodel.PluralAttribute; +import javax.persistence.metamodel.SingularAttribute; + +import org.apache.olingo.commons.api.edm.FullQualifiedName; +import org.apache.olingo.commons.api.edm.provider.CsdlAbstractEdmProvider; +import org.apache.olingo.commons.api.edm.provider.CsdlEntityContainer; +import org.apache.olingo.commons.api.edm.provider.CsdlEntityContainerInfo; +import org.apache.olingo.commons.api.edm.provider.CsdlEntitySet; +import org.apache.olingo.commons.api.edm.provider.CsdlEntityType; +import org.apache.olingo.commons.api.edm.provider.CsdlNavigationProperty; +import org.apache.olingo.commons.api.edm.provider.CsdlProperty; +import org.apache.olingo.commons.api.edm.provider.CsdlPropertyRef; +import org.apache.olingo.commons.api.edm.provider.CsdlSchema; +import org.apache.olingo.commons.api.ex.ODataException; +import org.springframework.stereotype.Component; + +@Component +public class JpaEdmProvider extends CsdlAbstractEdmProvider { + + EntityManagerFactory emf; + + // + private EdmTypeMapper typeMapper; + + // Service Namespace + public static final String NAMESPACE = "Baeldung.OData"; + + // EDM Container + public static final String CONTAINER_NAME = "Cars"; + public static final FullQualifiedName CONTAINER = new FullQualifiedName(NAMESPACE, CONTAINER_NAME); + + // Caches of OData types by it fully qualified name + private Map cdslName2Type = new HashMap<>(); + + public JpaEdmProvider(EntityManagerFactory emf, EdmTypeMapper mapper) { + this.emf = emf; + this.typeMapper = mapper; + } + + /* (non-Javadoc) + * @see org.apache.olingo.commons.api.edm.provider.CsdlAbstractEdmProvider#getEntitySet(org.apache.olingo.commons.api.edm.FullQualifiedName, java.lang.String) + */ + @Override + public CsdlEntitySet getEntitySet(FullQualifiedName entityContainer, String entitySetName) throws ODataException { + + if (entityContainer.equals(CONTAINER)) { + + EntityType e = emf.getMetamodel() + .getEntities() + .stream() + .filter((ent) -> (ent.getName() + "s") + .equals(entitySetName)) + .findFirst() + .orElse(null); + + if (e != null) { + CsdlEntitySet entitySet = new CsdlEntitySet(); + entitySet + .setName(entitySetName) + .setType(new FullQualifiedName(NAMESPACE, e.getName())); + return entitySet; + } + } + + return null; + } + + /* (non-Javadoc) + * @see org.apache.olingo.commons.api.edm.provider.CsdlAbstractEdmProvider#getEntityContainerInfo(org.apache.olingo.commons.api.edm.FullQualifiedName) + */ + @Override + public CsdlEntityContainerInfo getEntityContainerInfo(FullQualifiedName entityContainerName) throws ODataException { + + // This method is invoked when displaying the Service Document at e.g. http://localhost:8080/DemoService/DemoService.svc + if (entityContainerName == null || entityContainerName.equals(CONTAINER)) { + CsdlEntityContainerInfo entityContainerInfo = new CsdlEntityContainerInfo(); + entityContainerInfo.setContainerName(CONTAINER); + return entityContainerInfo; + } + + return null; + } + + /* (non-Javadoc) + * @see org.apache.olingo.commons.api.edm.provider.CsdlAbstractEdmProvider#getSchemas() + */ + @Override + public List getSchemas() throws ODataException { + // create Schema + CsdlSchema schema = new CsdlSchema(); + schema.setNamespace(NAMESPACE); + + // add EntityTypes + List entityTypes = emf.getMetamodel() + .getEntities() + .stream() + .map((e) -> { + try { + return getEntityType(new FullQualifiedName(NAMESPACE, e.getName())); + } catch (ODataException oe) { + throw new RuntimeException(oe); + } + }) + .collect(Collectors.toList()); + + schema.setEntityTypes(entityTypes); + + // add EntityContainer + schema.setEntityContainer(getEntityContainer()); + + // finally + List schemas = new ArrayList(); + schemas.add(schema); + + return schemas; + } + + /* (non-Javadoc) + * @see org.apache.olingo.commons.api.edm.provider.CsdlAbstractEdmProvider#getEntityContainer() + */ + @Override + public CsdlEntityContainer getEntityContainer() throws ODataException { + + + // add EntityTypes + List entitySets = emf.getMetamodel() + .getEntities() + .stream() + .map((e) -> { + try { + // Here we use a simple mapping strategy to map entity types to entity set names: + return getEntitySet(CONTAINER, e.getName() + "s"); + } catch (ODataException oe) { + throw new RuntimeException(oe); + } + }) + .collect(Collectors.toList()); + + // create EntityContainer + CsdlEntityContainer entityContainer = new CsdlEntityContainer(); + entityContainer.setName(CONTAINER_NAME); + entityContainer.setEntitySets(entitySets); + + return entityContainer; + } + + @Override + public CsdlEntityType getEntityType(FullQualifiedName entityTypeName) throws ODataException { + + CsdlEntityType result = cdslName2Type.get(entityTypeName); + if ( result != null ) { + return result; + } + + Metamodel mm = emf.getMetamodel(); + result = mm.getEntities() + .stream() + .filter(et -> entityTypeName.equals(new FullQualifiedName(NAMESPACE, et.getName()))) + .map(et -> buildODataType(et)) + .findFirst() + .orElse(null); + + // save for future use + cdslName2Type.put(entityTypeName, result); + return result; + + } + + /** + * Maps a JPA type to its OData counterpart. + * @param et + * @return + */ + protected CsdlEntityType buildODataType(EntityType et) { + + CsdlEntityType result = new CsdlEntityType(); + result.setName(et.getName()); + + // Process simple properties + List properties = et.getDeclaredSingularAttributes() + .stream() + .filter(attr -> attr.getPersistentAttributeType() == PersistentAttributeType.BASIC) + .map(attr -> buildBasicAttribute(et, attr)) + .collect(Collectors.toList()); + + result.setProperties(properties); + + // Process Ids + List ids = et.getDeclaredSingularAttributes() + .stream() + .filter(attr -> attr.getPersistentAttributeType() == PersistentAttributeType.BASIC && attr.isId()) + .map(attr -> buildRefAttribute(et, attr)) + .collect(Collectors.toList()); + + result.setKey(ids); + + // Process 1:N navs + List navs = et.getDeclaredPluralAttributes() + .stream() + .map(attr -> buildNavAttribute(et, attr)) + .collect(Collectors.toList()); + result.setNavigationProperties(navs); + + // Process N:1 navs + List navs2 = et.getDeclaredSingularAttributes() + .stream() + .filter(attr -> attr.getPersistentAttributeType() == PersistentAttributeType.MANY_TO_ONE) + .map(attr -> buildNavAttribute(et, attr)) + .collect(Collectors.toList()); + + result.getNavigationProperties().addAll(navs2); + + + return result; + } + + private CsdlProperty buildBasicAttribute(EntityType et, SingularAttribute attr) { + + CsdlProperty p = new CsdlProperty().setName(attr.getName()) + .setType(typeMapper.java2edm(attr.getJavaType()) + .getFullQualifiedName()) + .setNullable(et.getDeclaredSingularAttribute(attr.getName()) + .isOptional()); + + return p; + } + + private CsdlPropertyRef buildRefAttribute(EntityType et, SingularAttribute attr) { + + CsdlPropertyRef p = new CsdlPropertyRef().setName(attr.getName()); + + return p; + } + + // Build NavProperty for 1:N or M:N associations + private CsdlNavigationProperty buildNavAttribute(EntityType et, PluralAttribute attr) { + + CsdlNavigationProperty p = new CsdlNavigationProperty().setName(attr.getName()) + .setType(new FullQualifiedName(NAMESPACE, attr.getBindableJavaType().getSimpleName())) + .setCollection(true) + .setNullable(false); + + return p; + } + + // Build NavProperty for N:1 associations + private CsdlNavigationProperty buildNavAttribute(EntityType et, SingularAttribute attr) { + + CsdlNavigationProperty p = new CsdlNavigationProperty().setName(attr.getName()) + .setType(new FullQualifiedName(NAMESPACE, attr.getBindableJavaType().getSimpleName())) + .setCollection(false) + .setNullable(attr.isOptional()); + + return p; + } + +} diff --git a/apache-olingo/olingo4/src/main/java/org/baeldung/examples/olingo4/processor/JpaEntityCollectionProcessor.java b/apache-olingo/olingo4/src/main/java/org/baeldung/examples/olingo4/processor/JpaEntityCollectionProcessor.java new file mode 100644 index 0000000000..4a4e5026f3 --- /dev/null +++ b/apache-olingo/olingo4/src/main/java/org/baeldung/examples/olingo4/processor/JpaEntityCollectionProcessor.java @@ -0,0 +1,161 @@ +package org.baeldung.examples.olingo4.processor; + +import java.io.ByteArrayInputStream; +import java.io.InputStream; +import java.lang.reflect.InvocationTargetException; +import java.net.URI; +import java.net.URISyntaxException; +import java.util.Collection; +import java.util.List; + +import javax.persistence.EntityManagerFactory; +import javax.persistence.metamodel.EntityType; +import javax.persistence.metamodel.SingularAttribute; + +import org.apache.commons.beanutils.PropertyUtils; +import org.apache.olingo.commons.api.data.ContextURL; +import org.apache.olingo.commons.api.data.Entity; +import org.apache.olingo.commons.api.data.EntityCollection; +import org.apache.olingo.commons.api.data.Property; +import org.apache.olingo.commons.api.data.ValueType; +import org.apache.olingo.commons.api.edm.EdmEntitySet; +import org.apache.olingo.commons.api.edm.EdmEntityType; +import org.apache.olingo.commons.api.edm.EdmNavigationProperty; +import org.apache.olingo.commons.api.ex.ODataRuntimeException; +import org.apache.olingo.commons.api.format.ContentType; +import org.apache.olingo.commons.api.http.HttpHeader; +import org.apache.olingo.commons.api.http.HttpStatusCode; +import org.apache.olingo.server.api.OData; +import org.apache.olingo.server.api.ODataApplicationException; +import org.apache.olingo.server.api.ODataLibraryException; +import org.apache.olingo.server.api.ODataRequest; +import org.apache.olingo.server.api.ODataResponse; +import org.apache.olingo.server.api.ServiceMetadata; +import org.apache.olingo.server.api.processor.CountEntityCollectionProcessor; +import org.apache.olingo.server.api.processor.EntityCollectionProcessor; +import org.apache.olingo.server.api.serializer.EntityCollectionSerializerOptions; +import org.apache.olingo.server.api.serializer.ODataSerializer; +import org.apache.olingo.server.api.serializer.SerializerResult; +import org.apache.olingo.server.api.uri.UriInfo; +import org.apache.olingo.server.api.uri.UriParameter; +import org.apache.olingo.server.api.uri.UriResource; +import org.apache.olingo.server.api.uri.UriResourceEntitySet; +import org.baeldung.examples.olingo4.repository.RepositoryRegistry; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Component; + +@Component +public class JpaEntityCollectionProcessor implements CountEntityCollectionProcessor { + + private OData odata; + private ServiceMetadata serviceMetadata; + private EntityManagerFactory emf; + private RepositoryRegistry repositoryRegistry; + private JpaEntityMapper entityMapper; + + public JpaEntityCollectionProcessor(EntityManagerFactory emf, RepositoryRegistry repositoryRegistry, JpaEntityMapper entityMapper) { + this.emf = emf; + this.repositoryRegistry = repositoryRegistry; + this.entityMapper = entityMapper; + } + + @Override + public void init(OData odata, ServiceMetadata serviceMetadata) { + this.odata = odata; + this.serviceMetadata = serviceMetadata; + } + + @Override + public void readEntityCollection(ODataRequest request, ODataResponse response, UriInfo uriInfo, ContentType responseFormat) throws ODataApplicationException, ODataLibraryException { + + // 1st we have retrieve the requested EntitySet from the uriInfo object (representation of the parsed service URI) + List resourcePaths = uriInfo.getUriResourceParts(); + UriResourceEntitySet uriResourceEntitySet = (UriResourceEntitySet) resourcePaths.get(0); // in our example, the first segment is the EntitySet + EdmEntitySet edmEntitySet = uriResourceEntitySet.getEntitySet(); + + // 2nd: fetch the data from backend for this requested EntitySetName + // it has to be delivered as EntitySet object + EntityCollection entitySet = getData(edmEntitySet, uriInfo); + + // 3rd: create a serializer based on the requested format (json) + ODataSerializer serializer = odata.createSerializer(responseFormat); + + // 4th: Now serialize the content: transform from the EntitySet object to InputStream + EdmEntityType edmEntityType = edmEntitySet.getEntityType(); + ContextURL contextUrl = ContextURL.with() + .entitySet(edmEntitySet) + .build(); + + final String id = request.getRawBaseUri() + "/" + edmEntitySet.getName(); + EntityCollectionSerializerOptions opts = EntityCollectionSerializerOptions.with() + .id(id) + .contextURL(contextUrl) + .build(); + SerializerResult serializerResult = serializer.entityCollection(serviceMetadata, edmEntityType, entitySet, opts); + InputStream serializedContent = serializerResult.getContent(); + + // Finally: configure the response object: set the body, headers and status code + response.setContent(serializedContent); + response.setStatusCode(HttpStatusCode.OK.getStatusCode()); + response.setHeader(HttpHeader.CONTENT_TYPE, responseFormat.toContentTypeString()); + + } + + @Override + public void countEntityCollection(ODataRequest request, ODataResponse response, UriInfo uriInfo) throws ODataApplicationException, ODataLibraryException { + + // 1st we have retrieve the requested EntitySet from the uriInfo object (representation of the parsed service URI) + List resourcePaths = uriInfo.getUriResourceParts(); + UriResourceEntitySet uriResourceEntitySet = (UriResourceEntitySet) resourcePaths.get(0); // in our example, the first segment is the EntitySet + EdmEntitySet edmEntitySet = uriResourceEntitySet.getEntitySet(); + + // 2nd: fetch the data from backend for this requested EntitySetName + Long count = getCount(edmEntitySet, uriInfo); + + // Finally: configure the response object: set the body, headers and status code + response.setContent(new ByteArrayInputStream(count.toString().getBytes())); + response.setStatusCode(HttpStatusCode.OK.getStatusCode()); + response.setHeader(HttpHeader.CONTENT_TYPE, "text/plain"); + + } + + /** + * Helper method to retrieve all entities of an entity set from an the backend database + * @param edmEntitySet + * @param uriInfo + * @return + */ + protected EntityCollection getData(EdmEntitySet edmEntitySet, UriInfo uriInfo) { + + EdmEntityType type = edmEntitySet.getEntityType(); + JpaRepository repo = (JpaRepository)repositoryRegistry.getRepositoryForEntity(type); + EntityCollection result = new EntityCollection(); + + repo.findAll() + .stream() + .forEach((it) -> result.getEntities() + .add(entityMapper.map2entity(edmEntitySet, it))); + + return result; + } + + + /** + * Helper method to get the total size of an entity set + * @param edmEntitySet + * @param uriInfo + * @return + */ + protected Long getCount(EdmEntitySet edmEntitySet, UriInfo uriInfo) { + + EdmEntityType type = edmEntitySet.getEntityType(); + JpaRepository repo = (JpaRepository)repositoryRegistry.getRepositoryForEntity(type); + EntityCollection result = new EntityCollection(); + + return repo.count(); + } + + + + +} diff --git a/apache-olingo/olingo4/src/main/java/org/baeldung/examples/olingo4/processor/JpaEntityMapper.java b/apache-olingo/olingo4/src/main/java/org/baeldung/examples/olingo4/processor/JpaEntityMapper.java new file mode 100644 index 0000000000..1978aa4fd6 --- /dev/null +++ b/apache-olingo/olingo4/src/main/java/org/baeldung/examples/olingo4/processor/JpaEntityMapper.java @@ -0,0 +1,93 @@ +/** + * + */ +package org.baeldung.examples.olingo4.processor; + +import java.lang.reflect.InvocationTargetException; +import java.net.URI; +import java.net.URISyntaxException; + +import javax.persistence.EntityManagerFactory; +import javax.persistence.metamodel.EntityType; + +import org.apache.commons.beanutils.PropertyUtils; +import org.apache.olingo.commons.api.data.Entity; +import org.apache.olingo.commons.api.data.Property; +import org.apache.olingo.commons.api.data.ValueType; +import org.apache.olingo.commons.api.edm.EdmEntitySet; +import org.apache.olingo.commons.api.ex.ODataRuntimeException; +import org.springframework.stereotype.Component; + +/** + *

Helper class that converts a JPA entity into an OData entity using + * available metadata from the JPA's EntityManagerFactory.

+ * + * @author Philippe + * + */ +@Component +public class JpaEntityMapper { + + private EntityManagerFactory emf; + + public JpaEntityMapper(EntityManagerFactory emf) { + this.emf = emf; + } + + + public Entity map2entity(EdmEntitySet edmEntitySet, Object entry) { + + EntityType et = emf.getMetamodel() + .entity(entry.getClass()); + + + Entity e = new Entity(); + try { + et.getDeclaredSingularAttributes().stream() + .forEach( (attr) -> { + if ( !attr.isAssociation()) { + Object v = getPropertyValue(entry,attr.getName()); + Property p = new Property(null, attr.getName(),ValueType.PRIMITIVE,v); + e.addProperty(p); + + if ( attr.isId()) { + e.setId(createId(edmEntitySet.getName(),v)); + } + } + }); + } catch (Exception ex) { + throw new ODataRuntimeException("[E141] Unable to create OData entity", ex); + } + + return e; + } + + + public Object getPropertyValue(Object entry, String name) { + try { + return PropertyUtils.getProperty(entry,name); + } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) { + throw new ODataRuntimeException("[E141] Unable to read property from entity, property=" + name, e); + } + } + + public void setPropertyValue(Object entry, String name,Object value) { + try { + PropertyUtils.setProperty(entry,name,value); + } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) { + throw new ODataRuntimeException("[E141] Unable to read property from entity, property=" + name, e); + } + } + + + private URI createId(String entitySetName, Object id) { + try { + return new URI(entitySetName + "(" + String.valueOf(id) + ")"); + } catch (URISyntaxException e) { + throw new ODataRuntimeException("[E177] Unable to create URI", e); + } + } + + + +} diff --git a/apache-olingo/olingo4/src/main/java/org/baeldung/examples/olingo4/processor/JpaEntityProcessor.java b/apache-olingo/olingo4/src/main/java/org/baeldung/examples/olingo4/processor/JpaEntityProcessor.java new file mode 100644 index 0000000000..719e5de160 --- /dev/null +++ b/apache-olingo/olingo4/src/main/java/org/baeldung/examples/olingo4/processor/JpaEntityProcessor.java @@ -0,0 +1,304 @@ +/** + * + */ +package org.baeldung.examples.olingo4.processor; + +import java.io.InputStream; +import java.util.List; +import java.util.Locale; +import java.util.Optional; + +import javax.persistence.EntityManager; +import javax.persistence.EntityManagerFactory; +import javax.persistence.metamodel.SingularAttribute; + +import org.apache.olingo.commons.api.data.ContextURL; +import org.apache.olingo.commons.api.data.Entity; +import org.apache.olingo.commons.api.edm.EdmEntitySet; +import org.apache.olingo.commons.api.edm.EdmEntityType; +import org.apache.olingo.commons.api.edm.EdmNavigationProperty; +import org.apache.olingo.commons.api.ex.ODataRuntimeException; +import org.apache.olingo.commons.api.format.ContentType; +import org.apache.olingo.commons.api.http.HttpHeader; +import org.apache.olingo.commons.api.http.HttpStatusCode; +import org.apache.olingo.server.api.OData; +import org.apache.olingo.server.api.ODataApplicationException; +import org.apache.olingo.server.api.ODataLibraryException; +import org.apache.olingo.server.api.ODataRequest; +import org.apache.olingo.server.api.ODataResponse; +import org.apache.olingo.server.api.ServiceMetadata; +import org.apache.olingo.server.api.processor.EntityProcessor; +import org.apache.olingo.server.api.serializer.EntitySerializerOptions; +import org.apache.olingo.server.api.serializer.ODataSerializer; +import org.apache.olingo.server.api.serializer.SerializerResult; +import org.apache.olingo.server.api.uri.UriInfo; +import org.apache.olingo.server.api.uri.UriParameter; +import org.apache.olingo.server.api.uri.UriResource; +import org.apache.olingo.server.api.uri.UriResourceEntitySet; +import org.apache.olingo.server.api.uri.UriResourceNavigation; +import org.baeldung.examples.olingo4.repository.EdmEntityRepository; +import org.baeldung.examples.olingo4.repository.RepositoryRegistry; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Component; + +/** + * JpaEntityProcessor adapter. + *

This implementation is heavily based on the Tutorial available + * at Olingo's site. It is meant to be an starting point for an actual implementation.

+ *

Please note that many features from a full-fledged are missing + * @author Philippe + * + */ +@Component +public class JpaEntityProcessor implements EntityProcessor { + + private EntityManagerFactory emf; + private OData odata; + private ServiceMetadata serviceMetadata; + private RepositoryRegistry registry; + private JpaEntityMapper entityMapper; + + public JpaEntityProcessor(EntityManagerFactory emf, RepositoryRegistry registry, JpaEntityMapper entityMapper) { + this.emf = emf; + this.registry = registry; + this.entityMapper = entityMapper; + } + + /* (non-Javadoc) + * @see org.apache.olingo.server.api.processor.Processor#init(org.apache.olingo.server.api.OData, org.apache.olingo.server.api.ServiceMetadata) + */ + @Override + public void init(OData odata, ServiceMetadata serviceMetadata) { + this.odata = odata; + this.serviceMetadata = serviceMetadata; + + } + + /* (non-Javadoc) + * @see org.apache.olingo.server.api.processor.EntityProcessor#readEntity(org.apache.olingo.server.api.ODataRequest, org.apache.olingo.server.api.ODataResponse, org.apache.olingo.server.api.uri.UriInfo, org.apache.olingo.commons.api.format.ContentType) + */ + @Override + public void readEntity(ODataRequest request, ODataResponse response, UriInfo uriInfo, ContentType responseFormat) throws ODataApplicationException, ODataLibraryException { + + // First, we have to figure out which entity is requested + List resourceParts = uriInfo.getUriResourceParts(); + InputStream entityStream; + + UriResourceEntitySet rootResourceEntitySet = (UriResourceEntitySet) resourceParts.get(0); + EdmEntitySet rootEntitySet = rootResourceEntitySet.getEntitySet(); + List rootPredicates = rootResourceEntitySet.getKeyPredicates(); + + if ( resourceParts.size() == 1 ) { + entityStream = readRootEntity(rootEntitySet,rootPredicates,responseFormat); + } + else if ( resourceParts.size() == 2 ) { + UriResource part = resourceParts.get(1); + if ( !(part instanceof UriResourceNavigation)) { + throw new ODataRuntimeException("[E103] part type not supported: class=" + part.getClass().getName()); + } + + UriResourceNavigation navSegment = (UriResourceNavigation)part; + entityStream = readRelatedEntity(request, rootEntitySet,rootPredicates,navSegment.getProperty(),navSegment.getKeyPredicates(),responseFormat); + } + else { + // For now, we'll only allow navigation just to directly linked navs + throw new ODataApplicationException("[E109] Multi-level navigation not supported", HttpStatusCode.NOT_IMPLEMENTED.getStatusCode(), Locale.ROOT); + } + + //4. configure the response object + response.setContent(entityStream); + response.setStatusCode(HttpStatusCode.OK.getStatusCode()); + response.setHeader(HttpHeader.CONTENT_TYPE, responseFormat.toContentTypeString()); + + } + + + // Lookup the EntitySet associated with an EntityType + // In our example, we assume we have only one entityset for each entity type + private EdmEntitySet entitySetFromType(EdmEntityType type) { + return serviceMetadata + .getEdm() + .getEntityContainer() + .getEntitySets() + .stream() + .filter((s) -> s.getEntityType().getName().equals(type.getName())) + .findFirst() + .orElseThrow(() -> new ODataRuntimeException("[E144] No entity set found for type " + type.getFullQualifiedName())); + } + + // + // private boolean isOne2ManyProperty(EdmEntityType entityType, EdmNavigationProperty property) { + // return entityType.getProperty(property.getName()) != null && property.isCollection(); + //} + + @SuppressWarnings({ "rawtypes", "unchecked" }) + private InputStream readRootEntity(EdmEntitySet entitySet, List keyPredicates,ContentType responseFormat) throws ODataApplicationException, ODataLibraryException { + EdmEntityType type = entitySet.getEntityType(); + JpaRepository repo = registry.getRepositoryForEntity(type); + + // Get key value + Long keyValue = getEntityKey(keyPredicates); + Optional entry = repo.findById(keyValue); + if ( !entry.isPresent()) { + throw new ODataApplicationException( + "[E116] NO entity found for the given key", + HttpStatusCode.NOT_FOUND.getStatusCode(), + Locale.ENGLISH); + } + + Entity e = entityMapper.map2entity(entitySet, entry.get()); + return serializeEntity(entitySet,e,responseFormat); + } + + private InputStream serializeEntity(EdmEntitySet entitySet, Entity entity,ContentType responseFormat) throws ODataApplicationException, ODataLibraryException { + ContextURL contextUrl = ContextURL.with().entitySet(entitySet).build(); + // expand and select currently not supported + EntitySerializerOptions options = EntitySerializerOptions + .with() + .contextURL(contextUrl) + .build(); + + ODataSerializer serializer = odata.createSerializer(responseFormat); + + SerializerResult serializerResult = serializer.entity(serviceMetadata, entitySet.getEntityType(), entity, options); + return serializerResult.getContent(); + + } + +// @SuppressWarnings("unchecked") +// protected InputStream readRelatedEntities(EdmEntitySet rootEntitySet, List rootPredicates, EdmNavigationProperty property, ContentType responseFormat) throws ODataApplicationException { +// +// Object jpaEntity = readJPAEntity(rootEntitySet, rootPredicates); +// try { +// Collection set = (Collection)PropertyUtils.getProperty(jpaEntity, property.getName()); +// EdmEntitySet entitySet = entitySetFromType(property.getType()); +// ContextURL contextUrl = ContextURL +// .with() +// .entitySet(entitySet) +// .build(); +// +// EntityCollectionSerializerOptions options = EntityCollectionSerializerOptions +// .with() +// .contextURL(contextUrl) +// .build(); +// +// EntityCollection result = new EntityCollection(); +// +// set.stream() +// .map((o) -> this.entityMapper.map2entity(entitySet, o)) +// .forEach((e) -> result.getEntities().add(e)); +// +// ODataSerializer serializer = odata.createSerializer(responseFormat); +// SerializerResult serializerResult = serializer.entityCollection(serviceMetadata, property.getType(), result, options); +// return serializerResult.getContent(); +// } +// catch(Exception ex) { +// throw new ODataRuntimeException("[E181] Error accessing database", ex); +// } +// } + + @SuppressWarnings({ "rawtypes", "unchecked" }) + private InputStream readRelatedEntity(ODataRequest request, EdmEntitySet entitySet, List rootPredicates, EdmNavigationProperty property, List parentPredicates, ContentType responseFormat) throws ODataApplicationException, ODataLibraryException { + + + JpaRepository repo = (JpaRepository)registry.getRepositoryForEntity(entitySet.getEntityType()); + EdmEntityRepository relatedRepo = (EdmEntityRepository)registry.getRepositoryForEntity(property.getType()); + + // We assume here that we have a bi-directional 1:N relationship, so we'll + // always have a property in the child entity that points to the parent + Class rootClass = ((EdmEntityRepository)repo).getEntityClass(); + Class relatedClass = ((EdmEntityRepository)relatedRepo).getEntityClass(); + + SingularAttribute fk = emf.getMetamodel() + .entity(rootClass) + .getSingularAttributes() + .stream() + .filter((attr) -> { + boolean b = attr.isAssociation() && attr.getJavaType().isAssignableFrom(relatedClass); + return b; + }) + .findFirst() + .orElse(null); + + if ( fk == null ) { + throw new ODataRuntimeException("[E230] No singular attribute of child class '" + relatedClass.getName() + "' found" ); + } + + Long pkValue = getEntityKey(rootPredicates); + EntityManager em = this.emf.createEntityManager(); + try { + // Read data from DB + Object root = em.find(rootClass, pkValue); + Object related = this.entityMapper.getPropertyValue(root, fk.getName()); + + EdmEntitySet relatedEntitySet = entitySetFromType(property.getType()); + Entity e = entityMapper.map2entity(relatedEntitySet, related); + return serializeEntity(relatedEntitySet,e,responseFormat); + } + finally { + em.close(); + } + } + +// @SuppressWarnings("unchecked") +// private Object readJPAEntity(EdmEntitySet edmEntitySet, List keyPredicates) throws ODataApplicationException { +// EdmEntityType type = edmEntitySet.getEntityType(); +// JpaRepository repo = (JpaRepository)registry.getRepositoryForEntity(type); +// +// // Get key value +// Object keyValue = getEntityKey(type,keyPredicates); +// Object entry = repo +// .findById(keyValue) +// .orElseThrow( +// () -> new ODataApplicationException("[E116] NO entity found for the given key", +// HttpStatusCode.NOT_FOUND.getStatusCode(), Locale.ENGLISH)); +// +// return entry; +// } + + private Long getEntityKey(List keyPredicates) { + + if ( keyPredicates.size() > 1 ) { + throw new ODataRuntimeException("[E131] Composite keys are not supported"); + } + + // For now, we'll assume we only have numeric keys. + UriParameter keyParam = keyPredicates.get(0); + try { + return Long.parseLong(keyParam.getText()); + } + catch(NumberFormatException nfe) { + throw new ODataRuntimeException("[E140] Invalid key value. Only numeric keys are supported by this service"); + } + + + } + + /* (non-Javadoc) + * @see org.apache.olingo.server.api.processor.EntityProcessor#createEntity(org.apache.olingo.server.api.ODataRequest, org.apache.olingo.server.api.ODataResponse, org.apache.olingo.server.api.uri.UriInfo, org.apache.olingo.commons.api.format.ContentType, org.apache.olingo.commons.api.format.ContentType) + */ + @Override + public void createEntity(ODataRequest request, ODataResponse response, UriInfo uriInfo, ContentType requestFormat, ContentType responseFormat) throws ODataApplicationException, ODataLibraryException { + // TODO Auto-generated method stub + + } + + /* (non-Javadoc) + * @see org.apache.olingo.server.api.processor.EntityProcessor#updateEntity(org.apache.olingo.server.api.ODataRequest, org.apache.olingo.server.api.ODataResponse, org.apache.olingo.server.api.uri.UriInfo, org.apache.olingo.commons.api.format.ContentType, org.apache.olingo.commons.api.format.ContentType) + */ + @Override + public void updateEntity(ODataRequest request, ODataResponse response, UriInfo uriInfo, ContentType requestFormat, ContentType responseFormat) throws ODataApplicationException, ODataLibraryException { + // TODO Auto-generated method stub + + } + + /* (non-Javadoc) + * @see org.apache.olingo.server.api.processor.EntityProcessor#deleteEntity(org.apache.olingo.server.api.ODataRequest, org.apache.olingo.server.api.ODataResponse, org.apache.olingo.server.api.uri.UriInfo) + */ + @Override + public void deleteEntity(ODataRequest request, ODataResponse response, UriInfo uriInfo) throws ODataApplicationException, ODataLibraryException { + // TODO Auto-generated method stub + + } + +} diff --git a/apache-olingo/olingo4/src/main/java/org/baeldung/examples/olingo4/repository/CarMakerRepository.java b/apache-olingo/olingo4/src/main/java/org/baeldung/examples/olingo4/repository/CarMakerRepository.java new file mode 100644 index 0000000000..1bde9f148c --- /dev/null +++ b/apache-olingo/olingo4/src/main/java/org/baeldung/examples/olingo4/repository/CarMakerRepository.java @@ -0,0 +1,16 @@ +package org.baeldung.examples.olingo4.repository; + +import org.baeldung.examples.olingo4.domain.CarMaker; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.JpaSpecificationExecutor; +import org.springframework.stereotype.Repository; + +@Repository +public interface CarMakerRepository extends EdmEntityRepository, JpaRepository, JpaSpecificationExecutor { + + public default String getEdmEntityName() { return CarMaker.class.getSimpleName();} + @Override + default Class getEntityClass() { + return CarMaker.class; + } +} diff --git a/apache-olingo/olingo4/src/main/java/org/baeldung/examples/olingo4/repository/CarModelRepository.java b/apache-olingo/olingo4/src/main/java/org/baeldung/examples/olingo4/repository/CarModelRepository.java new file mode 100644 index 0000000000..247bf6e77b --- /dev/null +++ b/apache-olingo/olingo4/src/main/java/org/baeldung/examples/olingo4/repository/CarModelRepository.java @@ -0,0 +1,22 @@ +package org.baeldung.examples.olingo4.repository; + +import java.util.List; + +import org.baeldung.examples.olingo4.domain.CarModel; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.JpaSpecificationExecutor; +import org.springframework.stereotype.Repository; + +@Repository +public interface CarModelRepository extends EdmEntityRepository, JpaRepository, JpaSpecificationExecutor { + + public List findByMakerId(Long makerId); + + public default String getEdmEntityName() { return CarModel.class.getSimpleName();} + + @Override + default Class getEntityClass() { + return CarModel.class; + } + +} diff --git a/apache-olingo/olingo4/src/main/java/org/baeldung/examples/olingo4/repository/EdmEntityRepository.java b/apache-olingo/olingo4/src/main/java/org/baeldung/examples/olingo4/repository/EdmEntityRepository.java new file mode 100644 index 0000000000..dbfd0e6f93 --- /dev/null +++ b/apache-olingo/olingo4/src/main/java/org/baeldung/examples/olingo4/repository/EdmEntityRepository.java @@ -0,0 +1,17 @@ +/** + * + */ +package org.baeldung.examples.olingo4.repository; + + +/** + * @author Philippe + * + */ +public interface EdmEntityRepository { + + public String getEdmEntityName(); + public Class getEntityClass(); + + +} diff --git a/apache-olingo/olingo4/src/main/java/org/baeldung/examples/olingo4/repository/RepositoryRegistry.java b/apache-olingo/olingo4/src/main/java/org/baeldung/examples/olingo4/repository/RepositoryRegistry.java new file mode 100644 index 0000000000..e3bb172e3a --- /dev/null +++ b/apache-olingo/olingo4/src/main/java/org/baeldung/examples/olingo4/repository/RepositoryRegistry.java @@ -0,0 +1,29 @@ +package org.baeldung.examples.olingo4.repository; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.apache.olingo.commons.api.edm.EdmEntityType; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Component; + +@Component +public class RepositoryRegistry { + + private Map> repositoriesByClassName = new HashMap<>(); + + public RepositoryRegistry(List> allRepositories) { + + allRepositories.stream() + .forEach((r) -> + repositoriesByClassName.put(r.getEdmEntityName(),(JpaRepository)r)); + + } + + + public JpaRepository getRepositoryForEntity(EdmEntityType entityType) { + JpaRepository repo = repositoriesByClassName.get(entityType.getName()); + return repo; + } +} diff --git a/apache-olingo/olingo4/src/main/resources/application.properties b/apache-olingo/olingo4/src/main/resources/application.properties new file mode 100644 index 0000000000..02c7fe5c4d --- /dev/null +++ b/apache-olingo/olingo4/src/main/resources/application.properties @@ -0,0 +1,9 @@ +server: + port: 8080 + +spring: + jpa: + show-sql: true + open-in-view: true + hibernate: + ddl-auto: update diff --git a/apache-olingo/olingo4/src/main/resources/data.sql b/apache-olingo/olingo4/src/main/resources/data.sql new file mode 100644 index 0000000000..327f2688c5 --- /dev/null +++ b/apache-olingo/olingo4/src/main/resources/data.sql @@ -0,0 +1,12 @@ +insert into car_maker(id,name) values (1,'Special Motors'); +insert into car_maker(id,name) values (2,'BWM'); +insert into car_maker(id,name) values (3,'Dolores'); + +insert into car_model(id,maker_fk,name,sku,year) values(1,1,'Muze','SM001',2018); +insert into car_model(id,maker_fk,name,sku,year) values(2,1,'Empada','SM002',2008); + +insert into car_model(id,maker_fk,name,sku,year) values(4,2,'BWM-100','BWM100',2008); +insert into car_model(id,maker_fk,name,sku,year) values(5,2,'BWM-200','BWM200',2009); +insert into car_model(id,maker_fk,name,sku,year) values(6,2,'BWM-300','BWM300',2008); + +alter sequence hibernate_sequence restart with 100; \ No newline at end of file diff --git a/apache-olingo/olingo4/src/test/java/org/baeldung/examples/olingo4/Olingo4SampleApplicationTests.java b/apache-olingo/olingo4/src/test/java/org/baeldung/examples/olingo4/Olingo4SampleApplicationTests.java new file mode 100644 index 0000000000..5d23a4148e --- /dev/null +++ b/apache-olingo/olingo4/src/test/java/org/baeldung/examples/olingo4/Olingo4SampleApplicationTests.java @@ -0,0 +1,16 @@ +package org.baeldung.examples.olingo4; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; + +@RunWith(SpringRunner.class) +@SpringBootTest +public class Olingo4SampleApplicationTests { + + @Test + public void contextLoads() { + } + +} diff --git a/apache-velocity/pom.xml b/apache-velocity/pom.xml index a0a8389f7d..24ab0b861d 100644 --- a/apache-velocity/pom.xml +++ b/apache-velocity/pom.xml @@ -59,7 +59,6 @@ - 1.2 4.5.2 1.7 2.0 diff --git a/cdi/pom.xml b/cdi/pom.xml index 85da8518d0..c98ad57495 100644 --- a/cdi/pom.xml +++ b/cdi/pom.xml @@ -27,7 +27,7 @@ org.hamcrest hamcrest-core - ${hamcrest-core.version} + ${org.hamcrest.version} test @@ -64,7 +64,6 @@ 2.0.SP1 3.0.5.Final 1.9.2 - 1.3 3.10.0 5.1.2.RELEASE diff --git a/cloud-foundry-uaa/cf-uaa-oauth2-client/pom.xml b/cloud-foundry-uaa/cf-uaa-oauth2-client/pom.xml index f650498b69..c6de00dbe9 100644 --- a/cloud-foundry-uaa/cf-uaa-oauth2-client/pom.xml +++ b/cloud-foundry-uaa/cf-uaa-oauth2-client/pom.xml @@ -34,8 +34,5 @@ - - - 1.8 - + diff --git a/cloud-foundry-uaa/cf-uaa-oauth2-resource-server/pom.xml b/cloud-foundry-uaa/cf-uaa-oauth2-resource-server/pom.xml index 710cecbd4e..56fb23e9d8 100644 --- a/cloud-foundry-uaa/cf-uaa-oauth2-resource-server/pom.xml +++ b/cloud-foundry-uaa/cf-uaa-oauth2-resource-server/pom.xml @@ -35,8 +35,4 @@ - - 1.8 - - diff --git a/core-groovy/.gitignore b/core-groovy/.gitignore new file mode 100644 index 0000000000..09220fdf52 --- /dev/null +++ b/core-groovy/.gitignore @@ -0,0 +1 @@ +/src/main/resources/ioSerializedObject.txt \ No newline at end of file diff --git a/core-groovy/src/main/resources/ioSerializedObject.txt b/core-groovy/src/main/resources/ioSerializedObject.txt deleted file mode 100644 index 833ed32bf1..0000000000 Binary files a/core-groovy/src/main/resources/ioSerializedObject.txt and /dev/null differ diff --git a/core-groovy/src/test/groovy/com/baeldung/io/DataAndObjectsUnitTest.groovy b/core-groovy/src/test/groovy/com/baeldung/io/DataAndObjectsUnitTest.groovy index 0b413cf76c..32a21f6b38 100644 --- a/core-groovy/src/test/groovy/com/baeldung/io/DataAndObjectsUnitTest.groovy +++ b/core-groovy/src/test/groovy/com/baeldung/io/DataAndObjectsUnitTest.groovy @@ -34,7 +34,9 @@ class DataAndObjectsUnitTest { @Test void whenUsingWithObjectOutputStream_thenObjectIsSerializedToFile() { Task task = new Task(description:'Take out the trash', startDate:new Date(), status:0) - new File('src/main/resources/ioSerializedObject.txt').withObjectOutputStream { out -> + def serializedDataFile = new File('src/main/resources/ioSerializedObject.txt') + serializedDataFile.createNewFile() + serializedDataFile.withObjectOutputStream { out -> out.writeObject(task) } diff --git a/core-java-lang/native/nativedatetimeutils.dll b/core-java-lang/native/nativedatetimeutils.dll deleted file mode 100644 index ecdd388380..0000000000 Binary files a/core-java-lang/native/nativedatetimeutils.dll and /dev/null differ diff --git a/core-java-modules/README.md b/core-java-modules/README.md new file mode 100644 index 0000000000..a90535a44f --- /dev/null +++ b/core-java-modules/README.md @@ -0,0 +1,3 @@ +## Relevant articles: + +- [Multi-Module Maven Application with Java Modules](https://www.baeldung.com/maven-multi-module-project-java-jpms) diff --git a/core-java-10/README.md b/core-java-modules/core-java-10/README.md similarity index 100% rename from core-java-10/README.md rename to core-java-modules/core-java-10/README.md diff --git a/core-java-10/pom.xml b/core-java-modules/core-java-10/pom.xml similarity index 96% rename from core-java-10/pom.xml rename to core-java-modules/core-java-10/pom.xml index b15f8b5d63..7163619679 100644 --- a/core-java-10/pom.xml +++ b/core-java-modules/core-java-10/pom.xml @@ -12,6 +12,7 @@ com.baeldung parent-modules 1.0.0-SNAPSHOT + ../../ diff --git a/core-java-10/src/main/java/com/baeldung/App.java b/core-java-modules/core-java-10/src/main/java/com/baeldung/App.java similarity index 100% rename from core-java-10/src/main/java/com/baeldung/App.java rename to core-java-modules/core-java-10/src/main/java/com/baeldung/App.java diff --git a/core-java-10/src/main/java/com/baeldung/graal/CountUppercase.java b/core-java-modules/core-java-10/src/main/java/com/baeldung/graal/CountUppercase.java similarity index 100% rename from core-java-10/src/main/java/com/baeldung/graal/CountUppercase.java rename to core-java-modules/core-java-10/src/main/java/com/baeldung/graal/CountUppercase.java diff --git a/core-java-10/src/main/resources/logback.xml b/core-java-modules/core-java-10/src/main/resources/logback.xml similarity index 100% rename from core-java-10/src/main/resources/logback.xml rename to core-java-modules/core-java-10/src/main/resources/logback.xml diff --git a/core-java-10/src/test/java/com/baeldung/AppTest.java b/core-java-modules/core-java-10/src/test/java/com/baeldung/AppTest.java similarity index 100% rename from core-java-10/src/test/java/com/baeldung/AppTest.java rename to core-java-modules/core-java-10/src/test/java/com/baeldung/AppTest.java diff --git a/core-java-10/src/test/java/com/baeldung/java10/Java10FeaturesUnitTest.java b/core-java-modules/core-java-10/src/test/java/com/baeldung/java10/Java10FeaturesUnitTest.java similarity index 100% rename from core-java-10/src/test/java/com/baeldung/java10/Java10FeaturesUnitTest.java rename to core-java-modules/core-java-10/src/test/java/com/baeldung/java10/Java10FeaturesUnitTest.java diff --git a/core-java-10/src/test/java/com/baeldung/java10/list/CopyListServiceUnitTest.java b/core-java-modules/core-java-10/src/test/java/com/baeldung/java10/list/CopyListServiceUnitTest.java similarity index 100% rename from core-java-10/src/test/java/com/baeldung/java10/list/CopyListServiceUnitTest.java rename to core-java-modules/core-java-10/src/test/java/com/baeldung/java10/list/CopyListServiceUnitTest.java diff --git a/core-java-11/README.md b/core-java-modules/core-java-11/README.md similarity index 100% rename from core-java-11/README.md rename to core-java-modules/core-java-11/README.md diff --git a/core-java-11/pom.xml b/core-java-modules/core-java-11/pom.xml similarity index 97% rename from core-java-11/pom.xml rename to core-java-modules/core-java-11/pom.xml index 933acdbecc..b78c141552 100644 --- a/core-java-11/pom.xml +++ b/core-java-modules/core-java-11/pom.xml @@ -12,6 +12,7 @@ com.baeldung parent-modules 1.0.0-SNAPSHOT + ../../ diff --git a/core-java-11/src/main/java/com/baeldung/App.java b/core-java-modules/core-java-11/src/main/java/com/baeldung/App.java similarity index 100% rename from core-java-11/src/main/java/com/baeldung/App.java rename to core-java-modules/core-java-11/src/main/java/com/baeldung/App.java diff --git a/core-java-11/src/main/java/com/baeldung/Outer.java b/core-java-modules/core-java-11/src/main/java/com/baeldung/Outer.java similarity index 100% rename from core-java-11/src/main/java/com/baeldung/Outer.java rename to core-java-modules/core-java-11/src/main/java/com/baeldung/Outer.java diff --git a/core-java-11/src/main/java/com/baeldung/add b/core-java-modules/core-java-11/src/main/java/com/baeldung/add old mode 100755 new mode 100644 similarity index 100% rename from core-java-11/src/main/java/com/baeldung/add rename to core-java-modules/core-java-11/src/main/java/com/baeldung/add diff --git a/core-java-11/src/main/java/com/baeldung/epsilongc/MemoryPolluter.java b/core-java-modules/core-java-11/src/main/java/com/baeldung/epsilongc/MemoryPolluter.java similarity index 100% rename from core-java-11/src/main/java/com/baeldung/epsilongc/MemoryPolluter.java rename to core-java-modules/core-java-11/src/main/java/com/baeldung/epsilongc/MemoryPolluter.java diff --git a/core-java-11/src/main/java/com/baeldung/java11/httpclient/HttpClientExample.java b/core-java-modules/core-java-11/src/main/java/com/baeldung/java11/httpclient/HttpClientExample.java similarity index 97% rename from core-java-11/src/main/java/com/baeldung/java11/httpclient/HttpClientExample.java rename to core-java-modules/core-java-11/src/main/java/com/baeldung/java11/httpclient/HttpClientExample.java index fb4abd3bb6..725f969596 100644 --- a/core-java-11/src/main/java/com/baeldung/java11/httpclient/HttpClientExample.java +++ b/core-java-modules/core-java-11/src/main/java/com/baeldung/java11/httpclient/HttpClientExample.java @@ -1,132 +1,132 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package com.baeldung.java11.httpclient; - -import java.io.IOException; -import java.net.URI; -import java.net.URISyntaxException; -import java.net.http.HttpClient; -import java.net.http.HttpClient.Version; -import java.net.http.HttpRequest; -import java.net.http.HttpRequest.BodyPublishers; -import java.net.http.HttpResponse; -import java.net.http.HttpResponse.BodyHandlers; -import java.net.http.HttpResponse.PushPromiseHandler; -import java.util.Arrays; -import java.util.List; -import java.util.concurrent.CompletableFuture; -import java.util.function.Function; -import java.util.stream.Collectors; - -public class HttpClientExample { - - public static void main(String[] args) throws Exception { - httpGetRequest(); - httpPostRequest(); - asynchronousGetRequest(); - asynchronousMultipleRequests(); - pushRequest(); - } - - public static void httpGetRequest() throws URISyntaxException, IOException, InterruptedException { - HttpClient client = HttpClient.newHttpClient(); - HttpRequest request = HttpRequest.newBuilder() - .version(HttpClient.Version.HTTP_2) - .uri(URI.create("http://jsonplaceholder.typicode.com/posts/1")) - .headers("Accept-Enconding", "gzip, deflate") - .build(); - HttpResponse response = client.send(request, BodyHandlers.ofString()); - - String responseBody = response.body(); - int responseStatusCode = response.statusCode(); - - System.out.println("httpGetRequest: " + responseBody); - System.out.println("httpGetRequest status code: " + responseStatusCode); - } - - public static void httpPostRequest() throws URISyntaxException, IOException, InterruptedException { - HttpClient client = HttpClient.newBuilder() - .version(HttpClient.Version.HTTP_2) - .build(); - HttpRequest request = HttpRequest.newBuilder(new URI("http://jsonplaceholder.typicode.com/posts")) - .version(HttpClient.Version.HTTP_2) - .POST(BodyPublishers.ofString("Sample Post Request")) - .build(); - HttpResponse response = client.send(request, BodyHandlers.ofString()); - String responseBody = response.body(); - System.out.println("httpPostRequest : " + responseBody); - } - - public static void asynchronousGetRequest() throws URISyntaxException { - HttpClient client = HttpClient.newHttpClient(); - URI httpURI = new URI("http://jsonplaceholder.typicode.com/posts/1"); - HttpRequest request = HttpRequest.newBuilder(httpURI) - .version(HttpClient.Version.HTTP_2) - .build(); - CompletableFuture futureResponse = client.sendAsync(request, HttpResponse.BodyHandlers.ofString()) - .thenAccept(resp -> { - System.out.println("Got pushed response " + resp.uri()); - System.out.println("Response statuscode: " + resp.statusCode()); - System.out.println("Response body: " + resp.body()); - }); - System.out.println("futureResponse" + futureResponse); - - } - - public static void asynchronousMultipleRequests() throws URISyntaxException { - HttpClient client = HttpClient.newHttpClient(); - List uris = Arrays.asList(new URI("http://jsonplaceholder.typicode.com/posts/1"), new URI("http://jsonplaceholder.typicode.com/posts/2")); - List requests = uris.stream() - .map(HttpRequest::newBuilder) - .map(reqBuilder -> reqBuilder.build()) - .collect(Collectors.toList()); - System.out.println("Got pushed response1 " + requests); - CompletableFuture.allOf(requests.stream() - .map(request -> client.sendAsync(request, BodyHandlers.ofString())) - .toArray(CompletableFuture[]::new)) - .thenAccept(System.out::println) - .join(); - } - - public static void pushRequest() throws URISyntaxException, InterruptedException { - System.out.println("Running HTTP/2 Server Push example..."); - - HttpClient httpClient = HttpClient.newBuilder() - .version(Version.HTTP_2) - .build(); - - HttpRequest pageRequest = HttpRequest.newBuilder() - .uri(URI.create("https://http2.golang.org/serverpush")) - .build(); - - // Interface HttpResponse.PushPromiseHandler - // void applyPushPromise​(HttpRequest initiatingRequest, HttpRequest pushPromiseRequest, Function,​CompletableFuture>> acceptor) - httpClient.sendAsync(pageRequest, BodyHandlers.ofString(), pushPromiseHandler()) - .thenAccept(pageResponse -> { - System.out.println("Page response status code: " + pageResponse.statusCode()); - System.out.println("Page response headers: " + pageResponse.headers()); - String responseBody = pageResponse.body(); - System.out.println(responseBody); - }).join(); - - Thread.sleep(1000); // waiting for full response - } - - private static PushPromiseHandler pushPromiseHandler() { - return (HttpRequest initiatingRequest, - HttpRequest pushPromiseRequest, - Function, - CompletableFuture>> acceptor) -> { - acceptor.apply(BodyHandlers.ofString()) - .thenAccept(resp -> { - System.out.println(" Pushed response: " + resp.uri() + ", headers: " + resp.headers()); - }); - System.out.println("Promise request: " + pushPromiseRequest.uri()); - System.out.println("Promise request: " + pushPromiseRequest.headers()); - }; - } - -} +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package com.baeldung.java11.httpclient; + +import java.io.IOException; +import java.net.URI; +import java.net.URISyntaxException; +import java.net.http.HttpClient; +import java.net.http.HttpClient.Version; +import java.net.http.HttpRequest; +import java.net.http.HttpRequest.BodyPublishers; +import java.net.http.HttpResponse; +import java.net.http.HttpResponse.BodyHandlers; +import java.net.http.HttpResponse.PushPromiseHandler; +import java.util.Arrays; +import java.util.List; +import java.util.concurrent.CompletableFuture; +import java.util.function.Function; +import java.util.stream.Collectors; + +public class HttpClientExample { + + public static void main(String[] args) throws Exception { + httpGetRequest(); + httpPostRequest(); + asynchronousGetRequest(); + asynchronousMultipleRequests(); + pushRequest(); + } + + public static void httpGetRequest() throws URISyntaxException, IOException, InterruptedException { + HttpClient client = HttpClient.newHttpClient(); + HttpRequest request = HttpRequest.newBuilder() + .version(HttpClient.Version.HTTP_2) + .uri(URI.create("http://jsonplaceholder.typicode.com/posts/1")) + .headers("Accept-Enconding", "gzip, deflate") + .build(); + HttpResponse response = client.send(request, BodyHandlers.ofString()); + + String responseBody = response.body(); + int responseStatusCode = response.statusCode(); + + System.out.println("httpGetRequest: " + responseBody); + System.out.println("httpGetRequest status code: " + responseStatusCode); + } + + public static void httpPostRequest() throws URISyntaxException, IOException, InterruptedException { + HttpClient client = HttpClient.newBuilder() + .version(HttpClient.Version.HTTP_2) + .build(); + HttpRequest request = HttpRequest.newBuilder(new URI("http://jsonplaceholder.typicode.com/posts")) + .version(HttpClient.Version.HTTP_2) + .POST(BodyPublishers.ofString("Sample Post Request")) + .build(); + HttpResponse response = client.send(request, BodyHandlers.ofString()); + String responseBody = response.body(); + System.out.println("httpPostRequest : " + responseBody); + } + + public static void asynchronousGetRequest() throws URISyntaxException { + HttpClient client = HttpClient.newHttpClient(); + URI httpURI = new URI("http://jsonplaceholder.typicode.com/posts/1"); + HttpRequest request = HttpRequest.newBuilder(httpURI) + .version(HttpClient.Version.HTTP_2) + .build(); + CompletableFuture futureResponse = client.sendAsync(request, HttpResponse.BodyHandlers.ofString()) + .thenAccept(resp -> { + System.out.println("Got pushed response " + resp.uri()); + System.out.println("Response statuscode: " + resp.statusCode()); + System.out.println("Response body: " + resp.body()); + }); + System.out.println("futureResponse" + futureResponse); + + } + + public static void asynchronousMultipleRequests() throws URISyntaxException { + HttpClient client = HttpClient.newHttpClient(); + List uris = Arrays.asList(new URI("http://jsonplaceholder.typicode.com/posts/1"), new URI("http://jsonplaceholder.typicode.com/posts/2")); + List requests = uris.stream() + .map(HttpRequest::newBuilder) + .map(reqBuilder -> reqBuilder.build()) + .collect(Collectors.toList()); + System.out.println("Got pushed response1 " + requests); + CompletableFuture.allOf(requests.stream() + .map(request -> client.sendAsync(request, BodyHandlers.ofString())) + .toArray(CompletableFuture[]::new)) + .thenAccept(System.out::println) + .join(); + } + + public static void pushRequest() throws URISyntaxException, InterruptedException { + System.out.println("Running HTTP/2 Server Push example..."); + + HttpClient httpClient = HttpClient.newBuilder() + .version(Version.HTTP_2) + .build(); + + HttpRequest pageRequest = HttpRequest.newBuilder() + .uri(URI.create("https://http2.golang.org/serverpush")) + .build(); + + // Interface HttpResponse.PushPromiseHandler + // void applyPushPromise​(HttpRequest initiatingRequest, HttpRequest pushPromiseRequest, Function,​CompletableFuture>> acceptor) + httpClient.sendAsync(pageRequest, BodyHandlers.ofString(), pushPromiseHandler()) + .thenAccept(pageResponse -> { + System.out.println("Page response status code: " + pageResponse.statusCode()); + System.out.println("Page response headers: " + pageResponse.headers()); + String responseBody = pageResponse.body(); + System.out.println(responseBody); + }).join(); + + Thread.sleep(1000); // waiting for full response + } + + private static PushPromiseHandler pushPromiseHandler() { + return (HttpRequest initiatingRequest, + HttpRequest pushPromiseRequest, + Function, + CompletableFuture>> acceptor) -> { + acceptor.apply(BodyHandlers.ofString()) + .thenAccept(resp -> { + System.out.println(" Pushed response: " + resp.uri() + ", headers: " + resp.headers()); + }); + System.out.println("Promise request: " + pushPromiseRequest.uri()); + System.out.println("Promise request: " + pushPromiseRequest.headers()); + }; + } + +} diff --git a/core-java-11/src/main/resources/logback.xml b/core-java-modules/core-java-11/src/main/resources/logback.xml similarity index 100% rename from core-java-11/src/main/resources/logback.xml rename to core-java-modules/core-java-11/src/main/resources/logback.xml diff --git a/core-java-11/src/modules/jlinkModule/com/baeldung/jlink/HelloWorld.java b/core-java-modules/core-java-11/src/modules/jlinkModule/com/baeldung/jlink/HelloWorld.java similarity index 100% rename from core-java-11/src/modules/jlinkModule/com/baeldung/jlink/HelloWorld.java rename to core-java-modules/core-java-11/src/modules/jlinkModule/com/baeldung/jlink/HelloWorld.java diff --git a/core-java-11/src/modules/jlinkModule/module-info.java b/core-java-modules/core-java-11/src/modules/jlinkModule/module-info.java similarity index 100% rename from core-java-11/src/modules/jlinkModule/module-info.java rename to core-java-modules/core-java-11/src/modules/jlinkModule/module-info.java diff --git a/core-java-11/src/test/java/com/baeldung/AppTest.java b/core-java-modules/core-java-11/src/test/java/com/baeldung/AppTest.java similarity index 100% rename from core-java-11/src/test/java/com/baeldung/AppTest.java rename to core-java-modules/core-java-11/src/test/java/com/baeldung/AppTest.java diff --git a/core-java-11/src/test/java/com/baeldung/EmptyStringToEmptyOptionalUnitTest.java b/core-java-modules/core-java-11/src/test/java/com/baeldung/EmptyStringToEmptyOptionalUnitTest.java similarity index 100% rename from core-java-11/src/test/java/com/baeldung/EmptyStringToEmptyOptionalUnitTest.java rename to core-java-modules/core-java-11/src/test/java/com/baeldung/EmptyStringToEmptyOptionalUnitTest.java diff --git a/core-java-11/src/test/java/com/baeldung/NewStringAPIUnitTest.java b/core-java-modules/core-java-11/src/test/java/com/baeldung/NewStringAPIUnitTest.java similarity index 100% rename from core-java-11/src/test/java/com/baeldung/NewStringAPIUnitTest.java rename to core-java-modules/core-java-11/src/test/java/com/baeldung/NewStringAPIUnitTest.java diff --git a/core-java-11/src/test/java/com/baeldung/OuterUnitTest.java b/core-java-modules/core-java-11/src/test/java/com/baeldung/OuterUnitTest.java similarity index 100% rename from core-java-11/src/test/java/com/baeldung/OuterUnitTest.java rename to core-java-modules/core-java-11/src/test/java/com/baeldung/OuterUnitTest.java diff --git a/core-java-11/src/test/java/com/baeldung/java11/httpclient/test/HttpClientTest.java b/core-java-modules/core-java-11/src/test/java/com/baeldung/java11/httpclient/test/HttpClientTest.java similarity index 97% rename from core-java-11/src/test/java/com/baeldung/java11/httpclient/test/HttpClientTest.java rename to core-java-modules/core-java-11/src/test/java/com/baeldung/java11/httpclient/test/HttpClientTest.java index bade666636..0e9c12675c 100644 --- a/core-java-11/src/test/java/com/baeldung/java11/httpclient/test/HttpClientTest.java +++ b/core-java-modules/core-java-11/src/test/java/com/baeldung/java11/httpclient/test/HttpClientTest.java @@ -1,240 +1,240 @@ -package com.baeldung.java11.httpclient.test; - -import static org.hamcrest.CoreMatchers.containsString; -import static org.hamcrest.CoreMatchers.equalTo; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import java.io.IOException; -import java.net.Authenticator; -import java.net.CookieManager; -import java.net.CookiePolicy; -import java.net.HttpURLConnection; -import java.net.PasswordAuthentication; -import java.net.ProxySelector; -import java.net.URI; -import java.net.URISyntaxException; -import java.net.http.HttpClient; -import java.net.http.HttpRequest; -import java.net.http.HttpResponse; -import java.net.http.HttpResponse.BodyHandlers; -import java.util.Arrays; -import java.util.List; -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.CompletionException; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.TimeUnit; -import java.util.stream.Collectors; - -import org.junit.jupiter.api.Test; - -public class HttpClientTest { - - @Test - public void shouldReturnSampleDataContentWhenConnectViaSystemProxy() throws IOException, InterruptedException, URISyntaxException { - HttpRequest request = HttpRequest.newBuilder() - .uri(new URI("https://postman-echo.com/post")) - .headers("Content-Type", "text/plain;charset=UTF-8") - .POST(HttpRequest.BodyPublishers.ofString("Sample body")) - .build(); - - - HttpResponse response = HttpClient.newBuilder() - .proxy(ProxySelector.getDefault()) - .build() - .send(request, HttpResponse.BodyHandlers.ofString()); - - assertThat(response.statusCode(), equalTo(HttpURLConnection.HTTP_OK)); - assertThat(response.body(), containsString("Sample body")); - } - - @Test - public void shouldNotFollowRedirectWhenSetToDefaultNever() throws IOException, InterruptedException, URISyntaxException { - HttpRequest request = HttpRequest.newBuilder() - .uri(new URI("http://stackoverflow.com")) - .version(HttpClient.Version.HTTP_1_1) - .GET() - .build(); - HttpResponse response = HttpClient.newBuilder() - .build() - .send(request, HttpResponse.BodyHandlers.ofString()); - - assertThat(response.statusCode(), equalTo(HttpURLConnection.HTTP_MOVED_PERM)); - assertThat(response.body(), containsString("https://stackoverflow.com/")); - } - - @Test - public void shouldFollowRedirectWhenSetToAlways() throws IOException, InterruptedException, URISyntaxException { - HttpRequest request = HttpRequest.newBuilder() - .uri(new URI("http://stackoverflow.com")) - .version(HttpClient.Version.HTTP_1_1) - .GET() - .build(); - HttpResponse response = HttpClient.newBuilder() - .followRedirects(HttpClient.Redirect.ALWAYS) - .build() - .send(request, HttpResponse.BodyHandlers.ofString()); - - assertThat(response.statusCode(), equalTo(HttpURLConnection.HTTP_OK)); - assertThat(response.request() - .uri() - .toString(), equalTo("https://stackoverflow.com/")); - } - - @Test - public void shouldReturnOKStatusForAuthenticatedAccess() throws URISyntaxException, IOException, InterruptedException { - HttpRequest request = HttpRequest.newBuilder() - .uri(new URI("https://postman-echo.com/basic-auth")) - .GET() - .build(); - HttpResponse response = HttpClient.newBuilder() - .authenticator(new Authenticator() { - @Override - protected PasswordAuthentication getPasswordAuthentication() { - return new PasswordAuthentication("postman", "password".toCharArray()); - } - }) - .build() - .send(request, HttpResponse.BodyHandlers.ofString()); - - assertThat(response.statusCode(), equalTo(HttpURLConnection.HTTP_OK)); - } - - @Test - public void shouldSendRequestAsync() throws URISyntaxException, InterruptedException, ExecutionException { - HttpRequest request = HttpRequest.newBuilder() - .uri(new URI("https://postman-echo.com/post")) - .headers("Content-Type", "text/plain;charset=UTF-8") - .POST(HttpRequest.BodyPublishers.ofString("Sample body")) - .build(); - CompletableFuture> response = HttpClient.newBuilder() - .build() - .sendAsync(request, HttpResponse.BodyHandlers.ofString()); - - assertThat(response.get() - .statusCode(), equalTo(HttpURLConnection.HTTP_OK)); - } - - @Test - public void shouldUseJustTwoThreadWhenProcessingSendAsyncRequest() throws URISyntaxException, InterruptedException, ExecutionException { - HttpRequest request = HttpRequest.newBuilder() - .uri(new URI("https://postman-echo.com/get")) - .GET() - .build(); - - ExecutorService executorService = Executors.newFixedThreadPool(2); - - CompletableFuture> response1 = HttpClient.newBuilder() - .executor(executorService) - .build() - .sendAsync(request, HttpResponse.BodyHandlers.ofString()); - - CompletableFuture> response2 = HttpClient.newBuilder() - .executor(executorService) - .build() - .sendAsync(request, HttpResponse.BodyHandlers.ofString()); - - CompletableFuture> response3 = HttpClient.newBuilder() - .executor(executorService) - .build() - .sendAsync(request, HttpResponse.BodyHandlers.ofString()); - - CompletableFuture.allOf(response1, response2, response3) - .join(); - - assertThat(response1.get() - .statusCode(), equalTo(HttpURLConnection.HTTP_OK)); - assertThat(response2.get() - .statusCode(), equalTo(HttpURLConnection.HTTP_OK)); - assertThat(response3.get() - .statusCode(), equalTo(HttpURLConnection.HTTP_OK)); - } - - @Test - public void shouldNotStoreCookieWhenPolicyAcceptNone() throws URISyntaxException, IOException, InterruptedException { - HttpRequest request = HttpRequest.newBuilder() - .uri(new URI("https://postman-echo.com/get")) - .GET() - .build(); - - HttpClient httpClient = HttpClient.newBuilder() - .cookieHandler(new CookieManager(null, CookiePolicy.ACCEPT_NONE)) - .build(); - - httpClient.send(request, HttpResponse.BodyHandlers.ofString()); - - assertTrue(httpClient.cookieHandler() - .isPresent()); - } - - @Test - public void shouldStoreCookieWhenPolicyAcceptAll() throws URISyntaxException, IOException, InterruptedException { - HttpRequest request = HttpRequest.newBuilder() - .uri(new URI("https://postman-echo.com/get")) - .GET() - .build(); - - HttpClient httpClient = HttpClient.newBuilder() - .cookieHandler(new CookieManager(null, CookiePolicy.ACCEPT_ALL)) - .build(); - - httpClient.send(request, HttpResponse.BodyHandlers.ofString()); - - assertTrue(httpClient.cookieHandler() - .isPresent()); - } - - @Test - public void shouldProcessMultipleRequestViaStream() throws URISyntaxException, ExecutionException, InterruptedException { - List targets = Arrays.asList(new URI("https://postman-echo.com/get?foo1=bar1"), new URI("https://postman-echo.com/get?foo2=bar2")); - - HttpClient client = HttpClient.newHttpClient(); - - List> futures = targets.stream() - .map(target -> client.sendAsync(HttpRequest.newBuilder(target) - .GET() - .build(), HttpResponse.BodyHandlers.ofString()) - .thenApply(response -> response.body())) - .collect(Collectors.toList()); - - CompletableFuture.allOf(futures.toArray(new CompletableFuture[0])) - .join(); - - if (futures.get(0) - .get() - .contains("foo1")) { - assertThat(futures.get(0) - .get(), containsString("bar1")); - assertThat(futures.get(1) - .get(), containsString("bar2")); - } else { - assertThat(futures.get(1) - .get(), containsString("bar2")); - assertThat(futures.get(1) - .get(), containsString("bar1")); - } - - } - - @Test - public void completeExceptionallyExample() { - CompletableFuture cf = CompletableFuture.completedFuture("message").thenApplyAsync(String::toUpperCase, - CompletableFuture.delayedExecutor(1, TimeUnit.SECONDS)); - CompletableFuture exceptionHandler = cf.handle((s, th) -> { return (th != null) ? "message upon cancel" : ""; }); - cf.completeExceptionally(new RuntimeException("completed exceptionally")); - assertTrue("Was not completed exceptionally", cf.isCompletedExceptionally()); - try { - cf.join(); - fail("Should have thrown an exception"); - } catch (CompletionException ex) { // just for testing - assertEquals("completed exceptionally", ex.getCause().getMessage()); - } - - assertEquals("message upon cancel", exceptionHandler.join()); - } - -} +package com.baeldung.java11.httpclient.test; + +import static org.hamcrest.CoreMatchers.containsString; +import static org.hamcrest.CoreMatchers.equalTo; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +import java.io.IOException; +import java.net.Authenticator; +import java.net.CookieManager; +import java.net.CookiePolicy; +import java.net.HttpURLConnection; +import java.net.PasswordAuthentication; +import java.net.ProxySelector; +import java.net.URI; +import java.net.URISyntaxException; +import java.net.http.HttpClient; +import java.net.http.HttpRequest; +import java.net.http.HttpResponse; +import java.net.http.HttpResponse.BodyHandlers; +import java.util.Arrays; +import java.util.List; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.CompletionException; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.TimeUnit; +import java.util.stream.Collectors; + +import org.junit.jupiter.api.Test; + +public class HttpClientTest { + + @Test + public void shouldReturnSampleDataContentWhenConnectViaSystemProxy() throws IOException, InterruptedException, URISyntaxException { + HttpRequest request = HttpRequest.newBuilder() + .uri(new URI("https://postman-echo.com/post")) + .headers("Content-Type", "text/plain;charset=UTF-8") + .POST(HttpRequest.BodyPublishers.ofString("Sample body")) + .build(); + + + HttpResponse response = HttpClient.newBuilder() + .proxy(ProxySelector.getDefault()) + .build() + .send(request, HttpResponse.BodyHandlers.ofString()); + + assertThat(response.statusCode(), equalTo(HttpURLConnection.HTTP_OK)); + assertThat(response.body(), containsString("Sample body")); + } + + @Test + public void shouldNotFollowRedirectWhenSetToDefaultNever() throws IOException, InterruptedException, URISyntaxException { + HttpRequest request = HttpRequest.newBuilder() + .uri(new URI("http://stackoverflow.com")) + .version(HttpClient.Version.HTTP_1_1) + .GET() + .build(); + HttpResponse response = HttpClient.newBuilder() + .build() + .send(request, HttpResponse.BodyHandlers.ofString()); + + assertThat(response.statusCode(), equalTo(HttpURLConnection.HTTP_MOVED_PERM)); + assertThat(response.body(), containsString("https://stackoverflow.com/")); + } + + @Test + public void shouldFollowRedirectWhenSetToAlways() throws IOException, InterruptedException, URISyntaxException { + HttpRequest request = HttpRequest.newBuilder() + .uri(new URI("http://stackoverflow.com")) + .version(HttpClient.Version.HTTP_1_1) + .GET() + .build(); + HttpResponse response = HttpClient.newBuilder() + .followRedirects(HttpClient.Redirect.ALWAYS) + .build() + .send(request, HttpResponse.BodyHandlers.ofString()); + + assertThat(response.statusCode(), equalTo(HttpURLConnection.HTTP_OK)); + assertThat(response.request() + .uri() + .toString(), equalTo("https://stackoverflow.com/")); + } + + @Test + public void shouldReturnOKStatusForAuthenticatedAccess() throws URISyntaxException, IOException, InterruptedException { + HttpRequest request = HttpRequest.newBuilder() + .uri(new URI("https://postman-echo.com/basic-auth")) + .GET() + .build(); + HttpResponse response = HttpClient.newBuilder() + .authenticator(new Authenticator() { + @Override + protected PasswordAuthentication getPasswordAuthentication() { + return new PasswordAuthentication("postman", "password".toCharArray()); + } + }) + .build() + .send(request, HttpResponse.BodyHandlers.ofString()); + + assertThat(response.statusCode(), equalTo(HttpURLConnection.HTTP_OK)); + } + + @Test + public void shouldSendRequestAsync() throws URISyntaxException, InterruptedException, ExecutionException { + HttpRequest request = HttpRequest.newBuilder() + .uri(new URI("https://postman-echo.com/post")) + .headers("Content-Type", "text/plain;charset=UTF-8") + .POST(HttpRequest.BodyPublishers.ofString("Sample body")) + .build(); + CompletableFuture> response = HttpClient.newBuilder() + .build() + .sendAsync(request, HttpResponse.BodyHandlers.ofString()); + + assertThat(response.get() + .statusCode(), equalTo(HttpURLConnection.HTTP_OK)); + } + + @Test + public void shouldUseJustTwoThreadWhenProcessingSendAsyncRequest() throws URISyntaxException, InterruptedException, ExecutionException { + HttpRequest request = HttpRequest.newBuilder() + .uri(new URI("https://postman-echo.com/get")) + .GET() + .build(); + + ExecutorService executorService = Executors.newFixedThreadPool(2); + + CompletableFuture> response1 = HttpClient.newBuilder() + .executor(executorService) + .build() + .sendAsync(request, HttpResponse.BodyHandlers.ofString()); + + CompletableFuture> response2 = HttpClient.newBuilder() + .executor(executorService) + .build() + .sendAsync(request, HttpResponse.BodyHandlers.ofString()); + + CompletableFuture> response3 = HttpClient.newBuilder() + .executor(executorService) + .build() + .sendAsync(request, HttpResponse.BodyHandlers.ofString()); + + CompletableFuture.allOf(response1, response2, response3) + .join(); + + assertThat(response1.get() + .statusCode(), equalTo(HttpURLConnection.HTTP_OK)); + assertThat(response2.get() + .statusCode(), equalTo(HttpURLConnection.HTTP_OK)); + assertThat(response3.get() + .statusCode(), equalTo(HttpURLConnection.HTTP_OK)); + } + + @Test + public void shouldNotStoreCookieWhenPolicyAcceptNone() throws URISyntaxException, IOException, InterruptedException { + HttpRequest request = HttpRequest.newBuilder() + .uri(new URI("https://postman-echo.com/get")) + .GET() + .build(); + + HttpClient httpClient = HttpClient.newBuilder() + .cookieHandler(new CookieManager(null, CookiePolicy.ACCEPT_NONE)) + .build(); + + httpClient.send(request, HttpResponse.BodyHandlers.ofString()); + + assertTrue(httpClient.cookieHandler() + .isPresent()); + } + + @Test + public void shouldStoreCookieWhenPolicyAcceptAll() throws URISyntaxException, IOException, InterruptedException { + HttpRequest request = HttpRequest.newBuilder() + .uri(new URI("https://postman-echo.com/get")) + .GET() + .build(); + + HttpClient httpClient = HttpClient.newBuilder() + .cookieHandler(new CookieManager(null, CookiePolicy.ACCEPT_ALL)) + .build(); + + httpClient.send(request, HttpResponse.BodyHandlers.ofString()); + + assertTrue(httpClient.cookieHandler() + .isPresent()); + } + + @Test + public void shouldProcessMultipleRequestViaStream() throws URISyntaxException, ExecutionException, InterruptedException { + List targets = Arrays.asList(new URI("https://postman-echo.com/get?foo1=bar1"), new URI("https://postman-echo.com/get?foo2=bar2")); + + HttpClient client = HttpClient.newHttpClient(); + + List> futures = targets.stream() + .map(target -> client.sendAsync(HttpRequest.newBuilder(target) + .GET() + .build(), HttpResponse.BodyHandlers.ofString()) + .thenApply(response -> response.body())) + .collect(Collectors.toList()); + + CompletableFuture.allOf(futures.toArray(new CompletableFuture[0])) + .join(); + + if (futures.get(0) + .get() + .contains("foo1")) { + assertThat(futures.get(0) + .get(), containsString("bar1")); + assertThat(futures.get(1) + .get(), containsString("bar2")); + } else { + assertThat(futures.get(1) + .get(), containsString("bar2")); + assertThat(futures.get(1) + .get(), containsString("bar1")); + } + + } + + @Test + public void completeExceptionallyExample() { + CompletableFuture cf = CompletableFuture.completedFuture("message").thenApplyAsync(String::toUpperCase, + CompletableFuture.delayedExecutor(1, TimeUnit.SECONDS)); + CompletableFuture exceptionHandler = cf.handle((s, th) -> { return (th != null) ? "message upon cancel" : ""; }); + cf.completeExceptionally(new RuntimeException("completed exceptionally")); + assertTrue("Was not completed exceptionally", cf.isCompletedExceptionally()); + try { + cf.join(); + fail("Should have thrown an exception"); + } catch (CompletionException ex) { // just for testing + assertEquals("completed exceptionally", ex.getCause().getMessage()); + } + + assertEquals("message upon cancel", exceptionHandler.join()); + } + +} diff --git a/core-java-11/src/test/java/com/baeldung/java11/httpclient/test/HttpRequestTest.java b/core-java-modules/core-java-11/src/test/java/com/baeldung/java11/httpclient/test/HttpRequestTest.java similarity index 97% rename from core-java-11/src/test/java/com/baeldung/java11/httpclient/test/HttpRequestTest.java rename to core-java-modules/core-java-11/src/test/java/com/baeldung/java11/httpclient/test/HttpRequestTest.java index 7d138bd8d5..274d3a93fc 100644 --- a/core-java-11/src/test/java/com/baeldung/java11/httpclient/test/HttpRequestTest.java +++ b/core-java-modules/core-java-11/src/test/java/com/baeldung/java11/httpclient/test/HttpRequestTest.java @@ -1,168 +1,168 @@ -package com.baeldung.java11.httpclient.test; - -import static java.time.temporal.ChronoUnit.SECONDS; -import static org.hamcrest.CoreMatchers.containsString; -import static org.hamcrest.CoreMatchers.equalTo; -import static org.junit.Assert.assertThat; - -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.net.HttpURLConnection; -import java.net.URI; -import java.net.URISyntaxException; -import java.net.http.HttpClient; -import java.net.http.HttpRequest; -import java.net.http.HttpResponse; -import java.nio.file.Paths; -import java.security.NoSuchAlgorithmException; -import java.time.Duration; - -import org.junit.Test; - -public class HttpRequestTest { - - @Test - public void shouldReturnStatusOKWhenSendGetRequest() throws IOException, InterruptedException, URISyntaxException { - HttpRequest request = HttpRequest.newBuilder() - .uri(new URI("https://postman-echo.com/get")) - .GET() - .build(); - - HttpResponse response = HttpClient.newHttpClient() - .send(request, HttpResponse.BodyHandlers.ofString()); - - assertThat(response.statusCode(), equalTo(HttpURLConnection.HTTP_OK)); - } - - @Test - public void shouldUseHttp2WhenWebsiteUsesHttp2() throws IOException, InterruptedException, URISyntaxException { - HttpRequest request = HttpRequest.newBuilder() - .uri(new URI("https://stackoverflow.com")) - .version(HttpClient.Version.HTTP_2) - .GET() - .build(); - HttpResponse response = HttpClient.newHttpClient() - .send(request, HttpResponse.BodyHandlers.ofString()); - - assertThat(response.statusCode(), equalTo(HttpURLConnection.HTTP_OK)); - assertThat(response.version(), equalTo(HttpClient.Version.HTTP_2)); - } - - @Test - public void shouldFallbackToHttp1_1WhenWebsiteDoesNotUseHttp2() throws IOException, InterruptedException, URISyntaxException, NoSuchAlgorithmException { - HttpRequest request = HttpRequest.newBuilder() - .uri(new URI("https://postman-echo.com/get")) - .version(HttpClient.Version.HTTP_2) - .GET() - .build(); - - HttpResponse response = HttpClient.newHttpClient() - .send(request, HttpResponse.BodyHandlers.ofString()); - - assertThat(response.version(), equalTo(HttpClient.Version.HTTP_1_1)); - } - - @Test - public void shouldReturnStatusOKWhenSendGetRequestWithDummyHeaders() throws IOException, InterruptedException, URISyntaxException { - HttpRequest request = HttpRequest.newBuilder() - .uri(new URI("https://postman-echo.com/get")) - .headers("key1", "value1", "key2", "value2") - .GET() - .build(); - - HttpResponse response = HttpClient.newHttpClient() - .send(request, HttpResponse.BodyHandlers.ofString()); - - assertThat(response.statusCode(), equalTo(HttpURLConnection.HTTP_OK)); - } - - @Test - public void shouldReturnStatusOKWhenSendGetRequestTimeoutSet() throws IOException, InterruptedException, URISyntaxException { - HttpRequest request = HttpRequest.newBuilder() - .uri(new URI("https://postman-echo.com/get")) - .timeout(Duration.of(10, SECONDS)) - .GET() - .build(); - - HttpResponse response = HttpClient.newHttpClient() - .send(request, HttpResponse.BodyHandlers.ofString()); - - assertThat(response.statusCode(), equalTo(HttpURLConnection.HTTP_OK)); - } - - @Test - public void shouldReturnNoContentWhenPostWithNoBody() throws IOException, InterruptedException, URISyntaxException { - HttpRequest request = HttpRequest.newBuilder() - .uri(new URI("https://postman-echo.com/post")) - .POST(HttpRequest.BodyPublishers.noBody()) - .build(); - - HttpResponse response = HttpClient.newHttpClient() - .send(request, HttpResponse.BodyHandlers.ofString()); - - assertThat(response.statusCode(), equalTo(HttpURLConnection.HTTP_OK)); - } - - @Test - public void shouldReturnSampleDataContentWhenPostWithBodyText() throws IOException, InterruptedException, URISyntaxException { - HttpRequest request = HttpRequest.newBuilder() - .uri(new URI("https://postman-echo.com/post")) - .headers("Content-Type", "text/plain;charset=UTF-8") - .POST(HttpRequest.BodyPublishers.ofString("Sample request body")) - .build(); - - HttpResponse response = HttpClient.newHttpClient() - .send(request, HttpResponse.BodyHandlers.ofString()); - - assertThat(response.statusCode(), equalTo(HttpURLConnection.HTTP_OK)); - assertThat(response.body(), containsString("Sample request body")); - } - - @Test - public void shouldReturnSampleDataContentWhenPostWithInputStream() throws IOException, InterruptedException, URISyntaxException { - byte[] sampleData = "Sample request body".getBytes(); - HttpRequest request = HttpRequest.newBuilder() - .uri(new URI("https://postman-echo.com/post")) - .headers("Content-Type", "text/plain;charset=UTF-8") - .POST(HttpRequest.BodyPublishers.ofInputStream(() -> new ByteArrayInputStream(sampleData))) - .build(); - - HttpResponse response = HttpClient.newHttpClient() - .send(request, HttpResponse.BodyHandlers.ofString()); - - assertThat(response.statusCode(), equalTo(HttpURLConnection.HTTP_OK)); - assertThat(response.body(), containsString("Sample request body")); - } - - @Test - public void shouldReturnSampleDataContentWhenPostWithByteArrayProcessorStream() throws IOException, InterruptedException, URISyntaxException { - byte[] sampleData = "Sample request body".getBytes(); - HttpRequest request = HttpRequest.newBuilder() - .uri(new URI("https://postman-echo.com/post")) - .headers("Content-Type", "text/plain;charset=UTF-8") - .POST(HttpRequest.BodyPublishers.ofByteArray(sampleData)) - .build(); - - HttpResponse response = HttpClient.newHttpClient() - .send(request, HttpResponse.BodyHandlers.ofString()); - - assertThat(response.statusCode(), equalTo(HttpURLConnection.HTTP_OK)); - assertThat(response.body(), containsString("Sample request body")); - } - - @Test - public void shouldReturnSampleDataContentWhenPostWithFileProcessorStream() throws IOException, InterruptedException, URISyntaxException { - HttpRequest request = HttpRequest.newBuilder() - .uri(new URI("https://postman-echo.com/post")) - .headers("Content-Type", "text/plain;charset=UTF-8") - .POST(HttpRequest.BodyPublishers.ofFile(Paths.get("src/test/resources/sample.txt"))) - .build(); - - HttpResponse response = HttpClient.newHttpClient() - .send(request, HttpResponse.BodyHandlers.ofString()); - - assertThat(response.statusCode(), equalTo(HttpURLConnection.HTTP_OK)); - assertThat(response.body(), containsString("Sample file content")); - } - -} +package com.baeldung.java11.httpclient.test; + +import static java.time.temporal.ChronoUnit.SECONDS; +import static org.hamcrest.CoreMatchers.containsString; +import static org.hamcrest.CoreMatchers.equalTo; +import static org.junit.Assert.assertThat; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.net.HttpURLConnection; +import java.net.URI; +import java.net.URISyntaxException; +import java.net.http.HttpClient; +import java.net.http.HttpRequest; +import java.net.http.HttpResponse; +import java.nio.file.Paths; +import java.security.NoSuchAlgorithmException; +import java.time.Duration; + +import org.junit.Test; + +public class HttpRequestTest { + + @Test + public void shouldReturnStatusOKWhenSendGetRequest() throws IOException, InterruptedException, URISyntaxException { + HttpRequest request = HttpRequest.newBuilder() + .uri(new URI("https://postman-echo.com/get")) + .GET() + .build(); + + HttpResponse response = HttpClient.newHttpClient() + .send(request, HttpResponse.BodyHandlers.ofString()); + + assertThat(response.statusCode(), equalTo(HttpURLConnection.HTTP_OK)); + } + + @Test + public void shouldUseHttp2WhenWebsiteUsesHttp2() throws IOException, InterruptedException, URISyntaxException { + HttpRequest request = HttpRequest.newBuilder() + .uri(new URI("https://stackoverflow.com")) + .version(HttpClient.Version.HTTP_2) + .GET() + .build(); + HttpResponse response = HttpClient.newHttpClient() + .send(request, HttpResponse.BodyHandlers.ofString()); + + assertThat(response.statusCode(), equalTo(HttpURLConnection.HTTP_OK)); + assertThat(response.version(), equalTo(HttpClient.Version.HTTP_2)); + } + + @Test + public void shouldFallbackToHttp1_1WhenWebsiteDoesNotUseHttp2() throws IOException, InterruptedException, URISyntaxException, NoSuchAlgorithmException { + HttpRequest request = HttpRequest.newBuilder() + .uri(new URI("https://postman-echo.com/get")) + .version(HttpClient.Version.HTTP_2) + .GET() + .build(); + + HttpResponse response = HttpClient.newHttpClient() + .send(request, HttpResponse.BodyHandlers.ofString()); + + assertThat(response.version(), equalTo(HttpClient.Version.HTTP_1_1)); + } + + @Test + public void shouldReturnStatusOKWhenSendGetRequestWithDummyHeaders() throws IOException, InterruptedException, URISyntaxException { + HttpRequest request = HttpRequest.newBuilder() + .uri(new URI("https://postman-echo.com/get")) + .headers("key1", "value1", "key2", "value2") + .GET() + .build(); + + HttpResponse response = HttpClient.newHttpClient() + .send(request, HttpResponse.BodyHandlers.ofString()); + + assertThat(response.statusCode(), equalTo(HttpURLConnection.HTTP_OK)); + } + + @Test + public void shouldReturnStatusOKWhenSendGetRequestTimeoutSet() throws IOException, InterruptedException, URISyntaxException { + HttpRequest request = HttpRequest.newBuilder() + .uri(new URI("https://postman-echo.com/get")) + .timeout(Duration.of(10, SECONDS)) + .GET() + .build(); + + HttpResponse response = HttpClient.newHttpClient() + .send(request, HttpResponse.BodyHandlers.ofString()); + + assertThat(response.statusCode(), equalTo(HttpURLConnection.HTTP_OK)); + } + + @Test + public void shouldReturnNoContentWhenPostWithNoBody() throws IOException, InterruptedException, URISyntaxException { + HttpRequest request = HttpRequest.newBuilder() + .uri(new URI("https://postman-echo.com/post")) + .POST(HttpRequest.BodyPublishers.noBody()) + .build(); + + HttpResponse response = HttpClient.newHttpClient() + .send(request, HttpResponse.BodyHandlers.ofString()); + + assertThat(response.statusCode(), equalTo(HttpURLConnection.HTTP_OK)); + } + + @Test + public void shouldReturnSampleDataContentWhenPostWithBodyText() throws IOException, InterruptedException, URISyntaxException { + HttpRequest request = HttpRequest.newBuilder() + .uri(new URI("https://postman-echo.com/post")) + .headers("Content-Type", "text/plain;charset=UTF-8") + .POST(HttpRequest.BodyPublishers.ofString("Sample request body")) + .build(); + + HttpResponse response = HttpClient.newHttpClient() + .send(request, HttpResponse.BodyHandlers.ofString()); + + assertThat(response.statusCode(), equalTo(HttpURLConnection.HTTP_OK)); + assertThat(response.body(), containsString("Sample request body")); + } + + @Test + public void shouldReturnSampleDataContentWhenPostWithInputStream() throws IOException, InterruptedException, URISyntaxException { + byte[] sampleData = "Sample request body".getBytes(); + HttpRequest request = HttpRequest.newBuilder() + .uri(new URI("https://postman-echo.com/post")) + .headers("Content-Type", "text/plain;charset=UTF-8") + .POST(HttpRequest.BodyPublishers.ofInputStream(() -> new ByteArrayInputStream(sampleData))) + .build(); + + HttpResponse response = HttpClient.newHttpClient() + .send(request, HttpResponse.BodyHandlers.ofString()); + + assertThat(response.statusCode(), equalTo(HttpURLConnection.HTTP_OK)); + assertThat(response.body(), containsString("Sample request body")); + } + + @Test + public void shouldReturnSampleDataContentWhenPostWithByteArrayProcessorStream() throws IOException, InterruptedException, URISyntaxException { + byte[] sampleData = "Sample request body".getBytes(); + HttpRequest request = HttpRequest.newBuilder() + .uri(new URI("https://postman-echo.com/post")) + .headers("Content-Type", "text/plain;charset=UTF-8") + .POST(HttpRequest.BodyPublishers.ofByteArray(sampleData)) + .build(); + + HttpResponse response = HttpClient.newHttpClient() + .send(request, HttpResponse.BodyHandlers.ofString()); + + assertThat(response.statusCode(), equalTo(HttpURLConnection.HTTP_OK)); + assertThat(response.body(), containsString("Sample request body")); + } + + @Test + public void shouldReturnSampleDataContentWhenPostWithFileProcessorStream() throws IOException, InterruptedException, URISyntaxException { + HttpRequest request = HttpRequest.newBuilder() + .uri(new URI("https://postman-echo.com/post")) + .headers("Content-Type", "text/plain;charset=UTF-8") + .POST(HttpRequest.BodyPublishers.ofFile(Paths.get("src/test/resources/sample.txt"))) + .build(); + + HttpResponse response = HttpClient.newHttpClient() + .send(request, HttpResponse.BodyHandlers.ofString()); + + assertThat(response.statusCode(), equalTo(HttpURLConnection.HTTP_OK)); + assertThat(response.body(), containsString("Sample file content")); + } + +} diff --git a/core-java-11/src/test/java/com/baeldung/java11/httpclient/test/HttpResponseTest.java b/core-java-modules/core-java-11/src/test/java/com/baeldung/java11/httpclient/test/HttpResponseTest.java similarity index 97% rename from core-java-11/src/test/java/com/baeldung/java11/httpclient/test/HttpResponseTest.java rename to core-java-modules/core-java-11/src/test/java/com/baeldung/java11/httpclient/test/HttpResponseTest.java index 78d86fbf4e..abbc0233c1 100644 --- a/core-java-11/src/test/java/com/baeldung/java11/httpclient/test/HttpResponseTest.java +++ b/core-java-modules/core-java-11/src/test/java/com/baeldung/java11/httpclient/test/HttpResponseTest.java @@ -1,54 +1,54 @@ -package com.baeldung.java11.httpclient.test; - -import static org.hamcrest.CoreMatchers.equalTo; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertThat; - -import java.io.IOException; -import java.net.HttpURLConnection; -import java.net.URI; -import java.net.URISyntaxException; -import java.net.http.HttpClient; -import java.net.http.HttpRequest; -import java.net.http.HttpResponse; - -import org.junit.Test; - -public class HttpResponseTest { - - @Test - public void shouldReturnStatusOKWhenSendGetRequest() throws IOException, InterruptedException, URISyntaxException { - HttpRequest request = HttpRequest.newBuilder() - .uri(new URI("https://postman-echo.com/get")) - .version(HttpClient.Version.HTTP_2) - .GET() - .build(); - - HttpResponse response = HttpClient.newBuilder() - .followRedirects(HttpClient.Redirect.NORMAL) - .build() - .send(request, HttpResponse.BodyHandlers.ofString()); - - assertThat(response.statusCode(), equalTo(HttpURLConnection.HTTP_OK)); - assertNotNull(response.body()); - } - - @Test - public void shouldResponseURIDifferentThanRequestUIRWhenRedirect() throws IOException, InterruptedException, URISyntaxException { - HttpRequest request = HttpRequest.newBuilder() - .uri(new URI("http://stackoverflow.com")) - .version(HttpClient.Version.HTTP_2) - .GET() - .build(); - HttpResponse response = HttpClient.newBuilder() - .followRedirects(HttpClient.Redirect.NORMAL) - .build() - .send(request, HttpResponse.BodyHandlers.ofString()); - - assertThat(request.uri() - .toString(), equalTo("http://stackoverflow.com")); - assertThat(response.uri() - .toString(), equalTo("https://stackoverflow.com/")); - } - -} +package com.baeldung.java11.httpclient.test; + +import static org.hamcrest.CoreMatchers.equalTo; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertThat; + +import java.io.IOException; +import java.net.HttpURLConnection; +import java.net.URI; +import java.net.URISyntaxException; +import java.net.http.HttpClient; +import java.net.http.HttpRequest; +import java.net.http.HttpResponse; + +import org.junit.Test; + +public class HttpResponseTest { + + @Test + public void shouldReturnStatusOKWhenSendGetRequest() throws IOException, InterruptedException, URISyntaxException { + HttpRequest request = HttpRequest.newBuilder() + .uri(new URI("https://postman-echo.com/get")) + .version(HttpClient.Version.HTTP_2) + .GET() + .build(); + + HttpResponse response = HttpClient.newBuilder() + .followRedirects(HttpClient.Redirect.NORMAL) + .build() + .send(request, HttpResponse.BodyHandlers.ofString()); + + assertThat(response.statusCode(), equalTo(HttpURLConnection.HTTP_OK)); + assertNotNull(response.body()); + } + + @Test + public void shouldResponseURIDifferentThanRequestUIRWhenRedirect() throws IOException, InterruptedException, URISyntaxException { + HttpRequest request = HttpRequest.newBuilder() + .uri(new URI("http://stackoverflow.com")) + .version(HttpClient.Version.HTTP_2) + .GET() + .build(); + HttpResponse response = HttpClient.newBuilder() + .followRedirects(HttpClient.Redirect.NORMAL) + .build() + .send(request, HttpResponse.BodyHandlers.ofString()); + + assertThat(request.uri() + .toString(), equalTo("http://stackoverflow.com")); + assertThat(response.uri() + .toString(), equalTo("https://stackoverflow.com/")); + } + +} diff --git a/core-java-11/src/test/java/com/baeldung/optional/OptionalUnitTest.java b/core-java-modules/core-java-11/src/test/java/com/baeldung/optional/OptionalUnitTest.java similarity index 100% rename from core-java-11/src/test/java/com/baeldung/optional/OptionalUnitTest.java rename to core-java-modules/core-java-11/src/test/java/com/baeldung/optional/OptionalUnitTest.java diff --git a/core-java-12/pom.xml b/core-java-modules/core-java-12/pom.xml similarity index 97% rename from core-java-12/pom.xml rename to core-java-modules/core-java-12/pom.xml index c5eec1a4bb..06c49a0021 100644 --- a/core-java-12/pom.xml +++ b/core-java-modules/core-java-12/pom.xml @@ -14,6 +14,7 @@ com.baeldung parent-modules 1.0.0-SNAPSHOT + ../../ diff --git a/core-java-12/src/test/java/com/baeldung/collectors/CollectorsUnitTest.java b/core-java-modules/core-java-12/src/test/java/com/baeldung/collectors/CollectorsUnitTest.java similarity index 100% rename from core-java-12/src/test/java/com/baeldung/collectors/CollectorsUnitTest.java rename to core-java-modules/core-java-12/src/test/java/com/baeldung/collectors/CollectorsUnitTest.java diff --git a/core-java-12/src/test/java/com/baeldung/switchExpression/SwitchUnitTest.java b/core-java-modules/core-java-12/src/test/java/com/baeldung/switchExpression/SwitchUnitTest.java similarity index 100% rename from core-java-12/src/test/java/com/baeldung/switchExpression/SwitchUnitTest.java rename to core-java-modules/core-java-12/src/test/java/com/baeldung/switchExpression/SwitchUnitTest.java diff --git a/core-java-arrays/.gitignore b/core-java-modules/core-java-8-2/.gitignore similarity index 100% rename from core-java-arrays/.gitignore rename to core-java-modules/core-java-8-2/.gitignore diff --git a/core-java-8-2/README.md b/core-java-modules/core-java-8-2/README.md similarity index 100% rename from core-java-8-2/README.md rename to core-java-modules/core-java-8-2/README.md diff --git a/core-java-8-2/pom.xml b/core-java-modules/core-java-8-2/pom.xml similarity index 83% rename from core-java-8-2/pom.xml rename to core-java-modules/core-java-8-2/pom.xml index 7035f12fb7..fbaf795b95 100644 --- a/core-java-8-2/pom.xml +++ b/core-java-modules/core-java-8-2/pom.xml @@ -14,16 +14,23 @@ com.baeldung parent-java 0.0.1-SNAPSHOT - ../parent-java + ../../parent-java UTF-8 1.8 1.8 + 64.2 + + com.ibm.icu + icu4j + ${icu.version} + + diff --git a/core-java-modules/core-java-8-2/src/main/java/com/baeldung/jarArguments/JarExample.java b/core-java-modules/core-java-8-2/src/main/java/com/baeldung/jarArguments/JarExample.java new file mode 100644 index 0000000000..c2fb809790 --- /dev/null +++ b/core-java-modules/core-java-8-2/src/main/java/com/baeldung/jarArguments/JarExample.java @@ -0,0 +1,18 @@ +package com.baeldung.jarArguments; + +public class JarExample { + + public static void main(String[] args) { + System.out.println("Hello Baeldung Reader in JarExample!"); + + if(args == null) { + System.out.println("You have not provided any arguments!"); + }else { + System.out.println("There are "+args.length+" argument(s)!"); + for(int i=0; i locales = Arrays.asList(new Locale[] { Locale.UK, Locale.ITALY, Locale.FRANCE, Locale.forLanguageTag("pl-PL") }); + Localization.run(locales); + JavaSEFormat.run(locales); + ICUFormat.run(locales); + } + +} diff --git a/core-java-modules/core-java-8-2/src/main/java/com/baeldung/localization/ICUFormat.java b/core-java-modules/core-java-8-2/src/main/java/com/baeldung/localization/ICUFormat.java new file mode 100644 index 0000000000..f7bc357933 --- /dev/null +++ b/core-java-modules/core-java-8-2/src/main/java/com/baeldung/localization/ICUFormat.java @@ -0,0 +1,29 @@ +package com.baeldung.localization; + +import java.util.List; +import java.util.Locale; +import java.util.ResourceBundle; + +import com.ibm.icu.text.MessageFormat; + +public class ICUFormat { + + public static String getLabel(Locale locale, Object[] data) { + ResourceBundle bundle = ResourceBundle.getBundle("formats", locale); + String format = bundle.getString("label-icu"); + MessageFormat formatter = new MessageFormat(format, locale); + return formatter.format(data); + } + + public static void run(List locales) { + System.out.println("ICU formatter"); + locales.forEach(locale -> System.out.println(getLabel(locale, new Object[] { "Alice", "female", 0 }))); + locales.forEach(locale -> System.out.println(getLabel(locale, new Object[] { "Alice", "female", 1 }))); + locales.forEach(locale -> System.out.println(getLabel(locale, new Object[] { "Alice", "female", 2 }))); + locales.forEach(locale -> System.out.println(getLabel(locale, new Object[] { "Alice", "female", 3 }))); + locales.forEach(locale -> System.out.println(getLabel(locale, new Object[] { "Bob", "male", 0 }))); + locales.forEach(locale -> System.out.println(getLabel(locale, new Object[] { "Bob", "male", 1 }))); + locales.forEach(locale -> System.out.println(getLabel(locale, new Object[] { "Bob", "male", 2 }))); + locales.forEach(locale -> System.out.println(getLabel(locale, new Object[] { "Bob", "male", 3 }))); + } +} diff --git a/core-java-modules/core-java-8-2/src/main/java/com/baeldung/localization/JavaSEFormat.java b/core-java-modules/core-java-8-2/src/main/java/com/baeldung/localization/JavaSEFormat.java new file mode 100644 index 0000000000..c95dfffa13 --- /dev/null +++ b/core-java-modules/core-java-8-2/src/main/java/com/baeldung/localization/JavaSEFormat.java @@ -0,0 +1,24 @@ +package com.baeldung.localization; + +import java.text.MessageFormat; +import java.util.Date; +import java.util.List; +import java.util.Locale; +import java.util.ResourceBundle; + +public class JavaSEFormat { + + public static String getLabel(Locale locale, Object[] data) { + ResourceBundle bundle = ResourceBundle.getBundle("formats", locale); + final String pattern = bundle.getString("label"); + final MessageFormat formatter = new MessageFormat(pattern, locale); + return formatter.format(data); + } + + public static void run(List locales) { + System.out.println("Java formatter"); + final Date date = new Date(System.currentTimeMillis()); + locales.forEach(locale -> System.out.println(getLabel(locale, new Object[] { date, "Alice", 0 }))); + locales.forEach(locale -> System.out.println(getLabel(locale, new Object[] { date, "Alice", 2 }))); + } +} diff --git a/core-java-modules/core-java-8-2/src/main/java/com/baeldung/localization/Localization.java b/core-java-modules/core-java-8-2/src/main/java/com/baeldung/localization/Localization.java new file mode 100644 index 0000000000..17a6598ce0 --- /dev/null +++ b/core-java-modules/core-java-8-2/src/main/java/com/baeldung/localization/Localization.java @@ -0,0 +1,18 @@ +package com.baeldung.localization; + +import java.util.List; +import java.util.Locale; +import java.util.ResourceBundle; + +public class Localization { + + public static String getLabel(Locale locale) { + final ResourceBundle bundle = ResourceBundle.getBundle("messages", locale); + return bundle.getString("label"); + } + + public static void run(List locales) { + locales.forEach(locale -> System.out.println(getLabel(locale))); + } + +} diff --git a/core-java-modules/core-java-8-2/src/main/resources/example_manifest.txt b/core-java-modules/core-java-8-2/src/main/resources/example_manifest.txt new file mode 100644 index 0000000000..71abcb05fb --- /dev/null +++ b/core-java-modules/core-java-8-2/src/main/resources/example_manifest.txt @@ -0,0 +1 @@ +Main-Class: com.baeldung.jarArguments.JarExample diff --git a/core-java-modules/core-java-8-2/src/main/resources/formats_en.properties b/core-java-modules/core-java-8-2/src/main/resources/formats_en.properties new file mode 100644 index 0000000000..41e0e00119 --- /dev/null +++ b/core-java-modules/core-java-8-2/src/main/resources/formats_en.properties @@ -0,0 +1,2 @@ +label=On {0, date, short} {1} has sent you {2, choice, 0#no messages|1#a message|2#two messages|2<{2,number,integer} messages}. +label-icu={0} has sent you {2, plural, =0 {no messages} =1 {a message} other {{2, number, integer} messages}}. \ No newline at end of file diff --git a/core-java-modules/core-java-8-2/src/main/resources/formats_fr.properties b/core-java-modules/core-java-8-2/src/main/resources/formats_fr.properties new file mode 100644 index 0000000000..c2d5159b32 --- /dev/null +++ b/core-java-modules/core-java-8-2/src/main/resources/formats_fr.properties @@ -0,0 +1,2 @@ +label={0, date, short}, {1}{2, choice, 0# ne|0<} vous a envoyé {2, choice, 0#aucun message|1#un message|2#deux messages|2<{2,number,integer} messages}. +label-icu={0} {2, plural, =0 {ne } other {}}vous a envoyé {2, plural, =0 {aucun message} =1 {un message} other {{2, number, integer} messages}}. \ No newline at end of file diff --git a/core-java-modules/core-java-8-2/src/main/resources/formats_it.properties b/core-java-modules/core-java-8-2/src/main/resources/formats_it.properties new file mode 100644 index 0000000000..43fd1eee1c --- /dev/null +++ b/core-java-modules/core-java-8-2/src/main/resources/formats_it.properties @@ -0,0 +1,2 @@ +label={0, date, short} {1} ti ha inviato {2, choice, 0#nessun messagio|1#un messaggio|2#due messaggi|2<{2, number, integer} messaggi}. +label-icu={0} {2, plural, =0 {non } other {}}ti ha inviato {2, plural, =0 {nessun messaggio} =1 {un messaggio} other {{2, number, integer} messaggi}}. \ No newline at end of file diff --git a/core-java-modules/core-java-8-2/src/main/resources/formats_pl.properties b/core-java-modules/core-java-8-2/src/main/resources/formats_pl.properties new file mode 100644 index 0000000000..9333ec3396 --- /dev/null +++ b/core-java-modules/core-java-8-2/src/main/resources/formats_pl.properties @@ -0,0 +1,2 @@ +label=W {0, date, short} {1}{2, choice, 0# nie|0<} wys\u0142a\u0142a ci {2, choice, 0#\u017Cadnych wiadomo\u015Bci|1#wiadomo\u015B\u0107|2#dwie wiadomo\u015Bci|2<{2, number, integer} wiadomo\u015Bci}. +label-icu={0} {2, plural, =0 {nie } other {}}{1, select, male {wys\u0142a\u0142} female {wys\u0142a\u0142a} other {wys\u0142a\u0142o}} ci {2, plural, =0 {\u017Cadnej wiadomo\u015Bci} =1 {wiadomo\u015B\u0107} other {{2, number, integer} wiadomo\u015Bci}}. diff --git a/core-java-modules/core-java-8-2/src/main/resources/messages_en.properties b/core-java-modules/core-java-8-2/src/main/resources/messages_en.properties new file mode 100644 index 0000000000..bcbca9483c --- /dev/null +++ b/core-java-modules/core-java-8-2/src/main/resources/messages_en.properties @@ -0,0 +1 @@ +label=Alice has sent you a message. diff --git a/core-java-modules/core-java-8-2/src/main/resources/messages_fr.properties b/core-java-modules/core-java-8-2/src/main/resources/messages_fr.properties new file mode 100644 index 0000000000..6716102568 --- /dev/null +++ b/core-java-modules/core-java-8-2/src/main/resources/messages_fr.properties @@ -0,0 +1 @@ +label=Alice vous a envoyé un message. \ No newline at end of file diff --git a/core-java-modules/core-java-8-2/src/main/resources/messages_it.properties b/core-java-modules/core-java-8-2/src/main/resources/messages_it.properties new file mode 100644 index 0000000000..6929a8c091 --- /dev/null +++ b/core-java-modules/core-java-8-2/src/main/resources/messages_it.properties @@ -0,0 +1 @@ +label=Alice ti ha inviato un messaggio. \ No newline at end of file diff --git a/core-java-modules/core-java-8-2/src/main/resources/messages_pl.properties b/core-java-modules/core-java-8-2/src/main/resources/messages_pl.properties new file mode 100644 index 0000000000..5515a9920e --- /dev/null +++ b/core-java-modules/core-java-8-2/src/main/resources/messages_pl.properties @@ -0,0 +1 @@ +label=Alice wys\u0142a\u0142a ci wiadomo\u015B\u0107. \ No newline at end of file diff --git a/core-java-modules/core-java-8-2/src/test/java/com/baeldung/localization/ICUFormatUnitTest.java b/core-java-modules/core-java-8-2/src/test/java/com/baeldung/localization/ICUFormatUnitTest.java new file mode 100644 index 0000000000..2c8f9b47f3 --- /dev/null +++ b/core-java-modules/core-java-8-2/src/test/java/com/baeldung/localization/ICUFormatUnitTest.java @@ -0,0 +1,74 @@ +package com.baeldung.localization; + +import static org.junit.Assert.assertEquals; + +import java.util.Locale; + +import org.junit.Test; + +import com.baeldung.localization.ICUFormat; + +public class ICUFormatUnitTest { + + @Test + public void givenInUK_whenAliceSendsNothing_thenCorrectMessage() { + assertEquals("Alice has sent you no messages.", ICUFormat.getLabel(Locale.UK, new Object[] { "Alice", "female", 0 })); + } + + @Test + public void givenInUK_whenAliceSendsOneMessage_thenCorrectMessage() { + assertEquals("Alice has sent you a message.", ICUFormat.getLabel(Locale.UK, new Object[] { "Alice", "female", 1 })); + } + + @Test + public void givenInUK_whenBobSendsSixMessages_thenCorrectMessage() { + assertEquals("Bob has sent you 6 messages.", ICUFormat.getLabel(Locale.UK, new Object[] { "Bob", "male", 6 })); + } + + @Test + public void givenInItaly_whenAliceSendsNothing_thenCorrectMessage() { + assertEquals("Alice non ti ha inviato nessun messaggio.", ICUFormat.getLabel(Locale.ITALY, new Object[] { "Alice", "female", 0 })); + } + + @Test + public void givenInItaly_whenAliceSendsOneMessage_thenCorrectMessage() { + assertEquals("Alice ti ha inviato un messaggio.", ICUFormat.getLabel(Locale.ITALY, new Object[] { "Alice", "female", 1 })); + } + + @Test + public void givenInItaly_whenBobSendsSixMessages_thenCorrectMessage() { + assertEquals("Bob ti ha inviato 6 messaggi.", ICUFormat.getLabel(Locale.ITALY, new Object[] { "Bob", "male", 6 })); + } + + @Test + public void givenInFrance_whenAliceSendsNothing_thenCorrectMessage() { + assertEquals("Alice ne vous a envoyé aucun message.", ICUFormat.getLabel(Locale.FRANCE, new Object[] { "Alice", "female", 0 })); + } + + @Test + public void givenInFrance_whenAliceSendsOneMessage_thenCorrectMessage() { + assertEquals("Alice vous a envoyé un message.", ICUFormat.getLabel(Locale.FRANCE, new Object[] { "Alice", "female", 1 })); + } + + @Test + public void givenInFrance_whenBobSendsSixMessages_thenCorrectMessage() { + assertEquals("Bob vous a envoyé 6 messages.", ICUFormat.getLabel(Locale.FRANCE, new Object[] { "Bob", "male", 6 })); + } + + + @Test + public void givenInPoland_whenAliceSendsNothing_thenCorrectMessage() { + assertEquals("Alice nie wysÅ‚aÅ‚a ci żadnej wiadomoÅ›ci.", ICUFormat.getLabel(Locale.forLanguageTag("pl-PL"), new Object[] { "Alice", "female", 0 })); + } + + @Test + public void givenInPoland_whenAliceSendsOneMessage_thenCorrectMessage() { + assertEquals("Alice wysÅ‚aÅ‚a ci wiadomość.", ICUFormat.getLabel(Locale.forLanguageTag("pl-PL"), new Object[] { "Alice", "female", 1 })); + } + + @Test + public void givenInPoland_whenBobSendsSixMessages_thenCorrectMessage() { + assertEquals("Bob wysÅ‚aÅ‚ ci 6 wiadomoÅ›ci.", ICUFormat.getLabel(Locale.forLanguageTag("pl-PL"), new Object[] { "Bob", "male", 6 })); + } + +} diff --git a/core-java-8/.gitignore b/core-java-modules/core-java-8/.gitignore similarity index 100% rename from core-java-8/.gitignore rename to core-java-modules/core-java-8/.gitignore diff --git a/core-java-8/README.md b/core-java-modules/core-java-8/README.md similarity index 100% rename from core-java-8/README.md rename to core-java-modules/core-java-8/README.md diff --git a/core-java-8/pom.xml b/core-java-modules/core-java-8/pom.xml similarity index 96% rename from core-java-8/pom.xml rename to core-java-modules/core-java-8/pom.xml index b63afef7d4..c09c970e07 100644 --- a/core-java-8/pom.xml +++ b/core-java-modules/core-java-8/pom.xml @@ -1,199 +1,199 @@ - - 4.0.0 - com.baeldung - core-java-8 - 0.1.0-SNAPSHOT - core-java-8 - jar - - - com.baeldung - parent-java - 0.0.1-SNAPSHOT - ../parent-java - - - - - org.apache.commons - commons-collections4 - ${commons-collections4.version} - - - commons-io - commons-io - ${commons-io.version} - - - org.apache.commons - commons-lang3 - ${commons-lang3.version} - - - org.apache.commons - commons-math3 - ${commons-math3.version} - - - log4j - log4j - ${log4j.version} - - - commons-codec - commons-codec - ${commons-codec.version} - - - org.projectlombok - lombok - ${lombok.version} - provided - - - - org.assertj - assertj-core - ${assertj.version} - test - - - com.jayway.awaitility - awaitility - ${avaitility.version} - test - - - org.openjdk.jmh - jmh-core - ${jmh-core.version} - - - org.openjdk.jmh - jmh-generator-annprocess - ${jmh-generator.version} - - - org.openjdk.jmh - jmh-generator-bytecode - ${jmh-generator.version} - - - com.codepoetics - protonpack - ${protonpack.version} - - - io.vavr - vavr - ${vavr.version} - - - joda-time - joda-time - ${joda.version} - - - org.aspectj - aspectjrt - ${asspectj.version} - - - org.aspectj - aspectjweaver - ${asspectj.version} - - - org.powermock - powermock-module-junit4 - ${powermock.version} - test - - - org.powermock - powermock-api-mockito2 - ${powermock.version} - test - - - org.jmockit - jmockit - ${jmockit.version} - test - - - - - core-java-8 - - - src/main/resources - true - - - - - - org.apache.maven.plugins - maven-compiler-plugin - ${maven-compiler-plugin.version} - - 1.8 - 1.8 - -parameters - - - - org.springframework.boot - spring-boot-maven-plugin - ${spring-boot-maven-plugin.version} - - - - repackage - - - spring-boot - org.baeldung.executable.ExecutableMavenJar - - - - - - maven-surefire-plugin - ${maven-surefire-plugin.version} - - - -javaagent:${settings.localRepository}/org/jmockit/jmockit/${jmockit.version}/jmockit-${jmockit.version}.jar - - true - - - - - - - - 3.5 - 3.6.1 - 4.1 - 4.01 - 1.10 - 0.9.0 - 1.13 - 2.10 - - 3.6.1 - 1.8.9 - 2.0.0-RC.4 - 1.44 - 1.7.0 - 1.19 - 1.19 - 2.0.4.RELEASE - - 3.8.0 - 2.22.1 - - + + 4.0.0 + com.baeldung + core-java-8 + 0.1.0-SNAPSHOT + core-java-8 + jar + + + com.baeldung + parent-java + 0.0.1-SNAPSHOT + ../../parent-java + + + + + org.apache.commons + commons-collections4 + ${commons-collections4.version} + + + commons-io + commons-io + ${commons-io.version} + + + org.apache.commons + commons-lang3 + ${commons-lang3.version} + + + org.apache.commons + commons-math3 + ${commons-math3.version} + + + log4j + log4j + ${log4j.version} + + + commons-codec + commons-codec + ${commons-codec.version} + + + org.projectlombok + lombok + ${lombok.version} + provided + + + + org.assertj + assertj-core + ${assertj.version} + test + + + com.jayway.awaitility + awaitility + ${avaitility.version} + test + + + org.openjdk.jmh + jmh-core + ${jmh-core.version} + + + org.openjdk.jmh + jmh-generator-annprocess + ${jmh-generator.version} + + + org.openjdk.jmh + jmh-generator-bytecode + ${jmh-generator.version} + + + com.codepoetics + protonpack + ${protonpack.version} + + + io.vavr + vavr + ${vavr.version} + + + joda-time + joda-time + ${joda.version} + + + org.aspectj + aspectjrt + ${asspectj.version} + + + org.aspectj + aspectjweaver + ${asspectj.version} + + + org.powermock + powermock-module-junit4 + ${powermock.version} + test + + + org.powermock + powermock-api-mockito2 + ${powermock.version} + test + + + org.jmockit + jmockit + ${jmockit.version} + test + + + + + core-java-8 + + + src/main/resources + true + + + + + + org.apache.maven.plugins + maven-compiler-plugin + ${maven-compiler-plugin.version} + + 1.8 + 1.8 + -parameters + + + + org.springframework.boot + spring-boot-maven-plugin + ${spring-boot-maven-plugin.version} + + + + repackage + + + spring-boot + org.baeldung.executable.ExecutableMavenJar + + + + + + maven-surefire-plugin + ${maven-surefire-plugin.version} + + + -javaagent:${settings.localRepository}/org/jmockit/jmockit/${jmockit.version}/jmockit-${jmockit.version}.jar + + true + + + + + + + + 3.5 + 3.6.1 + 4.1 + 4.01 + 1.10 + 0.9.0 + 1.13 + 2.10 + + 3.6.1 + 1.8.9 + 2.0.0-RC.4 + 1.44 + 1.7.0 + 1.19 + 1.19 + 2.0.4.RELEASE + + 3.8.0 + 2.22.1 + + diff --git a/core-java-8/src/main/java/com/baeldung/annotations/ClassWithAnnotation.java b/core-java-modules/core-java-8/src/main/java/com/baeldung/annotations/ClassWithAnnotation.java similarity index 100% rename from core-java-8/src/main/java/com/baeldung/annotations/ClassWithAnnotation.java rename to core-java-modules/core-java-8/src/main/java/com/baeldung/annotations/ClassWithAnnotation.java diff --git a/core-java-8/src/main/java/com/baeldung/annotations/ClassWithDeprecatedMethod.java b/core-java-modules/core-java-8/src/main/java/com/baeldung/annotations/ClassWithDeprecatedMethod.java similarity index 100% rename from core-java-8/src/main/java/com/baeldung/annotations/ClassWithDeprecatedMethod.java rename to core-java-modules/core-java-8/src/main/java/com/baeldung/annotations/ClassWithDeprecatedMethod.java diff --git a/core-java-8/src/main/java/com/baeldung/annotations/ClassWithSafeVarargs.java b/core-java-modules/core-java-8/src/main/java/com/baeldung/annotations/ClassWithSafeVarargs.java similarity index 100% rename from core-java-8/src/main/java/com/baeldung/annotations/ClassWithSafeVarargs.java rename to core-java-modules/core-java-8/src/main/java/com/baeldung/annotations/ClassWithSafeVarargs.java diff --git a/core-java-8/src/main/java/com/baeldung/annotations/ClassWithSuppressWarnings.java b/core-java-modules/core-java-8/src/main/java/com/baeldung/annotations/ClassWithSuppressWarnings.java similarity index 100% rename from core-java-8/src/main/java/com/baeldung/annotations/ClassWithSuppressWarnings.java rename to core-java-modules/core-java-8/src/main/java/com/baeldung/annotations/ClassWithSuppressWarnings.java diff --git a/core-java-8/src/main/java/com/baeldung/annotations/IntConsumer.java b/core-java-modules/core-java-8/src/main/java/com/baeldung/annotations/IntConsumer.java similarity index 100% rename from core-java-8/src/main/java/com/baeldung/annotations/IntConsumer.java rename to core-java-modules/core-java-8/src/main/java/com/baeldung/annotations/IntConsumer.java diff --git a/core-java-8/src/main/java/com/baeldung/annotations/Interval.java b/core-java-modules/core-java-8/src/main/java/com/baeldung/annotations/Interval.java similarity index 100% rename from core-java-8/src/main/java/com/baeldung/annotations/Interval.java rename to core-java-modules/core-java-8/src/main/java/com/baeldung/annotations/Interval.java diff --git a/core-java-8/src/main/java/com/baeldung/annotations/IntervalUsage.java b/core-java-modules/core-java-8/src/main/java/com/baeldung/annotations/IntervalUsage.java similarity index 100% rename from core-java-8/src/main/java/com/baeldung/annotations/IntervalUsage.java rename to core-java-modules/core-java-8/src/main/java/com/baeldung/annotations/IntervalUsage.java diff --git a/core-java-8/src/main/java/com/baeldung/annotations/Intervals.java b/core-java-modules/core-java-8/src/main/java/com/baeldung/annotations/Intervals.java similarity index 100% rename from core-java-8/src/main/java/com/baeldung/annotations/Intervals.java rename to core-java-modules/core-java-8/src/main/java/com/baeldung/annotations/Intervals.java diff --git a/core-java-8/src/main/java/com/baeldung/annotations/MyAnnotation.java b/core-java-modules/core-java-8/src/main/java/com/baeldung/annotations/MyAnnotation.java similarity index 100% rename from core-java-8/src/main/java/com/baeldung/annotations/MyAnnotation.java rename to core-java-modules/core-java-8/src/main/java/com/baeldung/annotations/MyAnnotation.java diff --git a/core-java-8/src/main/java/com/baeldung/annotations/MyAnnotationTarget.java b/core-java-modules/core-java-8/src/main/java/com/baeldung/annotations/MyAnnotationTarget.java similarity index 100% rename from core-java-8/src/main/java/com/baeldung/annotations/MyAnnotationTarget.java rename to core-java-modules/core-java-8/src/main/java/com/baeldung/annotations/MyAnnotationTarget.java diff --git a/core-java-8/src/main/java/com/baeldung/annotations/MyOperation.java b/core-java-modules/core-java-8/src/main/java/com/baeldung/annotations/MyOperation.java similarity index 100% rename from core-java-8/src/main/java/com/baeldung/annotations/MyOperation.java rename to core-java-modules/core-java-8/src/main/java/com/baeldung/annotations/MyOperation.java diff --git a/core-java-8/src/main/java/com/baeldung/annotations/MyOperationImpl.java b/core-java-modules/core-java-8/src/main/java/com/baeldung/annotations/MyOperationImpl.java similarity index 100% rename from core-java-8/src/main/java/com/baeldung/annotations/MyOperationImpl.java rename to core-java-modules/core-java-8/src/main/java/com/baeldung/annotations/MyOperationImpl.java diff --git a/core-java-8/src/main/java/com/baeldung/aspect/ChangeCallsToCurrentTimeInMillisMethod.aj b/core-java-modules/core-java-8/src/main/java/com/baeldung/aspect/ChangeCallsToCurrentTimeInMillisMethod.aj similarity index 100% rename from core-java-8/src/main/java/com/baeldung/aspect/ChangeCallsToCurrentTimeInMillisMethod.aj rename to core-java-modules/core-java-8/src/main/java/com/baeldung/aspect/ChangeCallsToCurrentTimeInMillisMethod.aj diff --git a/core-java-8/src/main/java/com/baeldung/customannotations/Init.java b/core-java-modules/core-java-8/src/main/java/com/baeldung/customannotations/Init.java similarity index 95% rename from core-java-8/src/main/java/com/baeldung/customannotations/Init.java rename to core-java-modules/core-java-8/src/main/java/com/baeldung/customannotations/Init.java index 265e7ba1d6..c27d7d7980 100644 --- a/core-java-8/src/main/java/com/baeldung/customannotations/Init.java +++ b/core-java-modules/core-java-8/src/main/java/com/baeldung/customannotations/Init.java @@ -1,13 +1,13 @@ -package com.baeldung.customannotations; - -import static java.lang.annotation.ElementType.METHOD; -import static java.lang.annotation.RetentionPolicy.RUNTIME; - -import java.lang.annotation.Retention; -import java.lang.annotation.Target; - -@Retention(RUNTIME) -@Target(METHOD) -public @interface Init { - -} +package com.baeldung.customannotations; + +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.RetentionPolicy.RUNTIME; + +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +@Retention(RUNTIME) +@Target(METHOD) +public @interface Init { + +} diff --git a/core-java-8/src/main/java/com/baeldung/customannotations/JsonElement.java b/core-java-modules/core-java-8/src/main/java/com/baeldung/customannotations/JsonElement.java similarity index 96% rename from core-java-8/src/main/java/com/baeldung/customannotations/JsonElement.java rename to core-java-modules/core-java-8/src/main/java/com/baeldung/customannotations/JsonElement.java index e41a5b1e30..3c953f9081 100644 --- a/core-java-8/src/main/java/com/baeldung/customannotations/JsonElement.java +++ b/core-java-modules/core-java-8/src/main/java/com/baeldung/customannotations/JsonElement.java @@ -1,13 +1,13 @@ -package com.baeldung.customannotations; - -import static java.lang.annotation.ElementType.FIELD; -import static java.lang.annotation.RetentionPolicy.RUNTIME; - -import java.lang.annotation.Retention; -import java.lang.annotation.Target; - -@Retention(RUNTIME) -@Target({ FIELD }) -public @interface JsonElement { - public String key() default ""; -} +package com.baeldung.customannotations; + +import static java.lang.annotation.ElementType.FIELD; +import static java.lang.annotation.RetentionPolicy.RUNTIME; + +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +@Retention(RUNTIME) +@Target({ FIELD }) +public @interface JsonElement { + public String key() default ""; +} diff --git a/core-java-8/src/main/java/com/baeldung/customannotations/JsonSerializable.java b/core-java-modules/core-java-8/src/main/java/com/baeldung/customannotations/JsonSerializable.java similarity index 95% rename from core-java-8/src/main/java/com/baeldung/customannotations/JsonSerializable.java rename to core-java-modules/core-java-8/src/main/java/com/baeldung/customannotations/JsonSerializable.java index 48eeb09a1b..f6feba1b7b 100644 --- a/core-java-8/src/main/java/com/baeldung/customannotations/JsonSerializable.java +++ b/core-java-modules/core-java-8/src/main/java/com/baeldung/customannotations/JsonSerializable.java @@ -1,13 +1,13 @@ -package com.baeldung.customannotations; - -import static java.lang.annotation.ElementType.TYPE; -import static java.lang.annotation.RetentionPolicy.RUNTIME; - -import java.lang.annotation.Retention; -import java.lang.annotation.Target; - -@Retention(RUNTIME) -@Target(TYPE) -public @interface JsonSerializable { - -} +package com.baeldung.customannotations; + +import static java.lang.annotation.ElementType.TYPE; +import static java.lang.annotation.RetentionPolicy.RUNTIME; + +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +@Retention(RUNTIME) +@Target(TYPE) +public @interface JsonSerializable { + +} diff --git a/core-java-8/src/main/java/com/baeldung/customannotations/JsonSerializationException.java b/core-java-modules/core-java-8/src/main/java/com/baeldung/customannotations/JsonSerializationException.java similarity index 96% rename from core-java-8/src/main/java/com/baeldung/customannotations/JsonSerializationException.java rename to core-java-modules/core-java-8/src/main/java/com/baeldung/customannotations/JsonSerializationException.java index f2c29855ac..544d1311aa 100644 --- a/core-java-8/src/main/java/com/baeldung/customannotations/JsonSerializationException.java +++ b/core-java-modules/core-java-8/src/main/java/com/baeldung/customannotations/JsonSerializationException.java @@ -1,10 +1,10 @@ -package com.baeldung.customannotations; - -public class JsonSerializationException extends RuntimeException { - - private static final long serialVersionUID = 1L; - - public JsonSerializationException(String message) { - super(message); - } -} +package com.baeldung.customannotations; + +public class JsonSerializationException extends RuntimeException { + + private static final long serialVersionUID = 1L; + + public JsonSerializationException(String message) { + super(message); + } +} diff --git a/core-java-8/src/main/java/com/baeldung/customannotations/ObjectToJsonConverter.java b/core-java-modules/core-java-8/src/main/java/com/baeldung/customannotations/ObjectToJsonConverter.java similarity index 97% rename from core-java-8/src/main/java/com/baeldung/customannotations/ObjectToJsonConverter.java rename to core-java-modules/core-java-8/src/main/java/com/baeldung/customannotations/ObjectToJsonConverter.java index dd126be8ed..b809ea0d1d 100644 --- a/core-java-8/src/main/java/com/baeldung/customannotations/ObjectToJsonConverter.java +++ b/core-java-modules/core-java-8/src/main/java/com/baeldung/customannotations/ObjectToJsonConverter.java @@ -1,67 +1,67 @@ -package com.baeldung.customannotations; - -import java.lang.reflect.Field; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.stream.Collectors; - -public class ObjectToJsonConverter { - public String convertToJson(Object object) throws JsonSerializationException { - try { - - checkIfSerializable(object); - initializeObject(object); - return getJsonString(object); - - } catch (Exception e) { - throw new JsonSerializationException(e.getMessage()); - } - } - - private void checkIfSerializable(Object object) { - if (Objects.isNull(object)) { - throw new JsonSerializationException("Can't serialize a null object"); - } - - Class clazz = object.getClass(); - if (!clazz.isAnnotationPresent(JsonSerializable.class)) { - throw new JsonSerializationException("The class " + clazz.getSimpleName() + " is not annotated with JsonSerializable"); - } - } - - private void initializeObject(Object object) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException { - Class clazz = object.getClass(); - for (Method method : clazz.getDeclaredMethods()) { - if (method.isAnnotationPresent(Init.class)) { - method.setAccessible(true); - method.invoke(object); - } - } - } - - private String getJsonString(Object object) throws IllegalArgumentException, IllegalAccessException { - Class clazz = object.getClass(); - Map jsonElementsMap = new HashMap<>(); - for (Field field : clazz.getDeclaredFields()) { - field.setAccessible(true); - if (field.isAnnotationPresent(JsonElement.class)) { - jsonElementsMap.put(getKey(field), (String) field.get(object)); - } - } - - String jsonString = jsonElementsMap.entrySet() - .stream() - .map(entry -> "\"" + entry.getKey() + "\":\"" + entry.getValue() + "\"") - .collect(Collectors.joining(",")); - return "{" + jsonString + "}"; - } - - private String getKey(Field field) { - String value = field.getAnnotation(JsonElement.class) - .key(); - return value.isEmpty() ? field.getName() : value; - } -} +package com.baeldung.customannotations; + +import java.lang.reflect.Field; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.stream.Collectors; + +public class ObjectToJsonConverter { + public String convertToJson(Object object) throws JsonSerializationException { + try { + + checkIfSerializable(object); + initializeObject(object); + return getJsonString(object); + + } catch (Exception e) { + throw new JsonSerializationException(e.getMessage()); + } + } + + private void checkIfSerializable(Object object) { + if (Objects.isNull(object)) { + throw new JsonSerializationException("Can't serialize a null object"); + } + + Class clazz = object.getClass(); + if (!clazz.isAnnotationPresent(JsonSerializable.class)) { + throw new JsonSerializationException("The class " + clazz.getSimpleName() + " is not annotated with JsonSerializable"); + } + } + + private void initializeObject(Object object) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException { + Class clazz = object.getClass(); + for (Method method : clazz.getDeclaredMethods()) { + if (method.isAnnotationPresent(Init.class)) { + method.setAccessible(true); + method.invoke(object); + } + } + } + + private String getJsonString(Object object) throws IllegalArgumentException, IllegalAccessException { + Class clazz = object.getClass(); + Map jsonElementsMap = new HashMap<>(); + for (Field field : clazz.getDeclaredFields()) { + field.setAccessible(true); + if (field.isAnnotationPresent(JsonElement.class)) { + jsonElementsMap.put(getKey(field), (String) field.get(object)); + } + } + + String jsonString = jsonElementsMap.entrySet() + .stream() + .map(entry -> "\"" + entry.getKey() + "\":\"" + entry.getValue() + "\"") + .collect(Collectors.joining(",")); + return "{" + jsonString + "}"; + } + + private String getKey(Field field) { + String value = field.getAnnotation(JsonElement.class) + .key(); + return value.isEmpty() ? field.getName() : value; + } +} diff --git a/core-java-8/src/main/java/com/baeldung/customannotations/Person.java b/core-java-modules/core-java-8/src/main/java/com/baeldung/customannotations/Person.java similarity index 95% rename from core-java-8/src/main/java/com/baeldung/customannotations/Person.java rename to core-java-modules/core-java-8/src/main/java/com/baeldung/customannotations/Person.java index 5db1a7f279..ba702d6d76 100644 --- a/core-java-8/src/main/java/com/baeldung/customannotations/Person.java +++ b/core-java-modules/core-java-8/src/main/java/com/baeldung/customannotations/Person.java @@ -1,66 +1,66 @@ -package com.baeldung.customannotations; - -@JsonSerializable -public class Person { - @JsonElement - private String firstName; - @JsonElement - private String lastName; - @JsonElement(key = "personAge") - private String age; - - private String address; - - public Person(String firstName, String lastName) { - super(); - this.firstName = firstName; - this.lastName = lastName; - } - - public Person(String firstName, String lastName, String age) { - this.firstName = firstName; - this.lastName = lastName; - this.age = age; - } - - @Init - private void initNames() { - this.firstName = this.firstName.substring(0, 1) - .toUpperCase() + this.firstName.substring(1); - this.lastName = this.lastName.substring(0, 1) - .toUpperCase() + this.lastName.substring(1); - } - - public String getFirstName() { - return firstName; - } - - public void setFirstName(String firstName) { - this.firstName = firstName; - } - - public String getLastName() { - return lastName; - } - - public void setLastName(String lastName) { - this.lastName = lastName; - } - - public String getAge() { - return age; - } - - public void setAge(String age) { - this.age = age; - } - - public String getAddress() { - return address; - } - - public void setAddress(String address) { - this.address = address; - } - -} +package com.baeldung.customannotations; + +@JsonSerializable +public class Person { + @JsonElement + private String firstName; + @JsonElement + private String lastName; + @JsonElement(key = "personAge") + private String age; + + private String address; + + public Person(String firstName, String lastName) { + super(); + this.firstName = firstName; + this.lastName = lastName; + } + + public Person(String firstName, String lastName, String age) { + this.firstName = firstName; + this.lastName = lastName; + this.age = age; + } + + @Init + private void initNames() { + this.firstName = this.firstName.substring(0, 1) + .toUpperCase() + this.firstName.substring(1); + this.lastName = this.lastName.substring(0, 1) + .toUpperCase() + this.lastName.substring(1); + } + + public String getFirstName() { + return firstName; + } + + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + public String getLastName() { + return lastName; + } + + public void setLastName(String lastName) { + this.lastName = lastName; + } + + public String getAge() { + return age; + } + + public void setAge(String age) { + this.age = age; + } + + public String getAddress() { + return address; + } + + public void setAddress(String address) { + this.address = address; + } + +} diff --git a/core-java-8/src/main/java/com/baeldung/defaultstaticinterfacemethods/application/Application.java b/core-java-modules/core-java-8/src/main/java/com/baeldung/defaultstaticinterfacemethods/application/Application.java similarity index 100% rename from core-java-8/src/main/java/com/baeldung/defaultstaticinterfacemethods/application/Application.java rename to core-java-modules/core-java-8/src/main/java/com/baeldung/defaultstaticinterfacemethods/application/Application.java diff --git a/core-java-8/src/main/java/com/baeldung/defaultstaticinterfacemethods/model/Alarm.java b/core-java-modules/core-java-8/src/main/java/com/baeldung/defaultstaticinterfacemethods/model/Alarm.java similarity index 100% rename from core-java-8/src/main/java/com/baeldung/defaultstaticinterfacemethods/model/Alarm.java rename to core-java-modules/core-java-8/src/main/java/com/baeldung/defaultstaticinterfacemethods/model/Alarm.java diff --git a/core-java-8/src/main/java/com/baeldung/defaultstaticinterfacemethods/model/Car.java b/core-java-modules/core-java-8/src/main/java/com/baeldung/defaultstaticinterfacemethods/model/Car.java similarity index 100% rename from core-java-8/src/main/java/com/baeldung/defaultstaticinterfacemethods/model/Car.java rename to core-java-modules/core-java-8/src/main/java/com/baeldung/defaultstaticinterfacemethods/model/Car.java diff --git a/core-java-8/src/main/java/com/baeldung/defaultstaticinterfacemethods/model/Motorbike.java b/core-java-modules/core-java-8/src/main/java/com/baeldung/defaultstaticinterfacemethods/model/Motorbike.java similarity index 100% rename from core-java-8/src/main/java/com/baeldung/defaultstaticinterfacemethods/model/Motorbike.java rename to core-java-modules/core-java-8/src/main/java/com/baeldung/defaultstaticinterfacemethods/model/Motorbike.java diff --git a/core-java-8/src/main/java/com/baeldung/defaultstaticinterfacemethods/model/MultiAlarmCar.java b/core-java-modules/core-java-8/src/main/java/com/baeldung/defaultstaticinterfacemethods/model/MultiAlarmCar.java similarity index 100% rename from core-java-8/src/main/java/com/baeldung/defaultstaticinterfacemethods/model/MultiAlarmCar.java rename to core-java-modules/core-java-8/src/main/java/com/baeldung/defaultstaticinterfacemethods/model/MultiAlarmCar.java diff --git a/core-java-8/src/main/java/com/baeldung/defaultstaticinterfacemethods/model/Vehicle.java b/core-java-modules/core-java-8/src/main/java/com/baeldung/defaultstaticinterfacemethods/model/Vehicle.java similarity index 100% rename from core-java-8/src/main/java/com/baeldung/defaultstaticinterfacemethods/model/Vehicle.java rename to core-java-modules/core-java-8/src/main/java/com/baeldung/defaultstaticinterfacemethods/model/Vehicle.java diff --git a/core-java-8/src/main/java/com/baeldung/doublecolon/Computer.java b/core-java-modules/core-java-8/src/main/java/com/baeldung/doublecolon/Computer.java similarity index 100% rename from core-java-8/src/main/java/com/baeldung/doublecolon/Computer.java rename to core-java-modules/core-java-8/src/main/java/com/baeldung/doublecolon/Computer.java diff --git a/core-java-8/src/main/java/com/baeldung/doublecolon/ComputerUtils.java b/core-java-modules/core-java-8/src/main/java/com/baeldung/doublecolon/ComputerUtils.java similarity index 100% rename from core-java-8/src/main/java/com/baeldung/doublecolon/ComputerUtils.java rename to core-java-modules/core-java-8/src/main/java/com/baeldung/doublecolon/ComputerUtils.java diff --git a/core-java-8/src/main/java/com/baeldung/doublecolon/MacbookPro.java b/core-java-modules/core-java-8/src/main/java/com/baeldung/doublecolon/MacbookPro.java similarity index 100% rename from core-java-8/src/main/java/com/baeldung/doublecolon/MacbookPro.java rename to core-java-modules/core-java-8/src/main/java/com/baeldung/doublecolon/MacbookPro.java diff --git a/core-java-8/src/main/java/com/baeldung/doublecolon/function/ComputerPredicate.java b/core-java-modules/core-java-8/src/main/java/com/baeldung/doublecolon/function/ComputerPredicate.java similarity index 100% rename from core-java-8/src/main/java/com/baeldung/doublecolon/function/ComputerPredicate.java rename to core-java-modules/core-java-8/src/main/java/com/baeldung/doublecolon/function/ComputerPredicate.java diff --git a/core-java-8/src/main/java/com/baeldung/doublecolon/function/TriFunction.java b/core-java-modules/core-java-8/src/main/java/com/baeldung/doublecolon/function/TriFunction.java similarity index 100% rename from core-java-8/src/main/java/com/baeldung/doublecolon/function/TriFunction.java rename to core-java-modules/core-java-8/src/main/java/com/baeldung/doublecolon/function/TriFunction.java diff --git a/core-java-8/src/main/java/com/baeldung/java8/lambda/exceptions/LambdaExceptionWrappers.java b/core-java-modules/core-java-8/src/main/java/com/baeldung/java8/lambda/exceptions/LambdaExceptionWrappers.java similarity index 100% rename from core-java-8/src/main/java/com/baeldung/java8/lambda/exceptions/LambdaExceptionWrappers.java rename to core-java-modules/core-java-8/src/main/java/com/baeldung/java8/lambda/exceptions/LambdaExceptionWrappers.java diff --git a/core-java-8/src/main/java/com/baeldung/java8/lambda/exceptions/ThrowingConsumer.java b/core-java-modules/core-java-8/src/main/java/com/baeldung/java8/lambda/exceptions/ThrowingConsumer.java similarity index 100% rename from core-java-8/src/main/java/com/baeldung/java8/lambda/exceptions/ThrowingConsumer.java rename to core-java-modules/core-java-8/src/main/java/com/baeldung/java8/lambda/exceptions/ThrowingConsumer.java diff --git a/core-java-8/src/main/java/com/baeldung/java8/lambda/tips/Bar.java b/core-java-modules/core-java-8/src/main/java/com/baeldung/java8/lambda/tips/Bar.java similarity index 100% rename from core-java-8/src/main/java/com/baeldung/java8/lambda/tips/Bar.java rename to core-java-modules/core-java-8/src/main/java/com/baeldung/java8/lambda/tips/Bar.java diff --git a/core-java-8/src/main/java/com/baeldung/java8/lambda/tips/Baz.java b/core-java-modules/core-java-8/src/main/java/com/baeldung/java8/lambda/tips/Baz.java similarity index 100% rename from core-java-8/src/main/java/com/baeldung/java8/lambda/tips/Baz.java rename to core-java-modules/core-java-8/src/main/java/com/baeldung/java8/lambda/tips/Baz.java diff --git a/core-java-8/src/main/java/com/baeldung/java8/lambda/tips/Foo.java b/core-java-modules/core-java-8/src/main/java/com/baeldung/java8/lambda/tips/Foo.java similarity index 100% rename from core-java-8/src/main/java/com/baeldung/java8/lambda/tips/Foo.java rename to core-java-modules/core-java-8/src/main/java/com/baeldung/java8/lambda/tips/Foo.java diff --git a/core-java-8/src/main/java/com/baeldung/java8/lambda/tips/FooExtended.java b/core-java-modules/core-java-8/src/main/java/com/baeldung/java8/lambda/tips/FooExtended.java similarity index 100% rename from core-java-8/src/main/java/com/baeldung/java8/lambda/tips/FooExtended.java rename to core-java-modules/core-java-8/src/main/java/com/baeldung/java8/lambda/tips/FooExtended.java diff --git a/core-java-8/src/main/java/com/baeldung/java8/lambda/tips/Processor.java b/core-java-modules/core-java-8/src/main/java/com/baeldung/java8/lambda/tips/Processor.java similarity index 100% rename from core-java-8/src/main/java/com/baeldung/java8/lambda/tips/Processor.java rename to core-java-modules/core-java-8/src/main/java/com/baeldung/java8/lambda/tips/Processor.java diff --git a/core-java-8/src/main/java/com/baeldung/java8/lambda/tips/ProcessorImpl.java b/core-java-modules/core-java-8/src/main/java/com/baeldung/java8/lambda/tips/ProcessorImpl.java similarity index 100% rename from core-java-8/src/main/java/com/baeldung/java8/lambda/tips/ProcessorImpl.java rename to core-java-modules/core-java-8/src/main/java/com/baeldung/java8/lambda/tips/ProcessorImpl.java diff --git a/core-java-8/src/main/java/com/baeldung/java8/lambda/tips/UseFoo.java b/core-java-modules/core-java-8/src/main/java/com/baeldung/java8/lambda/tips/UseFoo.java similarity index 100% rename from core-java-8/src/main/java/com/baeldung/java8/lambda/tips/UseFoo.java rename to core-java-modules/core-java-8/src/main/java/com/baeldung/java8/lambda/tips/UseFoo.java diff --git a/core-java-8/src/main/java/com/baeldung/java_8_features/Address.java b/core-java-modules/core-java-8/src/main/java/com/baeldung/java_8_features/Address.java similarity index 100% rename from core-java-8/src/main/java/com/baeldung/java_8_features/Address.java rename to core-java-modules/core-java-8/src/main/java/com/baeldung/java_8_features/Address.java diff --git a/core-java-8/src/main/java/com/baeldung/java_8_features/CustomException.java b/core-java-modules/core-java-8/src/main/java/com/baeldung/java_8_features/CustomException.java similarity index 100% rename from core-java-8/src/main/java/com/baeldung/java_8_features/CustomException.java rename to core-java-modules/core-java-8/src/main/java/com/baeldung/java_8_features/CustomException.java diff --git a/core-java-8/src/main/java/com/baeldung/java_8_features/OptionalAddress.java b/core-java-modules/core-java-8/src/main/java/com/baeldung/java_8_features/OptionalAddress.java similarity index 100% rename from core-java-8/src/main/java/com/baeldung/java_8_features/OptionalAddress.java rename to core-java-modules/core-java-8/src/main/java/com/baeldung/java_8_features/OptionalAddress.java diff --git a/core-java-8/src/main/java/com/baeldung/java_8_features/OptionalUser.java b/core-java-modules/core-java-8/src/main/java/com/baeldung/java_8_features/OptionalUser.java similarity index 100% rename from core-java-8/src/main/java/com/baeldung/java_8_features/OptionalUser.java rename to core-java-modules/core-java-8/src/main/java/com/baeldung/java_8_features/OptionalUser.java diff --git a/core-java-8/src/main/java/com/baeldung/java_8_features/User.java b/core-java-modules/core-java-8/src/main/java/com/baeldung/java_8_features/User.java similarity index 100% rename from core-java-8/src/main/java/com/baeldung/java_8_features/User.java rename to core-java-modules/core-java-8/src/main/java/com/baeldung/java_8_features/User.java diff --git a/core-java-8/src/main/java/com/baeldung/java_8_features/Vehicle.java b/core-java-modules/core-java-8/src/main/java/com/baeldung/java_8_features/Vehicle.java similarity index 100% rename from core-java-8/src/main/java/com/baeldung/java_8_features/Vehicle.java rename to core-java-modules/core-java-8/src/main/java/com/baeldung/java_8_features/Vehicle.java diff --git a/core-java-8/src/main/java/com/baeldung/java_8_features/VehicleImpl.java b/core-java-modules/core-java-8/src/main/java/com/baeldung/java_8_features/VehicleImpl.java similarity index 100% rename from core-java-8/src/main/java/com/baeldung/java_8_features/VehicleImpl.java rename to core-java-modules/core-java-8/src/main/java/com/baeldung/java_8_features/VehicleImpl.java diff --git a/core-java-8/src/main/java/com/baeldung/java_8_features/groupingby/BlogPost.java b/core-java-modules/core-java-8/src/main/java/com/baeldung/java_8_features/groupingby/BlogPost.java similarity index 100% rename from core-java-8/src/main/java/com/baeldung/java_8_features/groupingby/BlogPost.java rename to core-java-modules/core-java-8/src/main/java/com/baeldung/java_8_features/groupingby/BlogPost.java diff --git a/core-java-8/src/main/java/com/baeldung/java_8_features/groupingby/BlogPostType.java b/core-java-modules/core-java-8/src/main/java/com/baeldung/java_8_features/groupingby/BlogPostType.java similarity index 100% rename from core-java-8/src/main/java/com/baeldung/java_8_features/groupingby/BlogPostType.java rename to core-java-modules/core-java-8/src/main/java/com/baeldung/java_8_features/groupingby/BlogPostType.java diff --git a/core-java-8/src/main/java/com/baeldung/nullsafecollectionstreams/NullSafeCollectionStreamsUsingCommonsEmptyIfNull.java b/core-java-modules/core-java-8/src/main/java/com/baeldung/nullsafecollectionstreams/NullSafeCollectionStreamsUsingCommonsEmptyIfNull.java similarity index 100% rename from core-java-8/src/main/java/com/baeldung/nullsafecollectionstreams/NullSafeCollectionStreamsUsingCommonsEmptyIfNull.java rename to core-java-modules/core-java-8/src/main/java/com/baeldung/nullsafecollectionstreams/NullSafeCollectionStreamsUsingCommonsEmptyIfNull.java diff --git a/core-java-8/src/main/java/com/baeldung/nullsafecollectionstreams/NullSafeCollectionStreamsUsingJava8OptionalContainer.java b/core-java-modules/core-java-8/src/main/java/com/baeldung/nullsafecollectionstreams/NullSafeCollectionStreamsUsingJava8OptionalContainer.java similarity index 100% rename from core-java-8/src/main/java/com/baeldung/nullsafecollectionstreams/NullSafeCollectionStreamsUsingJava8OptionalContainer.java rename to core-java-modules/core-java-8/src/main/java/com/baeldung/nullsafecollectionstreams/NullSafeCollectionStreamsUsingJava8OptionalContainer.java diff --git a/core-java-8/src/main/java/com/baeldung/nullsafecollectionstreams/NullSafeCollectionStreamsUsingNullDereferenceCheck.java b/core-java-modules/core-java-8/src/main/java/com/baeldung/nullsafecollectionstreams/NullSafeCollectionStreamsUsingNullDereferenceCheck.java similarity index 100% rename from core-java-8/src/main/java/com/baeldung/nullsafecollectionstreams/NullSafeCollectionStreamsUsingNullDereferenceCheck.java rename to core-java-modules/core-java-8/src/main/java/com/baeldung/nullsafecollectionstreams/NullSafeCollectionStreamsUsingNullDereferenceCheck.java diff --git a/core-java-8/src/main/java/com/baeldung/optional/Modem.java b/core-java-modules/core-java-8/src/main/java/com/baeldung/optional/Modem.java similarity index 100% rename from core-java-8/src/main/java/com/baeldung/optional/Modem.java rename to core-java-modules/core-java-8/src/main/java/com/baeldung/optional/Modem.java diff --git a/core-java-8/src/main/java/com/baeldung/optional/OrElseAndOrElseGet.java b/core-java-modules/core-java-8/src/main/java/com/baeldung/optional/OrElseAndOrElseGet.java similarity index 100% rename from core-java-8/src/main/java/com/baeldung/optional/OrElseAndOrElseGet.java rename to core-java-modules/core-java-8/src/main/java/com/baeldung/optional/OrElseAndOrElseGet.java diff --git a/core-java-8/src/main/java/com/baeldung/optional/OrElseAndOrElseGetBenchmarkRunner.java b/core-java-modules/core-java-8/src/main/java/com/baeldung/optional/OrElseAndOrElseGetBenchmarkRunner.java similarity index 100% rename from core-java-8/src/main/java/com/baeldung/optional/OrElseAndOrElseGetBenchmarkRunner.java rename to core-java-modules/core-java-8/src/main/java/com/baeldung/optional/OrElseAndOrElseGetBenchmarkRunner.java diff --git a/core-java-8/src/main/java/com/baeldung/optional/Person.java b/core-java-modules/core-java-8/src/main/java/com/baeldung/optional/Person.java similarity index 100% rename from core-java-8/src/main/java/com/baeldung/optional/Person.java rename to core-java-modules/core-java-8/src/main/java/com/baeldung/optional/Person.java diff --git a/core-java-8/src/main/java/com/baeldung/optional/PersonRepository.java b/core-java-modules/core-java-8/src/main/java/com/baeldung/optional/PersonRepository.java similarity index 100% rename from core-java-8/src/main/java/com/baeldung/optional/PersonRepository.java rename to core-java-modules/core-java-8/src/main/java/com/baeldung/optional/PersonRepository.java diff --git a/core-java-8/src/main/java/com/baeldung/primitive/BenchmarkRunner.java b/core-java-modules/core-java-8/src/main/java/com/baeldung/primitive/BenchmarkRunner.java similarity index 100% rename from core-java-8/src/main/java/com/baeldung/primitive/BenchmarkRunner.java rename to core-java-modules/core-java-8/src/main/java/com/baeldung/primitive/BenchmarkRunner.java diff --git a/core-java-8/src/main/java/com/baeldung/primitive/BooleanPrimitiveLookup.java b/core-java-modules/core-java-8/src/main/java/com/baeldung/primitive/BooleanPrimitiveLookup.java similarity index 100% rename from core-java-8/src/main/java/com/baeldung/primitive/BooleanPrimitiveLookup.java rename to core-java-modules/core-java-8/src/main/java/com/baeldung/primitive/BooleanPrimitiveLookup.java diff --git a/core-java-8/src/main/java/com/baeldung/primitive/BooleanWrapperLookup.java b/core-java-modules/core-java-8/src/main/java/com/baeldung/primitive/BooleanWrapperLookup.java similarity index 100% rename from core-java-8/src/main/java/com/baeldung/primitive/BooleanWrapperLookup.java rename to core-java-modules/core-java-8/src/main/java/com/baeldung/primitive/BooleanWrapperLookup.java diff --git a/core-java-8/src/main/java/com/baeldung/primitive/BytePrimitiveLookup.java b/core-java-modules/core-java-8/src/main/java/com/baeldung/primitive/BytePrimitiveLookup.java similarity index 100% rename from core-java-8/src/main/java/com/baeldung/primitive/BytePrimitiveLookup.java rename to core-java-modules/core-java-8/src/main/java/com/baeldung/primitive/BytePrimitiveLookup.java diff --git a/core-java-8/src/main/java/com/baeldung/primitive/ByteWrapperLookup.java b/core-java-modules/core-java-8/src/main/java/com/baeldung/primitive/ByteWrapperLookup.java similarity index 100% rename from core-java-8/src/main/java/com/baeldung/primitive/ByteWrapperLookup.java rename to core-java-modules/core-java-8/src/main/java/com/baeldung/primitive/ByteWrapperLookup.java diff --git a/core-java-8/src/main/java/com/baeldung/primitive/CharPrimitiveLookup.java b/core-java-modules/core-java-8/src/main/java/com/baeldung/primitive/CharPrimitiveLookup.java similarity index 100% rename from core-java-8/src/main/java/com/baeldung/primitive/CharPrimitiveLookup.java rename to core-java-modules/core-java-8/src/main/java/com/baeldung/primitive/CharPrimitiveLookup.java diff --git a/core-java-8/src/main/java/com/baeldung/primitive/CharacterWrapperLookup.java b/core-java-modules/core-java-8/src/main/java/com/baeldung/primitive/CharacterWrapperLookup.java similarity index 100% rename from core-java-8/src/main/java/com/baeldung/primitive/CharacterWrapperLookup.java rename to core-java-modules/core-java-8/src/main/java/com/baeldung/primitive/CharacterWrapperLookup.java diff --git a/core-java-8/src/main/java/com/baeldung/primitive/DoublePrimitiveLookup.java b/core-java-modules/core-java-8/src/main/java/com/baeldung/primitive/DoublePrimitiveLookup.java similarity index 100% rename from core-java-8/src/main/java/com/baeldung/primitive/DoublePrimitiveLookup.java rename to core-java-modules/core-java-8/src/main/java/com/baeldung/primitive/DoublePrimitiveLookup.java diff --git a/core-java-8/src/main/java/com/baeldung/primitive/DoubleWrapperLookup.java b/core-java-modules/core-java-8/src/main/java/com/baeldung/primitive/DoubleWrapperLookup.java similarity index 100% rename from core-java-8/src/main/java/com/baeldung/primitive/DoubleWrapperLookup.java rename to core-java-modules/core-java-8/src/main/java/com/baeldung/primitive/DoubleWrapperLookup.java diff --git a/core-java-8/src/main/java/com/baeldung/primitive/FloatPrimitiveLookup.java b/core-java-modules/core-java-8/src/main/java/com/baeldung/primitive/FloatPrimitiveLookup.java similarity index 100% rename from core-java-8/src/main/java/com/baeldung/primitive/FloatPrimitiveLookup.java rename to core-java-modules/core-java-8/src/main/java/com/baeldung/primitive/FloatPrimitiveLookup.java diff --git a/core-java-8/src/main/java/com/baeldung/primitive/FloatWrapperLookup.java b/core-java-modules/core-java-8/src/main/java/com/baeldung/primitive/FloatWrapperLookup.java similarity index 100% rename from core-java-8/src/main/java/com/baeldung/primitive/FloatWrapperLookup.java rename to core-java-modules/core-java-8/src/main/java/com/baeldung/primitive/FloatWrapperLookup.java diff --git a/core-java-8/src/main/java/com/baeldung/primitive/IntPrimitiveLookup.java b/core-java-modules/core-java-8/src/main/java/com/baeldung/primitive/IntPrimitiveLookup.java similarity index 100% rename from core-java-8/src/main/java/com/baeldung/primitive/IntPrimitiveLookup.java rename to core-java-modules/core-java-8/src/main/java/com/baeldung/primitive/IntPrimitiveLookup.java diff --git a/core-java-8/src/main/java/com/baeldung/primitive/IntegerWrapperLookup.java b/core-java-modules/core-java-8/src/main/java/com/baeldung/primitive/IntegerWrapperLookup.java similarity index 100% rename from core-java-8/src/main/java/com/baeldung/primitive/IntegerWrapperLookup.java rename to core-java-modules/core-java-8/src/main/java/com/baeldung/primitive/IntegerWrapperLookup.java diff --git a/core-java-8/src/main/java/com/baeldung/primitive/LongPrimitiveLookup.java b/core-java-modules/core-java-8/src/main/java/com/baeldung/primitive/LongPrimitiveLookup.java similarity index 100% rename from core-java-8/src/main/java/com/baeldung/primitive/LongPrimitiveLookup.java rename to core-java-modules/core-java-8/src/main/java/com/baeldung/primitive/LongPrimitiveLookup.java diff --git a/core-java-8/src/main/java/com/baeldung/primitive/LongWrapperLookup.java b/core-java-modules/core-java-8/src/main/java/com/baeldung/primitive/LongWrapperLookup.java similarity index 100% rename from core-java-8/src/main/java/com/baeldung/primitive/LongWrapperLookup.java rename to core-java-modules/core-java-8/src/main/java/com/baeldung/primitive/LongWrapperLookup.java diff --git a/core-java-8/src/main/java/com/baeldung/primitive/Lookup.java b/core-java-modules/core-java-8/src/main/java/com/baeldung/primitive/Lookup.java similarity index 100% rename from core-java-8/src/main/java/com/baeldung/primitive/Lookup.java rename to core-java-modules/core-java-8/src/main/java/com/baeldung/primitive/Lookup.java diff --git a/core-java-8/src/main/java/com/baeldung/primitive/ShortPrimitiveLookup.java b/core-java-modules/core-java-8/src/main/java/com/baeldung/primitive/ShortPrimitiveLookup.java similarity index 100% rename from core-java-8/src/main/java/com/baeldung/primitive/ShortPrimitiveLookup.java rename to core-java-modules/core-java-8/src/main/java/com/baeldung/primitive/ShortPrimitiveLookup.java diff --git a/core-java-8/src/main/java/com/baeldung/primitive/ShortWrapperLookup.java b/core-java-modules/core-java-8/src/main/java/com/baeldung/primitive/ShortWrapperLookup.java similarity index 100% rename from core-java-8/src/main/java/com/baeldung/primitive/ShortWrapperLookup.java rename to core-java-modules/core-java-8/src/main/java/com/baeldung/primitive/ShortWrapperLookup.java diff --git a/core-java-8/src/main/java/com/baeldung/reducingIfElse/AddCommand.java b/core-java-modules/core-java-8/src/main/java/com/baeldung/reducingIfElse/AddCommand.java similarity index 100% rename from core-java-8/src/main/java/com/baeldung/reducingIfElse/AddCommand.java rename to core-java-modules/core-java-8/src/main/java/com/baeldung/reducingIfElse/AddCommand.java diff --git a/core-java-8/src/main/java/com/baeldung/reducingIfElse/AddRule.java b/core-java-modules/core-java-8/src/main/java/com/baeldung/reducingIfElse/AddRule.java similarity index 100% rename from core-java-8/src/main/java/com/baeldung/reducingIfElse/AddRule.java rename to core-java-modules/core-java-8/src/main/java/com/baeldung/reducingIfElse/AddRule.java diff --git a/core-java-8/src/main/java/com/baeldung/reducingIfElse/Addition.java b/core-java-modules/core-java-8/src/main/java/com/baeldung/reducingIfElse/Addition.java similarity index 100% rename from core-java-8/src/main/java/com/baeldung/reducingIfElse/Addition.java rename to core-java-modules/core-java-8/src/main/java/com/baeldung/reducingIfElse/Addition.java diff --git a/core-java-8/src/main/java/com/baeldung/reducingIfElse/Calculator.java b/core-java-modules/core-java-8/src/main/java/com/baeldung/reducingIfElse/Calculator.java similarity index 100% rename from core-java-8/src/main/java/com/baeldung/reducingIfElse/Calculator.java rename to core-java-modules/core-java-8/src/main/java/com/baeldung/reducingIfElse/Calculator.java diff --git a/core-java-8/src/main/java/com/baeldung/reducingIfElse/Command.java b/core-java-modules/core-java-8/src/main/java/com/baeldung/reducingIfElse/Command.java similarity index 100% rename from core-java-8/src/main/java/com/baeldung/reducingIfElse/Command.java rename to core-java-modules/core-java-8/src/main/java/com/baeldung/reducingIfElse/Command.java diff --git a/core-java-8/src/main/java/com/baeldung/reducingIfElse/Division.java b/core-java-modules/core-java-8/src/main/java/com/baeldung/reducingIfElse/Division.java similarity index 100% rename from core-java-8/src/main/java/com/baeldung/reducingIfElse/Division.java rename to core-java-modules/core-java-8/src/main/java/com/baeldung/reducingIfElse/Division.java diff --git a/core-java-8/src/main/java/com/baeldung/reducingIfElse/Expression.java b/core-java-modules/core-java-8/src/main/java/com/baeldung/reducingIfElse/Expression.java similarity index 100% rename from core-java-8/src/main/java/com/baeldung/reducingIfElse/Expression.java rename to core-java-modules/core-java-8/src/main/java/com/baeldung/reducingIfElse/Expression.java diff --git a/core-java-8/src/main/java/com/baeldung/reducingIfElse/Modulo.java b/core-java-modules/core-java-8/src/main/java/com/baeldung/reducingIfElse/Modulo.java similarity index 100% rename from core-java-8/src/main/java/com/baeldung/reducingIfElse/Modulo.java rename to core-java-modules/core-java-8/src/main/java/com/baeldung/reducingIfElse/Modulo.java diff --git a/core-java-8/src/main/java/com/baeldung/reducingIfElse/Multiplication.java b/core-java-modules/core-java-8/src/main/java/com/baeldung/reducingIfElse/Multiplication.java similarity index 100% rename from core-java-8/src/main/java/com/baeldung/reducingIfElse/Multiplication.java rename to core-java-modules/core-java-8/src/main/java/com/baeldung/reducingIfElse/Multiplication.java diff --git a/core-java-8/src/main/java/com/baeldung/reducingIfElse/Operation.java b/core-java-modules/core-java-8/src/main/java/com/baeldung/reducingIfElse/Operation.java similarity index 100% rename from core-java-8/src/main/java/com/baeldung/reducingIfElse/Operation.java rename to core-java-modules/core-java-8/src/main/java/com/baeldung/reducingIfElse/Operation.java diff --git a/core-java-8/src/main/java/com/baeldung/reducingIfElse/Operator.java b/core-java-modules/core-java-8/src/main/java/com/baeldung/reducingIfElse/Operator.java similarity index 100% rename from core-java-8/src/main/java/com/baeldung/reducingIfElse/Operator.java rename to core-java-modules/core-java-8/src/main/java/com/baeldung/reducingIfElse/Operator.java diff --git a/core-java-8/src/main/java/com/baeldung/reducingIfElse/OperatorFactory.java b/core-java-modules/core-java-8/src/main/java/com/baeldung/reducingIfElse/OperatorFactory.java similarity index 100% rename from core-java-8/src/main/java/com/baeldung/reducingIfElse/OperatorFactory.java rename to core-java-modules/core-java-8/src/main/java/com/baeldung/reducingIfElse/OperatorFactory.java diff --git a/core-java-8/src/main/java/com/baeldung/reducingIfElse/Result.java b/core-java-modules/core-java-8/src/main/java/com/baeldung/reducingIfElse/Result.java similarity index 100% rename from core-java-8/src/main/java/com/baeldung/reducingIfElse/Result.java rename to core-java-modules/core-java-8/src/main/java/com/baeldung/reducingIfElse/Result.java diff --git a/core-java-8/src/main/java/com/baeldung/reducingIfElse/Rule.java b/core-java-modules/core-java-8/src/main/java/com/baeldung/reducingIfElse/Rule.java similarity index 100% rename from core-java-8/src/main/java/com/baeldung/reducingIfElse/Rule.java rename to core-java-modules/core-java-8/src/main/java/com/baeldung/reducingIfElse/Rule.java diff --git a/core-java-8/src/main/java/com/baeldung/reducingIfElse/RuleEngine.java b/core-java-modules/core-java-8/src/main/java/com/baeldung/reducingIfElse/RuleEngine.java similarity index 100% rename from core-java-8/src/main/java/com/baeldung/reducingIfElse/RuleEngine.java rename to core-java-modules/core-java-8/src/main/java/com/baeldung/reducingIfElse/RuleEngine.java diff --git a/core-java-8/src/main/java/com/baeldung/reducingIfElse/Subtraction.java b/core-java-modules/core-java-8/src/main/java/com/baeldung/reducingIfElse/Subtraction.java similarity index 100% rename from core-java-8/src/main/java/com/baeldung/reducingIfElse/Subtraction.java rename to core-java-modules/core-java-8/src/main/java/com/baeldung/reducingIfElse/Subtraction.java diff --git a/core-java-8/src/main/java/com/baeldung/reflect/Person.java b/core-java-modules/core-java-8/src/main/java/com/baeldung/reflect/Person.java similarity index 93% rename from core-java-8/src/main/java/com/baeldung/reflect/Person.java rename to core-java-modules/core-java-8/src/main/java/com/baeldung/reflect/Person.java index fba25aca8b..f15250869d 100644 --- a/core-java-8/src/main/java/com/baeldung/reflect/Person.java +++ b/core-java-modules/core-java-8/src/main/java/com/baeldung/reflect/Person.java @@ -1,18 +1,18 @@ -package com.baeldung.reflect; - -public class Person { - - private String fullName; - - public Person(String fullName) { - this.fullName = fullName; - } - - public void setFullName(String fullName) { - this.fullName = fullName; - } - - public String getFullName() { - return fullName; - } -} +package com.baeldung.reflect; + +public class Person { + + private String fullName; + + public Person(String fullName) { + this.fullName = fullName; + } + + public void setFullName(String fullName) { + this.fullName = fullName; + } + + public String getFullName() { + return fullName; + } +} diff --git a/core-java-8/src/main/java/com/baeldung/spliteratorAPI/Article.java b/core-java-modules/core-java-8/src/main/java/com/baeldung/spliteratorAPI/Article.java similarity index 95% rename from core-java-8/src/main/java/com/baeldung/spliteratorAPI/Article.java rename to core-java-modules/core-java-8/src/main/java/com/baeldung/spliteratorAPI/Article.java index 402ec6ec5f..3cd2a00da1 100644 --- a/core-java-8/src/main/java/com/baeldung/spliteratorAPI/Article.java +++ b/core-java-modules/core-java-8/src/main/java/com/baeldung/spliteratorAPI/Article.java @@ -1,44 +1,44 @@ -package com.baeldung.spliteratorAPI; - -import java.util.List; - -public class Article { - private List listOfAuthors; - private int id; - private String name; - - public Article(String name) { - this.name = name; - } - - public Article(List listOfAuthors, int id) { - super(); - this.listOfAuthors = listOfAuthors; - this.id = id; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public int getId() { - return id; - } - - public void setId(int id) { - this.id = id; - } - - public List getListOfAuthors() { - return listOfAuthors; - } - - public void setListOfAuthors(List listOfAuthors) { - this.listOfAuthors = listOfAuthors; - } - +package com.baeldung.spliteratorAPI; + +import java.util.List; + +public class Article { + private List listOfAuthors; + private int id; + private String name; + + public Article(String name) { + this.name = name; + } + + public Article(List listOfAuthors, int id) { + super(); + this.listOfAuthors = listOfAuthors; + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public List getListOfAuthors() { + return listOfAuthors; + } + + public void setListOfAuthors(List listOfAuthors) { + this.listOfAuthors = listOfAuthors; + } + } \ No newline at end of file diff --git a/core-java-8/src/main/java/com/baeldung/spliteratorAPI/Author.java b/core-java-modules/core-java-8/src/main/java/com/baeldung/spliteratorAPI/Author.java similarity index 95% rename from core-java-8/src/main/java/com/baeldung/spliteratorAPI/Author.java rename to core-java-modules/core-java-8/src/main/java/com/baeldung/spliteratorAPI/Author.java index 40c381f4a6..18bbbd073e 100644 --- a/core-java-8/src/main/java/com/baeldung/spliteratorAPI/Author.java +++ b/core-java-modules/core-java-8/src/main/java/com/baeldung/spliteratorAPI/Author.java @@ -1,33 +1,33 @@ -package com.baeldung.spliteratorAPI; - -public class Author { - private String name; - private int relatedArticleId; - - public Author(String name, int relatedArticleId) { - this.name = name; - this.relatedArticleId = relatedArticleId; - } - - public int getRelatedArticleId() { - return relatedArticleId; - } - - public void setRelatedArticleId(int relatedArticleId) { - this.relatedArticleId = relatedArticleId; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - @Override - public String toString() { - return "[name: " + name + ", relatedId: " + relatedArticleId + "]"; - } -} - +package com.baeldung.spliteratorAPI; + +public class Author { + private String name; + private int relatedArticleId; + + public Author(String name, int relatedArticleId) { + this.name = name; + this.relatedArticleId = relatedArticleId; + } + + public int getRelatedArticleId() { + return relatedArticleId; + } + + public void setRelatedArticleId(int relatedArticleId) { + this.relatedArticleId = relatedArticleId; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + @Override + public String toString() { + return "[name: " + name + ", relatedId: " + relatedArticleId + "]"; + } +} + diff --git a/core-java-8/src/main/java/com/baeldung/spliteratorAPI/Executor.java b/core-java-modules/core-java-8/src/main/java/com/baeldung/spliteratorAPI/Executor.java similarity index 96% rename from core-java-8/src/main/java/com/baeldung/spliteratorAPI/Executor.java rename to core-java-modules/core-java-8/src/main/java/com/baeldung/spliteratorAPI/Executor.java index 024d5dabdb..dd124948d8 100644 --- a/core-java-8/src/main/java/com/baeldung/spliteratorAPI/Executor.java +++ b/core-java-modules/core-java-8/src/main/java/com/baeldung/spliteratorAPI/Executor.java @@ -1,19 +1,19 @@ -package com.baeldung.spliteratorAPI; - -import java.util.List; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -public class Executor { - - public static int countAutors(Stream stream) { - RelatedAuthorCounter wordCounter = stream.reduce(new RelatedAuthorCounter(0, true), - RelatedAuthorCounter::accumulate, RelatedAuthorCounter::combine); - return wordCounter.getCounter(); - } - - public static List
generateElements() { - return Stream.generate(() -> new Article("Java")).limit(35000).collect(Collectors.toList()); - } - +package com.baeldung.spliteratorAPI; + +import java.util.List; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +public class Executor { + + public static int countAutors(Stream stream) { + RelatedAuthorCounter wordCounter = stream.reduce(new RelatedAuthorCounter(0, true), + RelatedAuthorCounter::accumulate, RelatedAuthorCounter::combine); + return wordCounter.getCounter(); + } + + public static List
generateElements() { + return Stream.generate(() -> new Article("Java")).limit(35000).collect(Collectors.toList()); + } + } \ No newline at end of file diff --git a/core-java-8/src/main/java/com/baeldung/spliteratorAPI/RelatedAuthorCounter.java b/core-java-modules/core-java-8/src/main/java/com/baeldung/spliteratorAPI/RelatedAuthorCounter.java similarity index 96% rename from core-java-8/src/main/java/com/baeldung/spliteratorAPI/RelatedAuthorCounter.java rename to core-java-modules/core-java-8/src/main/java/com/baeldung/spliteratorAPI/RelatedAuthorCounter.java index b7120b3af2..282c0be727 100644 --- a/core-java-8/src/main/java/com/baeldung/spliteratorAPI/RelatedAuthorCounter.java +++ b/core-java-modules/core-java-8/src/main/java/com/baeldung/spliteratorAPI/RelatedAuthorCounter.java @@ -1,27 +1,27 @@ -package com.baeldung.spliteratorAPI; - -public class RelatedAuthorCounter { - private final int counter; - private final boolean isRelated; - - public RelatedAuthorCounter(int counter, boolean isRelated) { - this.counter = counter; - this.isRelated = isRelated; - } - - public RelatedAuthorCounter accumulate(Author author) { - if (author.getRelatedArticleId() == 0) { - return isRelated ? this : new RelatedAuthorCounter(counter, true); - } else { - return isRelated ? new RelatedAuthorCounter(counter + 1, false) : this; - } - } - - public RelatedAuthorCounter combine(RelatedAuthorCounter RelatedAuthorCounter) { - return new RelatedAuthorCounter(counter + RelatedAuthorCounter.counter, RelatedAuthorCounter.isRelated); - } - - public int getCounter() { - return counter; - } -} +package com.baeldung.spliteratorAPI; + +public class RelatedAuthorCounter { + private final int counter; + private final boolean isRelated; + + public RelatedAuthorCounter(int counter, boolean isRelated) { + this.counter = counter; + this.isRelated = isRelated; + } + + public RelatedAuthorCounter accumulate(Author author) { + if (author.getRelatedArticleId() == 0) { + return isRelated ? this : new RelatedAuthorCounter(counter, true); + } else { + return isRelated ? new RelatedAuthorCounter(counter + 1, false) : this; + } + } + + public RelatedAuthorCounter combine(RelatedAuthorCounter RelatedAuthorCounter) { + return new RelatedAuthorCounter(counter + RelatedAuthorCounter.counter, RelatedAuthorCounter.isRelated); + } + + public int getCounter() { + return counter; + } +} diff --git a/core-java-8/src/main/java/com/baeldung/spliteratorAPI/RelatedAuthorSpliterator.java b/core-java-modules/core-java-8/src/main/java/com/baeldung/spliteratorAPI/RelatedAuthorSpliterator.java similarity index 96% rename from core-java-8/src/main/java/com/baeldung/spliteratorAPI/RelatedAuthorSpliterator.java rename to core-java-modules/core-java-8/src/main/java/com/baeldung/spliteratorAPI/RelatedAuthorSpliterator.java index 0a7190964e..094638da37 100644 --- a/core-java-8/src/main/java/com/baeldung/spliteratorAPI/RelatedAuthorSpliterator.java +++ b/core-java-modules/core-java-8/src/main/java/com/baeldung/spliteratorAPI/RelatedAuthorSpliterator.java @@ -1,49 +1,49 @@ -package com.baeldung.spliteratorAPI; - -import java.util.List; -import java.util.Spliterator; -import java.util.concurrent.atomic.AtomicInteger; -import java.util.function.Consumer; - -public class RelatedAuthorSpliterator implements Spliterator { - private final List list; - AtomicInteger current = new AtomicInteger(); - - public RelatedAuthorSpliterator(List list) { - this.list = list; - } - - @Override - public boolean tryAdvance(Consumer action) { - - action.accept(list.get(current.getAndIncrement())); - return current.get() < list.size(); - } - - @Override - public Spliterator trySplit() { - int currentSize = list.size() - current.get(); - if (currentSize < 10) { - return null; - } - for (int splitPos = currentSize / 2 + current.intValue(); splitPos < list.size(); splitPos++) { - if (list.get(splitPos).getRelatedArticleId() == 0) { - Spliterator spliterator = new RelatedAuthorSpliterator(list.subList(current.get(), splitPos)); - current.set(splitPos); - return spliterator; - } - } - return null; - } - - @Override - public long estimateSize() { - return list.size() - current.get(); - } - - @Override - public int characteristics() { - return CONCURRENT; - } - -} +package com.baeldung.spliteratorAPI; + +import java.util.List; +import java.util.Spliterator; +import java.util.concurrent.atomic.AtomicInteger; +import java.util.function.Consumer; + +public class RelatedAuthorSpliterator implements Spliterator { + private final List list; + AtomicInteger current = new AtomicInteger(); + + public RelatedAuthorSpliterator(List list) { + this.list = list; + } + + @Override + public boolean tryAdvance(Consumer action) { + + action.accept(list.get(current.getAndIncrement())); + return current.get() < list.size(); + } + + @Override + public Spliterator trySplit() { + int currentSize = list.size() - current.get(); + if (currentSize < 10) { + return null; + } + for (int splitPos = currentSize / 2 + current.intValue(); splitPos < list.size(); splitPos++) { + if (list.get(splitPos).getRelatedArticleId() == 0) { + Spliterator spliterator = new RelatedAuthorSpliterator(list.subList(current.get(), splitPos)); + current.set(splitPos); + return spliterator; + } + } + return null; + } + + @Override + public long estimateSize() { + return list.size() - current.get(); + } + + @Override + public int characteristics() { + return CONCURRENT; + } + +} diff --git a/core-java-8/src/main/java/com/baeldung/spliteratorAPI/Task.java b/core-java-modules/core-java-8/src/main/java/com/baeldung/spliteratorAPI/Task.java similarity index 96% rename from core-java-8/src/main/java/com/baeldung/spliteratorAPI/Task.java rename to core-java-modules/core-java-8/src/main/java/com/baeldung/spliteratorAPI/Task.java index 70435d1c75..06a124cc98 100644 --- a/core-java-8/src/main/java/com/baeldung/spliteratorAPI/Task.java +++ b/core-java-modules/core-java-8/src/main/java/com/baeldung/spliteratorAPI/Task.java @@ -1,27 +1,27 @@ -package com.baeldung.spliteratorAPI; - -import java.util.Spliterator; -import java.util.concurrent.Callable; - -public class Task implements Callable { - private Spliterator
spliterator; - private final static String SUFFIX = "- published by Baeldung"; - - public Task(Spliterator
spliterator) { - this.spliterator = spliterator; - } - - @Override - public String call() { - int current = 0; - while (spliterator.tryAdvance(article -> { - article.setName(article.getName() - .concat(SUFFIX)); - })) { - current++; - } - ; - return Thread.currentThread() - .getName() + ":" + current; - } -} +package com.baeldung.spliteratorAPI; + +import java.util.Spliterator; +import java.util.concurrent.Callable; + +public class Task implements Callable { + private Spliterator
spliterator; + private final static String SUFFIX = "- published by Baeldung"; + + public Task(Spliterator
spliterator) { + this.spliterator = spliterator; + } + + @Override + public String call() { + int current = 0; + while (spliterator.tryAdvance(article -> { + article.setName(article.getName() + .concat(SUFFIX)); + })) { + current++; + } + ; + return Thread.currentThread() + .getName() + ":" + current; + } +} diff --git a/core-java-8/src/main/java/com/baeldung/strategy/ChristmasDiscounter.java b/core-java-modules/core-java-8/src/main/java/com/baeldung/strategy/ChristmasDiscounter.java similarity index 100% rename from core-java-8/src/main/java/com/baeldung/strategy/ChristmasDiscounter.java rename to core-java-modules/core-java-8/src/main/java/com/baeldung/strategy/ChristmasDiscounter.java diff --git a/core-java-8/src/main/java/com/baeldung/strategy/Discounter.java b/core-java-modules/core-java-8/src/main/java/com/baeldung/strategy/Discounter.java similarity index 100% rename from core-java-8/src/main/java/com/baeldung/strategy/Discounter.java rename to core-java-modules/core-java-8/src/main/java/com/baeldung/strategy/Discounter.java diff --git a/core-java-8/src/main/java/com/baeldung/strategy/EasterDiscounter.java b/core-java-modules/core-java-8/src/main/java/com/baeldung/strategy/EasterDiscounter.java similarity index 100% rename from core-java-8/src/main/java/com/baeldung/strategy/EasterDiscounter.java rename to core-java-modules/core-java-8/src/main/java/com/baeldung/strategy/EasterDiscounter.java diff --git a/core-java-8/src/main/java/com/baeldung/streamreduce/application/Application.java b/core-java-modules/core-java-8/src/main/java/com/baeldung/streamreduce/application/Application.java similarity index 97% rename from core-java-8/src/main/java/com/baeldung/streamreduce/application/Application.java rename to core-java-modules/core-java-8/src/main/java/com/baeldung/streamreduce/application/Application.java index 0b1dd952dc..00fc45ccae 100644 --- a/core-java-8/src/main/java/com/baeldung/streamreduce/application/Application.java +++ b/core-java-modules/core-java-8/src/main/java/com/baeldung/streamreduce/application/Application.java @@ -1,62 +1,62 @@ -package com.baeldung.streamreduce.application; - -import com.baeldung.streamreduce.entities.User; -import com.baeldung.streamreduce.utilities.NumberUtils; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -public class Application { - - public static void main(String[] args) { - List numbers = Arrays.asList(1, 2, 3, 4, 5, 6); - int result1 = numbers.stream().reduce(0, (a, b) -> a + b); - System.out.println(result1); - - int result2 = numbers.stream().reduce(0, Integer::sum); - System.out.println(result2); - - List letters = Arrays.asList("a", "b", "c", "d", "e"); - String result3 = letters.stream().reduce("", (a, b) -> a + b); - System.out.println(result3); - - String result4 = letters.stream().reduce("", String::concat); - System.out.println(result4); - - String result5 = letters.stream().reduce("", (a, b) -> a.toUpperCase() + b.toUpperCase()); - System.out.println(result5); - - List users = Arrays.asList(new User("John", 30), new User("Julie", 35)); - int result6 = users.stream().reduce(0, (partialAgeResult, user) -> partialAgeResult + user.getAge(), Integer::sum); - System.out.println(result6); - - String result7 = letters.parallelStream().reduce("", String::concat); - System.out.println(result7); - - int result8 = users.parallelStream().reduce(0, (partialAgeResult, user) -> partialAgeResult + user.getAge(), Integer::sum); - System.out.println(result8); - - List userList = new ArrayList<>(); - for (int i = 0; i <= 1000000; i++) { - userList.add(new User("John" + i, i)); - } - - long t1 = System.currentTimeMillis(); - int result9 = userList.stream().reduce(0, (partialAgeResult, user) -> partialAgeResult + user.getAge(), Integer::sum); - long t2 = System.currentTimeMillis(); - System.out.println(result9); - System.out.println("Sequential stream time: " + (t2 - t1) + "ms"); - - long t3 = System.currentTimeMillis(); - int result10 = userList.parallelStream().reduce(0, (partialAgeResult, user) -> partialAgeResult + user.getAge(), Integer::sum); - long t4 = System.currentTimeMillis(); - System.out.println(result10); - System.out.println("Parallel stream time: " + (t4 - t3) + "ms"); - - int result11 = NumberUtils.divideListElements(numbers, 1); - System.out.println(result11); - - int result12 = NumberUtils.divideListElementsWithExtractedTryCatchBlock(numbers, 0); - System.out.println(result12); - } -} +package com.baeldung.streamreduce.application; + +import com.baeldung.streamreduce.entities.User; +import com.baeldung.streamreduce.utilities.NumberUtils; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +public class Application { + + public static void main(String[] args) { + List numbers = Arrays.asList(1, 2, 3, 4, 5, 6); + int result1 = numbers.stream().reduce(0, (a, b) -> a + b); + System.out.println(result1); + + int result2 = numbers.stream().reduce(0, Integer::sum); + System.out.println(result2); + + List letters = Arrays.asList("a", "b", "c", "d", "e"); + String result3 = letters.stream().reduce("", (a, b) -> a + b); + System.out.println(result3); + + String result4 = letters.stream().reduce("", String::concat); + System.out.println(result4); + + String result5 = letters.stream().reduce("", (a, b) -> a.toUpperCase() + b.toUpperCase()); + System.out.println(result5); + + List users = Arrays.asList(new User("John", 30), new User("Julie", 35)); + int result6 = users.stream().reduce(0, (partialAgeResult, user) -> partialAgeResult + user.getAge(), Integer::sum); + System.out.println(result6); + + String result7 = letters.parallelStream().reduce("", String::concat); + System.out.println(result7); + + int result8 = users.parallelStream().reduce(0, (partialAgeResult, user) -> partialAgeResult + user.getAge(), Integer::sum); + System.out.println(result8); + + List userList = new ArrayList<>(); + for (int i = 0; i <= 1000000; i++) { + userList.add(new User("John" + i, i)); + } + + long t1 = System.currentTimeMillis(); + int result9 = userList.stream().reduce(0, (partialAgeResult, user) -> partialAgeResult + user.getAge(), Integer::sum); + long t2 = System.currentTimeMillis(); + System.out.println(result9); + System.out.println("Sequential stream time: " + (t2 - t1) + "ms"); + + long t3 = System.currentTimeMillis(); + int result10 = userList.parallelStream().reduce(0, (partialAgeResult, user) -> partialAgeResult + user.getAge(), Integer::sum); + long t4 = System.currentTimeMillis(); + System.out.println(result10); + System.out.println("Parallel stream time: " + (t4 - t3) + "ms"); + + int result11 = NumberUtils.divideListElements(numbers, 1); + System.out.println(result11); + + int result12 = NumberUtils.divideListElementsWithExtractedTryCatchBlock(numbers, 0); + System.out.println(result12); + } +} diff --git a/core-java-8/src/main/java/com/baeldung/streamreduce/entities/User.java b/core-java-modules/core-java-8/src/main/java/com/baeldung/streamreduce/entities/User.java similarity index 94% rename from core-java-8/src/main/java/com/baeldung/streamreduce/entities/User.java rename to core-java-modules/core-java-8/src/main/java/com/baeldung/streamreduce/entities/User.java index bc13a8cde6..39a42beab7 100644 --- a/core-java-8/src/main/java/com/baeldung/streamreduce/entities/User.java +++ b/core-java-modules/core-java-8/src/main/java/com/baeldung/streamreduce/entities/User.java @@ -1,25 +1,25 @@ -package com.baeldung.streamreduce.entities; - -public class User { - - private final String name; - private final int age; - - public User(String name, int age) { - this.name = name; - this.age = age; - } - - public String getName() { - return name; - } - - public int getAge() { - return age; - } - - @Override - public String toString() { - return "User{" + "name=" + name + ", age=" + age + '}'; - } -} +package com.baeldung.streamreduce.entities; + +public class User { + + private final String name; + private final int age; + + public User(String name, int age) { + this.name = name; + this.age = age; + } + + public String getName() { + return name; + } + + public int getAge() { + return age; + } + + @Override + public String toString() { + return "User{" + "name=" + name + ", age=" + age + '}'; + } +} diff --git a/core-java-8/src/main/java/com/baeldung/streamreduce/utilities/NumberUtils.java b/core-java-modules/core-java-8/src/main/java/com/baeldung/streamreduce/utilities/NumberUtils.java similarity index 97% rename from core-java-8/src/main/java/com/baeldung/streamreduce/utilities/NumberUtils.java rename to core-java-modules/core-java-8/src/main/java/com/baeldung/streamreduce/utilities/NumberUtils.java index 7a6a85e6c4..a2325cc701 100644 --- a/core-java-8/src/main/java/com/baeldung/streamreduce/utilities/NumberUtils.java +++ b/core-java-modules/core-java-8/src/main/java/com/baeldung/streamreduce/utilities/NumberUtils.java @@ -1,52 +1,52 @@ -package com.baeldung.streamreduce.utilities; - -import java.util.List; -import java.util.function.BiFunction; -import java.util.logging.Level; -import java.util.logging.Logger; - -public abstract class NumberUtils { - - private static final Logger LOGGER = Logger.getLogger(NumberUtils.class.getName()); - - public static int divideListElements(List values, Integer divider) { - return values.stream() - .reduce(0, (a, b) -> { - try { - return a / divider + b / divider; - } catch (ArithmeticException e) { - LOGGER.log(Level.INFO, "Arithmetic Exception: Division by Zero"); - } - return 0; - }); - } - - public static int divideListElementsWithExtractedTryCatchBlock(List values, int divider) { - return values.stream().reduce(0, (a, b) -> divide(a, divider) + divide(b, divider)); - } - - public static int divideListElementsWithApplyFunctionMethod(List values, int divider) { - BiFunction division = (a, b) -> a / b; - return values.stream().reduce(0, (a, b) -> applyFunction(division, a, divider) + applyFunction(division, b, divider)); - } - - private static int divide(int value, int factor) { - int result = 0; - try { - result = value / factor; - } catch (ArithmeticException e) { - LOGGER.log(Level.INFO, "Arithmetic Exception: Division by Zero"); - } - return result; - } - - private static int applyFunction(BiFunction function, int a, int b) { - try { - return function.apply(a, b); - } - catch(Exception e) { - LOGGER.log(Level.INFO, "Exception occurred!"); - } - return 0; - } -} +package com.baeldung.streamreduce.utilities; + +import java.util.List; +import java.util.function.BiFunction; +import java.util.logging.Level; +import java.util.logging.Logger; + +public abstract class NumberUtils { + + private static final Logger LOGGER = Logger.getLogger(NumberUtils.class.getName()); + + public static int divideListElements(List values, Integer divider) { + return values.stream() + .reduce(0, (a, b) -> { + try { + return a / divider + b / divider; + } catch (ArithmeticException e) { + LOGGER.log(Level.INFO, "Arithmetic Exception: Division by Zero"); + } + return 0; + }); + } + + public static int divideListElementsWithExtractedTryCatchBlock(List values, int divider) { + return values.stream().reduce(0, (a, b) -> divide(a, divider) + divide(b, divider)); + } + + public static int divideListElementsWithApplyFunctionMethod(List values, int divider) { + BiFunction division = (a, b) -> a / b; + return values.stream().reduce(0, (a, b) -> applyFunction(division, a, divider) + applyFunction(division, b, divider)); + } + + private static int divide(int value, int factor) { + int result = 0; + try { + result = value / factor; + } catch (ArithmeticException e) { + LOGGER.log(Level.INFO, "Arithmetic Exception: Division by Zero"); + } + return result; + } + + private static int applyFunction(BiFunction function, int a, int b) { + try { + return function.apply(a, b); + } + catch(Exception e) { + LOGGER.log(Level.INFO, "Exception occurred!"); + } + return 0; + } +} diff --git a/core-java-8/src/main/resources/logback.xml b/core-java-modules/core-java-8/src/main/resources/logback.xml similarity index 100% rename from core-java-8/src/main/resources/logback.xml rename to core-java-modules/core-java-8/src/main/resources/logback.xml diff --git a/core-java-8/src/test/java/com/baeldung/collectors/Java8CollectorsUnitTest.java b/core-java-modules/core-java-8/src/test/java/com/baeldung/collectors/Java8CollectorsUnitTest.java similarity index 100% rename from core-java-8/src/test/java/com/baeldung/collectors/Java8CollectorsUnitTest.java rename to core-java-modules/core-java-8/src/test/java/com/baeldung/collectors/Java8CollectorsUnitTest.java diff --git a/core-java-8/src/test/java/com/baeldung/counter/CounterStatistics.java b/core-java-modules/core-java-8/src/test/java/com/baeldung/counter/CounterStatistics.java similarity index 97% rename from core-java-8/src/test/java/com/baeldung/counter/CounterStatistics.java rename to core-java-modules/core-java-8/src/test/java/com/baeldung/counter/CounterStatistics.java index 015ca3f942..e5b03bf355 100644 --- a/core-java-8/src/test/java/com/baeldung/counter/CounterStatistics.java +++ b/core-java-modules/core-java-8/src/test/java/com/baeldung/counter/CounterStatistics.java @@ -1,61 +1,61 @@ -package com.baeldung.counter; - -import java.util.HashMap; -import java.util.Map; -import java.util.Random; - -import org.openjdk.jmh.annotations.Benchmark; -import org.openjdk.jmh.annotations.BenchmarkMode; -import org.openjdk.jmh.annotations.Fork; -import org.openjdk.jmh.annotations.Mode; - -import com.baeldung.counter.CounterUtil.MutableInteger; - -@Fork(value = 1, warmups = 3) -@BenchmarkMode(Mode.All) -public class CounterStatistics { - - private static final Map counterMap = new HashMap<>(); - private static final Map counterWithMutableIntMap = new HashMap<>(); - private static final Map counterWithIntArrayMap = new HashMap<>(); - private static final Map counterWithLongWrapperMap = new HashMap<>(); - private static final Map counterWithLongWrapperStreamMap = new HashMap<>(); - - static { - CounterUtil.COUNTRY_NAMES = new String[10000]; - final String prefix = "NewString"; - Random random = new Random(); - for (int i=0; i<10000; i++) { - CounterUtil.COUNTRY_NAMES[i] = new String(prefix + random.nextInt(1000)); - } - } - - @Benchmark - public void wrapperAsCounter() { - CounterUtil.counterWithWrapperObject(counterMap); - } - - @Benchmark - public void lambdaExpressionWithWrapper() { - CounterUtil.counterWithLambdaAndWrapper(counterWithLongWrapperMap); - } - - @Benchmark - public void parallelStreamWithWrapper() { - CounterUtil.counterWithParallelStreamAndWrapper(counterWithLongWrapperStreamMap); - } - - @Benchmark - public void mutableIntegerAsCounter() { - CounterUtil.counterWithMutableInteger(counterWithMutableIntMap); - } - - @Benchmark - public void primitiveArrayAsCounter() { - CounterUtil.counterWithPrimitiveArray(counterWithIntArrayMap); - } - - public static void main(String[] args) throws Exception { - org.openjdk.jmh.Main.main(args); - } -} +package com.baeldung.counter; + +import java.util.HashMap; +import java.util.Map; +import java.util.Random; + +import org.openjdk.jmh.annotations.Benchmark; +import org.openjdk.jmh.annotations.BenchmarkMode; +import org.openjdk.jmh.annotations.Fork; +import org.openjdk.jmh.annotations.Mode; + +import com.baeldung.counter.CounterUtil.MutableInteger; + +@Fork(value = 1, warmups = 3) +@BenchmarkMode(Mode.All) +public class CounterStatistics { + + private static final Map counterMap = new HashMap<>(); + private static final Map counterWithMutableIntMap = new HashMap<>(); + private static final Map counterWithIntArrayMap = new HashMap<>(); + private static final Map counterWithLongWrapperMap = new HashMap<>(); + private static final Map counterWithLongWrapperStreamMap = new HashMap<>(); + + static { + CounterUtil.COUNTRY_NAMES = new String[10000]; + final String prefix = "NewString"; + Random random = new Random(); + for (int i=0; i<10000; i++) { + CounterUtil.COUNTRY_NAMES[i] = new String(prefix + random.nextInt(1000)); + } + } + + @Benchmark + public void wrapperAsCounter() { + CounterUtil.counterWithWrapperObject(counterMap); + } + + @Benchmark + public void lambdaExpressionWithWrapper() { + CounterUtil.counterWithLambdaAndWrapper(counterWithLongWrapperMap); + } + + @Benchmark + public void parallelStreamWithWrapper() { + CounterUtil.counterWithParallelStreamAndWrapper(counterWithLongWrapperStreamMap); + } + + @Benchmark + public void mutableIntegerAsCounter() { + CounterUtil.counterWithMutableInteger(counterWithMutableIntMap); + } + + @Benchmark + public void primitiveArrayAsCounter() { + CounterUtil.counterWithPrimitiveArray(counterWithIntArrayMap); + } + + public static void main(String[] args) throws Exception { + org.openjdk.jmh.Main.main(args); + } +} diff --git a/core-java-8/src/test/java/com/baeldung/counter/CounterUnitTest.java b/core-java-modules/core-java-8/src/test/java/com/baeldung/counter/CounterUnitTest.java similarity index 96% rename from core-java-8/src/test/java/com/baeldung/counter/CounterUnitTest.java rename to core-java-modules/core-java-8/src/test/java/com/baeldung/counter/CounterUnitTest.java index ef57fc2c6e..4f914bd289 100644 --- a/core-java-8/src/test/java/com/baeldung/counter/CounterUnitTest.java +++ b/core-java-modules/core-java-8/src/test/java/com/baeldung/counter/CounterUnitTest.java @@ -1,53 +1,53 @@ -package com.baeldung.counter; - -import java.util.HashMap; -import java.util.Map; - -import static org.junit.Assert.*; - -import org.junit.Test; - -import com.baeldung.counter.CounterUtil.MutableInteger; - -public class CounterUnitTest { - - @Test - public void whenMapWithWrapperAsCounter_runsSuccessfully() { - Map counterMap = new HashMap<>(); - CounterUtil.counterWithWrapperObject(counterMap); - - assertEquals(3, counterMap.get("China") - .intValue()); - assertEquals(2, counterMap.get("India") - .intValue()); - } - - @Test - public void whenMapWithLambdaAndWrapperCounter_runsSuccessfully() { - Map counterMap = new HashMap<>(); - CounterUtil.counterWithLambdaAndWrapper(counterMap); - - assertEquals(3l, counterMap.get("China") - .longValue()); - assertEquals(2l, counterMap.get("India") - .longValue()); - } - - @Test - public void whenMapWithMutableIntegerCounter_runsSuccessfully() { - Map counterMap = new HashMap<>(); - CounterUtil.counterWithMutableInteger(counterMap); - assertEquals(3, counterMap.get("China") - .getCount()); - assertEquals(2, counterMap.get("India") - .getCount()); - } - - @Test - public void whenMapWithPrimitiveArray_runsSuccessfully() { - Map counterMap = new HashMap<>(); - CounterUtil.counterWithPrimitiveArray(counterMap); - assertEquals(3, counterMap.get("China")[0]); - assertEquals(2, counterMap.get("India")[0]); - } -} +package com.baeldung.counter; + +import java.util.HashMap; +import java.util.Map; + +import static org.junit.Assert.*; + +import org.junit.Test; + +import com.baeldung.counter.CounterUtil.MutableInteger; + +public class CounterUnitTest { + + @Test + public void whenMapWithWrapperAsCounter_runsSuccessfully() { + Map counterMap = new HashMap<>(); + CounterUtil.counterWithWrapperObject(counterMap); + + assertEquals(3, counterMap.get("China") + .intValue()); + assertEquals(2, counterMap.get("India") + .intValue()); + } + + @Test + public void whenMapWithLambdaAndWrapperCounter_runsSuccessfully() { + Map counterMap = new HashMap<>(); + CounterUtil.counterWithLambdaAndWrapper(counterMap); + + assertEquals(3l, counterMap.get("China") + .longValue()); + assertEquals(2l, counterMap.get("India") + .longValue()); + } + + @Test + public void whenMapWithMutableIntegerCounter_runsSuccessfully() { + Map counterMap = new HashMap<>(); + CounterUtil.counterWithMutableInteger(counterMap); + assertEquals(3, counterMap.get("China") + .getCount()); + assertEquals(2, counterMap.get("India") + .getCount()); + } + + @Test + public void whenMapWithPrimitiveArray_runsSuccessfully() { + Map counterMap = new HashMap<>(); + CounterUtil.counterWithPrimitiveArray(counterMap); + assertEquals(3, counterMap.get("China")[0]); + assertEquals(2, counterMap.get("India")[0]); + } +} diff --git a/core-java-8/src/test/java/com/baeldung/counter/CounterUtil.java b/core-java-modules/core-java-8/src/test/java/com/baeldung/counter/CounterUtil.java similarity index 97% rename from core-java-8/src/test/java/com/baeldung/counter/CounterUtil.java rename to core-java-modules/core-java-8/src/test/java/com/baeldung/counter/CounterUtil.java index c2bf47e213..7e15fa1356 100644 --- a/core-java-8/src/test/java/com/baeldung/counter/CounterUtil.java +++ b/core-java-modules/core-java-8/src/test/java/com/baeldung/counter/CounterUtil.java @@ -1,57 +1,57 @@ -package com.baeldung.counter; - -import java.util.Map; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -public class CounterUtil { - - public static String[] COUNTRY_NAMES = { "China", "Australia", "India", "USA", "USSR", "UK", "China", "France", "Poland", "Austria", "India", "USA", "Egypt", "China" }; - - public static void counterWithWrapperObject(Map counterMap) { - for (String country : COUNTRY_NAMES) { - counterMap.compute(country, (k, v) -> v == null ? 1 : v + 1); - } - } - - public static void counterWithLambdaAndWrapper(Map counterMap) { - Stream.of(COUNTRY_NAMES) - .collect(Collectors.groupingBy(k -> k, () -> counterMap, Collectors.counting())); - } - - public static void counterWithParallelStreamAndWrapper(Map counterMap) { - Stream.of(COUNTRY_NAMES) - .parallel() - .collect(Collectors.groupingBy(k -> k, () -> counterMap, Collectors.counting())); - } - - public static class MutableInteger { - int count; - - public MutableInteger(int count) { - this.count = count; - } - - public void increment() { - this.count++; - } - - public int getCount() { - return this.count; - } - } - - public static void counterWithMutableInteger(Map counterMap) { - for (String country : COUNTRY_NAMES) { - counterMap.compute(country, (k, v) -> v == null ? new MutableInteger(0) : v) - .increment(); - } - } - - public static void counterWithPrimitiveArray(Map counterMap) { - for (String country : COUNTRY_NAMES) { - counterMap.compute(country, (k, v) -> v == null ? new int[] { 0 } : v)[0]++; - } - } - +package com.baeldung.counter; + +import java.util.Map; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +public class CounterUtil { + + public static String[] COUNTRY_NAMES = { "China", "Australia", "India", "USA", "USSR", "UK", "China", "France", "Poland", "Austria", "India", "USA", "Egypt", "China" }; + + public static void counterWithWrapperObject(Map counterMap) { + for (String country : COUNTRY_NAMES) { + counterMap.compute(country, (k, v) -> v == null ? 1 : v + 1); + } + } + + public static void counterWithLambdaAndWrapper(Map counterMap) { + Stream.of(COUNTRY_NAMES) + .collect(Collectors.groupingBy(k -> k, () -> counterMap, Collectors.counting())); + } + + public static void counterWithParallelStreamAndWrapper(Map counterMap) { + Stream.of(COUNTRY_NAMES) + .parallel() + .collect(Collectors.groupingBy(k -> k, () -> counterMap, Collectors.counting())); + } + + public static class MutableInteger { + int count; + + public MutableInteger(int count) { + this.count = count; + } + + public void increment() { + this.count++; + } + + public int getCount() { + return this.count; + } + } + + public static void counterWithMutableInteger(Map counterMap) { + for (String country : COUNTRY_NAMES) { + counterMap.compute(country, (k, v) -> v == null ? new MutableInteger(0) : v) + .increment(); + } + } + + public static void counterWithPrimitiveArray(Map counterMap) { + for (String country : COUNTRY_NAMES) { + counterMap.compute(country, (k, v) -> v == null ? new int[] { 0 } : v)[0]++; + } + } + } \ No newline at end of file diff --git a/core-java-8/src/test/java/com/baeldung/customannotations/JsonSerializerUnitTest.java b/core-java-modules/core-java-8/src/test/java/com/baeldung/customannotations/JsonSerializerUnitTest.java similarity index 97% rename from core-java-8/src/test/java/com/baeldung/customannotations/JsonSerializerUnitTest.java rename to core-java-modules/core-java-8/src/test/java/com/baeldung/customannotations/JsonSerializerUnitTest.java index f24b37aef7..fd8f8ba8b3 100644 --- a/core-java-8/src/test/java/com/baeldung/customannotations/JsonSerializerUnitTest.java +++ b/core-java-modules/core-java-8/src/test/java/com/baeldung/customannotations/JsonSerializerUnitTest.java @@ -1,26 +1,26 @@ -package com.baeldung.customannotations; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertThrows; - -import org.junit.jupiter.api.Test; - -public class JsonSerializerUnitTest { - - @Test - public void givenObjectNotSerializedThenExceptionThrown() throws JsonSerializationException { - Object object = new Object(); - ObjectToJsonConverter serializer = new ObjectToJsonConverter(); - assertThrows(JsonSerializationException.class, () -> { - serializer.convertToJson(object); - }); - } - - @Test - public void givenObjectSerializedThenTrueReturned() throws JsonSerializationException { - Person person = new Person("soufiane", "cheouati", "34"); - ObjectToJsonConverter serializer = new ObjectToJsonConverter(); - String jsonString = serializer.convertToJson(person); - assertEquals("{\"personAge\":\"34\",\"firstName\":\"Soufiane\",\"lastName\":\"Cheouati\"}", jsonString); - } -} +package com.baeldung.customannotations; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; + +import org.junit.jupiter.api.Test; + +public class JsonSerializerUnitTest { + + @Test + public void givenObjectNotSerializedThenExceptionThrown() throws JsonSerializationException { + Object object = new Object(); + ObjectToJsonConverter serializer = new ObjectToJsonConverter(); + assertThrows(JsonSerializationException.class, () -> { + serializer.convertToJson(object); + }); + } + + @Test + public void givenObjectSerializedThenTrueReturned() throws JsonSerializationException { + Person person = new Person("soufiane", "cheouati", "34"); + ObjectToJsonConverter serializer = new ObjectToJsonConverter(); + String jsonString = serializer.convertToJson(person); + assertEquals("{\"personAge\":\"34\",\"firstName\":\"Soufiane\",\"lastName\":\"Cheouati\"}", jsonString); + } +} diff --git a/core-java-8/src/test/java/com/baeldung/defaultistaticinterfacemethods/test/StaticDefaulInterfaceMethodUnitTest.java b/core-java-modules/core-java-8/src/test/java/com/baeldung/defaultistaticinterfacemethods/test/StaticDefaulInterfaceMethodUnitTest.java similarity index 100% rename from core-java-8/src/test/java/com/baeldung/defaultistaticinterfacemethods/test/StaticDefaulInterfaceMethodUnitTest.java rename to core-java-modules/core-java-8/src/test/java/com/baeldung/defaultistaticinterfacemethods/test/StaticDefaulInterfaceMethodUnitTest.java diff --git a/core-java-8/src/test/java/com/baeldung/doublecolon/ComputerUtilsUnitTest.java b/core-java-modules/core-java-8/src/test/java/com/baeldung/doublecolon/ComputerUtilsUnitTest.java similarity index 100% rename from core-java-8/src/test/java/com/baeldung/doublecolon/ComputerUtilsUnitTest.java rename to core-java-modules/core-java-8/src/test/java/com/baeldung/doublecolon/ComputerUtilsUnitTest.java diff --git a/core-java-8/src/test/java/com/baeldung/functionalinterface/FunctionalInterfaceUnitTest.java b/core-java-modules/core-java-8/src/test/java/com/baeldung/functionalinterface/FunctionalInterfaceUnitTest.java similarity index 100% rename from core-java-8/src/test/java/com/baeldung/functionalinterface/FunctionalInterfaceUnitTest.java rename to core-java-modules/core-java-8/src/test/java/com/baeldung/functionalinterface/FunctionalInterfaceUnitTest.java diff --git a/core-java-8/src/test/java/com/baeldung/functionalinterface/ShortToByteFunction.java b/core-java-modules/core-java-8/src/test/java/com/baeldung/functionalinterface/ShortToByteFunction.java similarity index 100% rename from core-java-8/src/test/java/com/baeldung/functionalinterface/ShortToByteFunction.java rename to core-java-modules/core-java-8/src/test/java/com/baeldung/functionalinterface/ShortToByteFunction.java diff --git a/core-java-8/src/test/java/com/baeldung/internationalization/DateFormatUnitTest.java b/core-java-modules/core-java-8/src/test/java/com/baeldung/internationalization/DateFormatUnitTest.java similarity index 100% rename from core-java-8/src/test/java/com/baeldung/internationalization/DateFormatUnitTest.java rename to core-java-modules/core-java-8/src/test/java/com/baeldung/internationalization/DateFormatUnitTest.java diff --git a/core-java-8/src/test/java/com/baeldung/internationalization/NumbersCurrenciesFormattingUnitTest.java b/core-java-modules/core-java-8/src/test/java/com/baeldung/internationalization/NumbersCurrenciesFormattingUnitTest.java similarity index 100% rename from core-java-8/src/test/java/com/baeldung/internationalization/NumbersCurrenciesFormattingUnitTest.java rename to core-java-modules/core-java-8/src/test/java/com/baeldung/internationalization/NumbersCurrenciesFormattingUnitTest.java diff --git a/core-java-8/src/test/java/com/baeldung/java8/Java8DefaultStaticIntefaceMethodsUnitTest.java b/core-java-modules/core-java-8/src/test/java/com/baeldung/java8/Java8DefaultStaticIntefaceMethodsUnitTest.java similarity index 100% rename from core-java-8/src/test/java/com/baeldung/java8/Java8DefaultStaticIntefaceMethodsUnitTest.java rename to core-java-modules/core-java-8/src/test/java/com/baeldung/java8/Java8DefaultStaticIntefaceMethodsUnitTest.java diff --git a/core-java-8/src/test/java/com/baeldung/java8/Java8ForEachUnitTest.java b/core-java-modules/core-java-8/src/test/java/com/baeldung/java8/Java8ForEachUnitTest.java similarity index 100% rename from core-java-8/src/test/java/com/baeldung/java8/Java8ForEachUnitTest.java rename to core-java-modules/core-java-8/src/test/java/com/baeldung/java8/Java8ForEachUnitTest.java diff --git a/core-java-8/src/test/java/com/baeldung/java8/Java8GroupingByCollectorUnitTest.java b/core-java-modules/core-java-8/src/test/java/com/baeldung/java8/Java8GroupingByCollectorUnitTest.java similarity index 100% rename from core-java-8/src/test/java/com/baeldung/java8/Java8GroupingByCollectorUnitTest.java rename to core-java-modules/core-java-8/src/test/java/com/baeldung/java8/Java8GroupingByCollectorUnitTest.java diff --git a/core-java-8/src/test/java/com/baeldung/java8/Java8MethodReferenceUnitTest.java b/core-java-modules/core-java-8/src/test/java/com/baeldung/java8/Java8MethodReferenceUnitTest.java similarity index 100% rename from core-java-8/src/test/java/com/baeldung/java8/Java8MethodReferenceUnitTest.java rename to core-java-modules/core-java-8/src/test/java/com/baeldung/java8/Java8MethodReferenceUnitTest.java diff --git a/core-java-8/src/test/java/com/baeldung/java8/Java8OptionalUnitTest.java b/core-java-modules/core-java-8/src/test/java/com/baeldung/java8/Java8OptionalUnitTest.java similarity index 100% rename from core-java-8/src/test/java/com/baeldung/java8/Java8OptionalUnitTest.java rename to core-java-modules/core-java-8/src/test/java/com/baeldung/java8/Java8OptionalUnitTest.java diff --git a/core-java-8/src/test/java/com/baeldung/java8/Java8PredicateChainUnitTest.java b/core-java-modules/core-java-8/src/test/java/com/baeldung/java8/Java8PredicateChainUnitTest.java similarity index 100% rename from core-java-8/src/test/java/com/baeldung/java8/Java8PredicateChainUnitTest.java rename to core-java-modules/core-java-8/src/test/java/com/baeldung/java8/Java8PredicateChainUnitTest.java diff --git a/core-java-8/src/test/java/com/baeldung/java8/Java8SortUnitTest.java b/core-java-modules/core-java-8/src/test/java/com/baeldung/java8/Java8SortUnitTest.java similarity index 100% rename from core-java-8/src/test/java/com/baeldung/java8/Java8SortUnitTest.java rename to core-java-modules/core-java-8/src/test/java/com/baeldung/java8/Java8SortUnitTest.java diff --git a/core-java-8/src/test/java/com/baeldung/java8/JavaTryWithResourcesLongRunningUnitTest.java b/core-java-modules/core-java-8/src/test/java/com/baeldung/java8/JavaTryWithResourcesLongRunningUnitTest.java similarity index 100% rename from core-java-8/src/test/java/com/baeldung/java8/JavaTryWithResourcesLongRunningUnitTest.java rename to core-java-modules/core-java-8/src/test/java/com/baeldung/java8/JavaTryWithResourcesLongRunningUnitTest.java diff --git a/core-java-8/src/test/java/com/baeldung/java8/UnsignedArithmeticUnitTest.java b/core-java-modules/core-java-8/src/test/java/com/baeldung/java8/UnsignedArithmeticUnitTest.java similarity index 100% rename from core-java-8/src/test/java/com/baeldung/java8/UnsignedArithmeticUnitTest.java rename to core-java-modules/core-java-8/src/test/java/com/baeldung/java8/UnsignedArithmeticUnitTest.java diff --git a/core-java-8/src/test/java/com/baeldung/java8/comparator/Employee.java b/core-java-modules/core-java-8/src/test/java/com/baeldung/java8/comparator/Employee.java similarity index 100% rename from core-java-8/src/test/java/com/baeldung/java8/comparator/Employee.java rename to core-java-modules/core-java-8/src/test/java/com/baeldung/java8/comparator/Employee.java diff --git a/core-java-8/src/test/java/com/baeldung/java8/comparator/Java8ComparatorUnitTest.java b/core-java-modules/core-java-8/src/test/java/com/baeldung/java8/comparator/Java8ComparatorUnitTest.java similarity index 100% rename from core-java-8/src/test/java/com/baeldung/java8/comparator/Java8ComparatorUnitTest.java rename to core-java-modules/core-java-8/src/test/java/com/baeldung/java8/comparator/Java8ComparatorUnitTest.java diff --git a/core-java-8/src/test/java/com/baeldung/java8/entity/Human.java b/core-java-modules/core-java-8/src/test/java/com/baeldung/java8/entity/Human.java similarity index 100% rename from core-java-8/src/test/java/com/baeldung/java8/entity/Human.java rename to core-java-modules/core-java-8/src/test/java/com/baeldung/java8/entity/Human.java diff --git a/core-java-8/src/test/java/com/baeldung/java8/lambda/exceptions/LambdaExceptionWrappersUnitTest.java b/core-java-modules/core-java-8/src/test/java/com/baeldung/java8/lambda/exceptions/LambdaExceptionWrappersUnitTest.java similarity index 100% rename from core-java-8/src/test/java/com/baeldung/java8/lambda/exceptions/LambdaExceptionWrappersUnitTest.java rename to core-java-modules/core-java-8/src/test/java/com/baeldung/java8/lambda/exceptions/LambdaExceptionWrappersUnitTest.java diff --git a/core-java-8/src/test/java/com/baeldung/java8/lambda/methodreference/Bicycle.java b/core-java-modules/core-java-8/src/test/java/com/baeldung/java8/lambda/methodreference/Bicycle.java similarity index 100% rename from core-java-8/src/test/java/com/baeldung/java8/lambda/methodreference/Bicycle.java rename to core-java-modules/core-java-8/src/test/java/com/baeldung/java8/lambda/methodreference/Bicycle.java diff --git a/core-java-8/src/test/java/com/baeldung/java8/lambda/methodreference/BicycleComparator.java b/core-java-modules/core-java-8/src/test/java/com/baeldung/java8/lambda/methodreference/BicycleComparator.java similarity index 100% rename from core-java-8/src/test/java/com/baeldung/java8/lambda/methodreference/BicycleComparator.java rename to core-java-modules/core-java-8/src/test/java/com/baeldung/java8/lambda/methodreference/BicycleComparator.java diff --git a/core-java-8/src/test/java/com/baeldung/java8/lambda/methodreference/MethodReferenceUnitTest.java b/core-java-modules/core-java-8/src/test/java/com/baeldung/java8/lambda/methodreference/MethodReferenceUnitTest.java similarity index 100% rename from core-java-8/src/test/java/com/baeldung/java8/lambda/methodreference/MethodReferenceUnitTest.java rename to core-java-modules/core-java-8/src/test/java/com/baeldung/java8/lambda/methodreference/MethodReferenceUnitTest.java diff --git a/core-java-8/src/test/java/com/baeldung/java8/lambda/tips/Java8FunctionalInteracesLambdasUnitTest.java b/core-java-modules/core-java-8/src/test/java/com/baeldung/java8/lambda/tips/Java8FunctionalInteracesLambdasUnitTest.java similarity index 100% rename from core-java-8/src/test/java/com/baeldung/java8/lambda/tips/Java8FunctionalInteracesLambdasUnitTest.java rename to core-java-modules/core-java-8/src/test/java/com/baeldung/java8/lambda/tips/Java8FunctionalInteracesLambdasUnitTest.java diff --git a/core-java-8/src/test/java/com/baeldung/java8/optional/OptionalChainingUnitTest.java b/core-java-modules/core-java-8/src/test/java/com/baeldung/java8/optional/OptionalChainingUnitTest.java similarity index 100% rename from core-java-8/src/test/java/com/baeldung/java8/optional/OptionalChainingUnitTest.java rename to core-java-modules/core-java-8/src/test/java/com/baeldung/java8/optional/OptionalChainingUnitTest.java diff --git a/core-java-8/src/test/java/com/baeldung/java8/optional/OptionalUnitTest.java b/core-java-modules/core-java-8/src/test/java/com/baeldung/java8/optional/OptionalUnitTest.java similarity index 100% rename from core-java-8/src/test/java/com/baeldung/java8/optional/OptionalUnitTest.java rename to core-java-modules/core-java-8/src/test/java/com/baeldung/java8/optional/OptionalUnitTest.java diff --git a/core-java-8/src/test/java/com/baeldung/java8/optional/OrElseAndOrElseGetUnitTest.java b/core-java-modules/core-java-8/src/test/java/com/baeldung/java8/optional/OrElseAndOrElseGetUnitTest.java similarity index 100% rename from core-java-8/src/test/java/com/baeldung/java8/optional/OrElseAndOrElseGetUnitTest.java rename to core-java-modules/core-java-8/src/test/java/com/baeldung/java8/optional/OrElseAndOrElseGetUnitTest.java diff --git a/core-java-8/src/test/java/com/baeldung/math/MathNewMethodsUnitTest.java b/core-java-modules/core-java-8/src/test/java/com/baeldung/math/MathNewMethodsUnitTest.java similarity index 100% rename from core-java-8/src/test/java/com/baeldung/math/MathNewMethodsUnitTest.java rename to core-java-modules/core-java-8/src/test/java/com/baeldung/math/MathNewMethodsUnitTest.java diff --git a/core-java-8/src/test/java/com/baeldung/nullsafecollectionstreams/NullSafeCollectionStreamsUsingCommonsEmptyIfNullUnitTest.java b/core-java-modules/core-java-8/src/test/java/com/baeldung/nullsafecollectionstreams/NullSafeCollectionStreamsUsingCommonsEmptyIfNullUnitTest.java similarity index 100% rename from core-java-8/src/test/java/com/baeldung/nullsafecollectionstreams/NullSafeCollectionStreamsUsingCommonsEmptyIfNullUnitTest.java rename to core-java-modules/core-java-8/src/test/java/com/baeldung/nullsafecollectionstreams/NullSafeCollectionStreamsUsingCommonsEmptyIfNullUnitTest.java diff --git a/core-java-8/src/test/java/com/baeldung/nullsafecollectionstreams/NullSafeCollectionStreamsUsingJava8OptionalContainerUnitTest.java b/core-java-modules/core-java-8/src/test/java/com/baeldung/nullsafecollectionstreams/NullSafeCollectionStreamsUsingJava8OptionalContainerUnitTest.java similarity index 100% rename from core-java-8/src/test/java/com/baeldung/nullsafecollectionstreams/NullSafeCollectionStreamsUsingJava8OptionalContainerUnitTest.java rename to core-java-modules/core-java-8/src/test/java/com/baeldung/nullsafecollectionstreams/NullSafeCollectionStreamsUsingJava8OptionalContainerUnitTest.java diff --git a/core-java-8/src/test/java/com/baeldung/nullsafecollectionstreams/NullSafeCollectionStreamsUsingNullDereferenceCheckUnitTest.java b/core-java-modules/core-java-8/src/test/java/com/baeldung/nullsafecollectionstreams/NullSafeCollectionStreamsUsingNullDereferenceCheckUnitTest.java similarity index 100% rename from core-java-8/src/test/java/com/baeldung/nullsafecollectionstreams/NullSafeCollectionStreamsUsingNullDereferenceCheckUnitTest.java rename to core-java-modules/core-java-8/src/test/java/com/baeldung/nullsafecollectionstreams/NullSafeCollectionStreamsUsingNullDereferenceCheckUnitTest.java diff --git a/core-java-8/src/test/java/com/baeldung/optional/PersonRepositoryUnitTest.java b/core-java-modules/core-java-8/src/test/java/com/baeldung/optional/PersonRepositoryUnitTest.java similarity index 100% rename from core-java-8/src/test/java/com/baeldung/optional/PersonRepositoryUnitTest.java rename to core-java-modules/core-java-8/src/test/java/com/baeldung/optional/PersonRepositoryUnitTest.java diff --git a/core-java-8/src/test/java/com/baeldung/reduceIfelse/CalculatorUnitTest.java b/core-java-modules/core-java-8/src/test/java/com/baeldung/reduceIfelse/CalculatorUnitTest.java similarity index 100% rename from core-java-8/src/test/java/com/baeldung/reduceIfelse/CalculatorUnitTest.java rename to core-java-modules/core-java-8/src/test/java/com/baeldung/reduceIfelse/CalculatorUnitTest.java diff --git a/core-java-8/src/test/java/com/baeldung/reduceIfelse/RuleEngineUnitTest.java b/core-java-modules/core-java-8/src/test/java/com/baeldung/reduceIfelse/RuleEngineUnitTest.java similarity index 100% rename from core-java-8/src/test/java/com/baeldung/reduceIfelse/RuleEngineUnitTest.java rename to core-java-modules/core-java-8/src/test/java/com/baeldung/reduceIfelse/RuleEngineUnitTest.java diff --git a/core-java-8/src/test/java/com/baeldung/reflect/MethodParamNameUnitTest.java b/core-java-modules/core-java-8/src/test/java/com/baeldung/reflect/MethodParamNameUnitTest.java similarity index 97% rename from core-java-8/src/test/java/com/baeldung/reflect/MethodParamNameUnitTest.java rename to core-java-modules/core-java-8/src/test/java/com/baeldung/reflect/MethodParamNameUnitTest.java index b191c94826..dadd6d7543 100644 --- a/core-java-8/src/test/java/com/baeldung/reflect/MethodParamNameUnitTest.java +++ b/core-java-modules/core-java-8/src/test/java/com/baeldung/reflect/MethodParamNameUnitTest.java @@ -1,34 +1,34 @@ -package com.baeldung.reflect; - -import static org.assertj.core.api.Assertions.assertThat; - -import java.lang.reflect.Parameter; -import java.util.Arrays; -import java.util.List; -import java.util.Optional; - -import org.junit.Test; - -public class MethodParamNameUnitTest { - - @Test - public void whenGetConstructorParams_thenOk() - throws NoSuchMethodException, SecurityException { - List parameters - = Arrays.asList(Person.class.getConstructor(String.class).getParameters()); - Optional parameter - = parameters.stream().filter(Parameter::isNamePresent).findFirst(); - assertThat(parameter.get().getName()).isEqualTo("fullName"); - } - - @Test - public void whenGetMethodParams_thenOk() - throws NoSuchMethodException, SecurityException { - List parameters - = Arrays.asList( - Person.class.getMethod("setFullName", String.class).getParameters()); - Optional parameter - = parameters.stream().filter(Parameter::isNamePresent).findFirst(); - assertThat(parameter.get().getName()).isEqualTo("fullName"); - } -} +package com.baeldung.reflect; + +import static org.assertj.core.api.Assertions.assertThat; + +import java.lang.reflect.Parameter; +import java.util.Arrays; +import java.util.List; +import java.util.Optional; + +import org.junit.Test; + +public class MethodParamNameUnitTest { + + @Test + public void whenGetConstructorParams_thenOk() + throws NoSuchMethodException, SecurityException { + List parameters + = Arrays.asList(Person.class.getConstructor(String.class).getParameters()); + Optional parameter + = parameters.stream().filter(Parameter::isNamePresent).findFirst(); + assertThat(parameter.get().getName()).isEqualTo("fullName"); + } + + @Test + public void whenGetMethodParams_thenOk() + throws NoSuchMethodException, SecurityException { + List parameters + = Arrays.asList( + Person.class.getMethod("setFullName", String.class).getParameters()); + Optional parameter + = parameters.stream().filter(Parameter::isNamePresent).findFirst(); + assertThat(parameter.get().getName()).isEqualTo("fullName"); + } +} diff --git a/core-java-8/src/test/java/com/baeldung/spliteratorAPI/ExecutorUnitTest.java b/core-java-modules/core-java-8/src/test/java/com/baeldung/spliteratorAPI/ExecutorUnitTest.java similarity index 97% rename from core-java-8/src/test/java/com/baeldung/spliteratorAPI/ExecutorUnitTest.java rename to core-java-modules/core-java-8/src/test/java/com/baeldung/spliteratorAPI/ExecutorUnitTest.java index 81fad12eb0..6981898500 100644 --- a/core-java-8/src/test/java/com/baeldung/spliteratorAPI/ExecutorUnitTest.java +++ b/core-java-modules/core-java-8/src/test/java/com/baeldung/spliteratorAPI/ExecutorUnitTest.java @@ -1,44 +1,44 @@ -package com.baeldung.spliteratorAPI; - -import java.util.Arrays; -import java.util.Spliterator; -import java.util.stream.Stream; -import java.util.stream.StreamSupport; - -import static org.assertj.core.api.Assertions.*; -import org.junit.Before; -import org.junit.Test; - -public class ExecutorUnitTest { - Article article; - Stream stream; - Spliterator spliterator; - Spliterator
split1; - Spliterator
split2; - - @Before - public void init() { - article = new Article(Arrays.asList(new Author("Ahmad", 0), new Author("Eugen", 0), new Author("Alice", 1), - new Author("Alice", 1), new Author("Mike", 0), new Author("Alice", 1), new Author("Mike", 0), - new Author("Alice", 1), new Author("Mike", 0), new Author("Alice", 1), new Author("Mike", 0), - new Author("Mike", 0), new Author("Alice", 1), new Author("Mike", 0), new Author("Alice", 1), - new Author("Mike", 0), new Author("Alice", 1), new Author("Mike", 0), new Author("Alice", 1), - new Author("Mike", 0), new Author("Michał", 0), new Author("Loredana", 1)), 0); - stream = article.getListOfAuthors().stream(); - split1 = Executor.generateElements().spliterator(); - split2 = split1.trySplit(); - spliterator = new RelatedAuthorSpliterator(article.getListOfAuthors()); - } - - @Test - public void givenAstreamOfAuthors_whenProcessedInParallelWithCustomSpliterator_coubtProducessRightOutput() { - Stream stream2 = StreamSupport.stream(spliterator, true); - assertThat(Executor.countAutors(stream2.parallel())).isEqualTo(9); - } - - @Test - public void givenSpliterator_whenAppliedToAListOfArticle_thenSplittedInHalf() { - assertThat(new Task(split1).call()).containsSequence(Executor.generateElements().size() / 2 + ""); - assertThat(new Task(split2).call()).containsSequence(Executor.generateElements().size() / 2 + ""); - } -} +package com.baeldung.spliteratorAPI; + +import java.util.Arrays; +import java.util.Spliterator; +import java.util.stream.Stream; +import java.util.stream.StreamSupport; + +import static org.assertj.core.api.Assertions.*; +import org.junit.Before; +import org.junit.Test; + +public class ExecutorUnitTest { + Article article; + Stream stream; + Spliterator spliterator; + Spliterator
split1; + Spliterator
split2; + + @Before + public void init() { + article = new Article(Arrays.asList(new Author("Ahmad", 0), new Author("Eugen", 0), new Author("Alice", 1), + new Author("Alice", 1), new Author("Mike", 0), new Author("Alice", 1), new Author("Mike", 0), + new Author("Alice", 1), new Author("Mike", 0), new Author("Alice", 1), new Author("Mike", 0), + new Author("Mike", 0), new Author("Alice", 1), new Author("Mike", 0), new Author("Alice", 1), + new Author("Mike", 0), new Author("Alice", 1), new Author("Mike", 0), new Author("Alice", 1), + new Author("Mike", 0), new Author("Michał", 0), new Author("Loredana", 1)), 0); + stream = article.getListOfAuthors().stream(); + split1 = Executor.generateElements().spliterator(); + split2 = split1.trySplit(); + spliterator = new RelatedAuthorSpliterator(article.getListOfAuthors()); + } + + @Test + public void givenAstreamOfAuthors_whenProcessedInParallelWithCustomSpliterator_coubtProducessRightOutput() { + Stream stream2 = StreamSupport.stream(spliterator, true); + assertThat(Executor.countAutors(stream2.parallel())).isEqualTo(9); + } + + @Test + public void givenSpliterator_whenAppliedToAListOfArticle_thenSplittedInHalf() { + assertThat(new Task(split1).call()).containsSequence(Executor.generateElements().size() / 2 + ""); + assertThat(new Task(split2).call()).containsSequence(Executor.generateElements().size() / 2 + ""); + } +} diff --git a/core-java-8/src/test/java/com/baeldung/strategy/StrategyDesignPatternUnitTest.java b/core-java-modules/core-java-8/src/test/java/com/baeldung/strategy/StrategyDesignPatternUnitTest.java similarity index 100% rename from core-java-8/src/test/java/com/baeldung/strategy/StrategyDesignPatternUnitTest.java rename to core-java-modules/core-java-8/src/test/java/com/baeldung/strategy/StrategyDesignPatternUnitTest.java diff --git a/core-java-8/src/test/java/com/baeldung/stream/conditional/StreamForEachIfElseUnitTest.java b/core-java-modules/core-java-8/src/test/java/com/baeldung/stream/conditional/StreamForEachIfElseUnitTest.java similarity index 100% rename from core-java-8/src/test/java/com/baeldung/stream/conditional/StreamForEachIfElseUnitTest.java rename to core-java-modules/core-java-8/src/test/java/com/baeldung/stream/conditional/StreamForEachIfElseUnitTest.java diff --git a/core-java-8/src/test/java/com/baeldung/streamreduce/tests/StreamReduceManualTest.java b/core-java-modules/core-java-8/src/test/java/com/baeldung/streamreduce/tests/StreamReduceManualTest.java similarity index 97% rename from core-java-8/src/test/java/com/baeldung/streamreduce/tests/StreamReduceManualTest.java rename to core-java-modules/core-java-8/src/test/java/com/baeldung/streamreduce/tests/StreamReduceManualTest.java index 9222cbb689..0bf1a5837e 100644 --- a/core-java-8/src/test/java/com/baeldung/streamreduce/tests/StreamReduceManualTest.java +++ b/core-java-modules/core-java-8/src/test/java/com/baeldung/streamreduce/tests/StreamReduceManualTest.java @@ -1,126 +1,126 @@ -package com.baeldung.streamreduce.tests; - -import com.baeldung.streamreduce.entities.User; -import com.baeldung.streamreduce.utilities.NumberUtils; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import static org.assertj.core.api.Assertions.assertThat; -import org.junit.Test; - -public class StreamReduceManualTest { - - @Test - public void givenIntegerList_whenReduceWithSumAccumulatorLambda_thenCorrect() { - List numbers = Arrays.asList(1, 2, 3, 4, 5, 6); - - int result = numbers.stream().reduce(0, (a, b) -> a + b); - - assertThat(result).isEqualTo(21); - } - - @Test - public void givenIntegerList_whenReduceWithSumAccumulatorMethodReference_thenCorrect() { - List numbers = Arrays.asList(1, 2, 3, 4, 5, 6); - - int result = numbers.stream().reduce(0, Integer::sum); - - assertThat(result).isEqualTo(21); - } - - @Test - public void givenStringList_whenReduceWithConcatenatorAccumulatorLambda_thenCorrect() { - List letters = Arrays.asList("a", "b", "c", "d", "e"); - - String result = letters.stream().reduce("", (a, b) -> a + b); - - assertThat(result).isEqualTo("abcde"); - } - - @Test - public void givenStringList_whenReduceWithConcatenatorAccumulatorMethodReference_thenCorrect() { - List letters = Arrays.asList("a", "b", "c", "d", "e"); - - String result = letters.stream().reduce("", String::concat); - - assertThat(result).isEqualTo("abcde"); - } - - @Test - public void givenStringList_whenReduceWithUppercaseConcatenatorAccumulator_thenCorrect() { - List letters = Arrays.asList("a", "b", "c", "d", "e"); - - String result = letters.stream().reduce("", (a, b) -> a.toUpperCase() + b.toUpperCase()); - - assertThat(result).isEqualTo("ABCDE"); - } - - @Test - public void givenUserList_whenReduceWithAgeAccumulatorAndSumCombiner_thenCorrect() { - List users = Arrays.asList(new User("John", 30), new User("Julie", 35)); - - int result = users.stream().reduce(0, (partialAgeResult, user) -> partialAgeResult + user.getAge(), Integer::sum); - - assertThat(result).isEqualTo(65); - } - - @Test - public void givenStringList_whenReduceWithParallelStream_thenCorrect() { - List letters = Arrays.asList("a", "b", "c", "d", "e"); - - String result = letters.parallelStream().reduce("", String::concat); - - assertThat(result).isEqualTo("abcde"); - } - - @Test - public void givenNumberUtilsClass_whenCalledDivideListElements_thenCorrect() { - List numbers = Arrays.asList(1, 2, 3, 4, 5, 6); - - assertThat(NumberUtils.divideListElements(numbers, 1)).isEqualTo(21); - } - - @Test - public void givenNumberUtilsClass_whenCalledDivideListElementsWithExtractedTryCatchBlock_thenCorrect() { - List numbers = Arrays.asList(1, 2, 3, 4, 5, 6); - - assertThat(NumberUtils.divideListElementsWithExtractedTryCatchBlock(numbers, 1)).isEqualTo(21); - } - - @Test - public void givenNumberUtilsClass_whenCalledDivideListElementsWithExtractedTryCatchBlockAndListContainsZero_thenCorrect() { - List numbers = Arrays.asList(0, 1, 2, 3, 4, 5, 6); - - assertThat(NumberUtils.divideListElementsWithExtractedTryCatchBlock(numbers, 1)).isEqualTo(21); - } - - @Test - public void givenNumberUtilsClass_whenCalledDivideListElementsWithExtractedTryCatchBlockAndDividerIsZero_thenCorrect() { - List numbers = Arrays.asList(1, 2, 3, 4, 5, 6); - - assertThat(NumberUtils.divideListElementsWithExtractedTryCatchBlock(numbers, 0)).isEqualTo(0); - } - - @Test - public void givenStream_whneCalleddivideListElementsWithApplyFunctionMethod_thenCorrect() { - List numbers = Arrays.asList(1, 2, 3, 4, 5, 6); - - assertThat(NumberUtils.divideListElementsWithApplyFunctionMethod(numbers, 1)).isEqualTo(21); - } - - @Test - public void givenTwoStreams_whenCalledReduceOnParallelizedStream_thenFasterExecutionTime() { - List userList = new ArrayList<>(); - for (int i = 0; i <= 1000000; i++) { - userList.add(new User("John" + i, i)); - } - long currentTime1 = System.currentTimeMillis(); - userList.stream().reduce(0, (partialAgeResult, user) -> partialAgeResult + user.getAge(), Integer::sum); - long sequentialExecutionTime = System.currentTimeMillis() -currentTime1; - long currentTime2 = System.currentTimeMillis(); - userList.parallelStream().reduce(0, (partialAgeResult, user) -> partialAgeResult + user.getAge(), Integer::sum); - long parallelizedExecutionTime = System.currentTimeMillis() - currentTime2; - - assertThat(parallelizedExecutionTime).isLessThan(sequentialExecutionTime); - } -} +package com.baeldung.streamreduce.tests; + +import com.baeldung.streamreduce.entities.User; +import com.baeldung.streamreduce.utilities.NumberUtils; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import static org.assertj.core.api.Assertions.assertThat; +import org.junit.Test; + +public class StreamReduceManualTest { + + @Test + public void givenIntegerList_whenReduceWithSumAccumulatorLambda_thenCorrect() { + List numbers = Arrays.asList(1, 2, 3, 4, 5, 6); + + int result = numbers.stream().reduce(0, (a, b) -> a + b); + + assertThat(result).isEqualTo(21); + } + + @Test + public void givenIntegerList_whenReduceWithSumAccumulatorMethodReference_thenCorrect() { + List numbers = Arrays.asList(1, 2, 3, 4, 5, 6); + + int result = numbers.stream().reduce(0, Integer::sum); + + assertThat(result).isEqualTo(21); + } + + @Test + public void givenStringList_whenReduceWithConcatenatorAccumulatorLambda_thenCorrect() { + List letters = Arrays.asList("a", "b", "c", "d", "e"); + + String result = letters.stream().reduce("", (a, b) -> a + b); + + assertThat(result).isEqualTo("abcde"); + } + + @Test + public void givenStringList_whenReduceWithConcatenatorAccumulatorMethodReference_thenCorrect() { + List letters = Arrays.asList("a", "b", "c", "d", "e"); + + String result = letters.stream().reduce("", String::concat); + + assertThat(result).isEqualTo("abcde"); + } + + @Test + public void givenStringList_whenReduceWithUppercaseConcatenatorAccumulator_thenCorrect() { + List letters = Arrays.asList("a", "b", "c", "d", "e"); + + String result = letters.stream().reduce("", (a, b) -> a.toUpperCase() + b.toUpperCase()); + + assertThat(result).isEqualTo("ABCDE"); + } + + @Test + public void givenUserList_whenReduceWithAgeAccumulatorAndSumCombiner_thenCorrect() { + List users = Arrays.asList(new User("John", 30), new User("Julie", 35)); + + int result = users.stream().reduce(0, (partialAgeResult, user) -> partialAgeResult + user.getAge(), Integer::sum); + + assertThat(result).isEqualTo(65); + } + + @Test + public void givenStringList_whenReduceWithParallelStream_thenCorrect() { + List letters = Arrays.asList("a", "b", "c", "d", "e"); + + String result = letters.parallelStream().reduce("", String::concat); + + assertThat(result).isEqualTo("abcde"); + } + + @Test + public void givenNumberUtilsClass_whenCalledDivideListElements_thenCorrect() { + List numbers = Arrays.asList(1, 2, 3, 4, 5, 6); + + assertThat(NumberUtils.divideListElements(numbers, 1)).isEqualTo(21); + } + + @Test + public void givenNumberUtilsClass_whenCalledDivideListElementsWithExtractedTryCatchBlock_thenCorrect() { + List numbers = Arrays.asList(1, 2, 3, 4, 5, 6); + + assertThat(NumberUtils.divideListElementsWithExtractedTryCatchBlock(numbers, 1)).isEqualTo(21); + } + + @Test + public void givenNumberUtilsClass_whenCalledDivideListElementsWithExtractedTryCatchBlockAndListContainsZero_thenCorrect() { + List numbers = Arrays.asList(0, 1, 2, 3, 4, 5, 6); + + assertThat(NumberUtils.divideListElementsWithExtractedTryCatchBlock(numbers, 1)).isEqualTo(21); + } + + @Test + public void givenNumberUtilsClass_whenCalledDivideListElementsWithExtractedTryCatchBlockAndDividerIsZero_thenCorrect() { + List numbers = Arrays.asList(1, 2, 3, 4, 5, 6); + + assertThat(NumberUtils.divideListElementsWithExtractedTryCatchBlock(numbers, 0)).isEqualTo(0); + } + + @Test + public void givenStream_whneCalleddivideListElementsWithApplyFunctionMethod_thenCorrect() { + List numbers = Arrays.asList(1, 2, 3, 4, 5, 6); + + assertThat(NumberUtils.divideListElementsWithApplyFunctionMethod(numbers, 1)).isEqualTo(21); + } + + @Test + public void givenTwoStreams_whenCalledReduceOnParallelizedStream_thenFasterExecutionTime() { + List userList = new ArrayList<>(); + for (int i = 0; i <= 1000000; i++) { + userList.add(new User("John" + i, i)); + } + long currentTime1 = System.currentTimeMillis(); + userList.stream().reduce(0, (partialAgeResult, user) -> partialAgeResult + user.getAge(), Integer::sum); + long sequentialExecutionTime = System.currentTimeMillis() -currentTime1; + long currentTime2 = System.currentTimeMillis(); + userList.parallelStream().reduce(0, (partialAgeResult, user) -> partialAgeResult + user.getAge(), Integer::sum); + long parallelizedExecutionTime = System.currentTimeMillis() - currentTime2; + + assertThat(parallelizedExecutionTime).isLessThan(sequentialExecutionTime); + } +} diff --git a/core-java-8/src/test/java/com/baeldung/time/InstantUnitTest.java b/core-java-modules/core-java-8/src/test/java/com/baeldung/time/InstantUnitTest.java similarity index 100% rename from core-java-8/src/test/java/com/baeldung/time/InstantUnitTest.java rename to core-java-modules/core-java-8/src/test/java/com/baeldung/time/InstantUnitTest.java diff --git a/core-java-8/src/test/java/com/baeldung/time/InstantWithJMockUnitTest.java b/core-java-modules/core-java-8/src/test/java/com/baeldung/time/InstantWithJMockUnitTest.java similarity index 100% rename from core-java-8/src/test/java/com/baeldung/time/InstantWithJMockUnitTest.java rename to core-java-modules/core-java-8/src/test/java/com/baeldung/time/InstantWithJMockUnitTest.java diff --git a/core-java-8/src/test/java/com/baeldung/time/LocalDateTimeUnitTest.java b/core-java-modules/core-java-8/src/test/java/com/baeldung/time/LocalDateTimeUnitTest.java similarity index 100% rename from core-java-8/src/test/java/com/baeldung/time/LocalDateTimeUnitTest.java rename to core-java-modules/core-java-8/src/test/java/com/baeldung/time/LocalDateTimeUnitTest.java diff --git a/core-java-8/src/test/java/com/baeldung/time/LocalDateTimeWithJMockUnitTest.java b/core-java-modules/core-java-8/src/test/java/com/baeldung/time/LocalDateTimeWithJMockUnitTest.java similarity index 100% rename from core-java-8/src/test/java/com/baeldung/time/LocalDateTimeWithJMockUnitTest.java rename to core-java-modules/core-java-8/src/test/java/com/baeldung/time/LocalDateTimeWithJMockUnitTest.java diff --git a/core-java-8/src/test/java/com/baeldung/typeinference/TypeInferenceUnitTest.java b/core-java-modules/core-java-8/src/test/java/com/baeldung/typeinference/TypeInferenceUnitTest.java similarity index 100% rename from core-java-8/src/test/java/com/baeldung/typeinference/TypeInferenceUnitTest.java rename to core-java-modules/core-java-8/src/test/java/com/baeldung/typeinference/TypeInferenceUnitTest.java diff --git a/core-java-8/src/test/java/com/baeldung/util/CurrentDateTimeUnitTest.java b/core-java-modules/core-java-8/src/test/java/com/baeldung/util/CurrentDateTimeUnitTest.java similarity index 100% rename from core-java-8/src/test/java/com/baeldung/util/CurrentDateTimeUnitTest.java rename to core-java-modules/core-java-8/src/test/java/com/baeldung/util/CurrentDateTimeUnitTest.java diff --git a/core-java-8/src/test/resources/.gitignore b/core-java-modules/core-java-8/src/test/resources/.gitignore similarity index 100% rename from core-java-8/src/test/resources/.gitignore rename to core-java-modules/core-java-8/src/test/resources/.gitignore diff --git a/core-java-9/.gitignore b/core-java-modules/core-java-9/.gitignore similarity index 100% rename from core-java-9/.gitignore rename to core-java-modules/core-java-9/.gitignore diff --git a/core-java-9/README.md b/core-java-modules/core-java-9/README.md similarity index 99% rename from core-java-9/README.md rename to core-java-modules/core-java-9/README.md index c2dbef1586..ecad86ace2 100644 --- a/core-java-9/README.md +++ b/core-java-modules/core-java-9/README.md @@ -31,3 +31,4 @@ - [A Guide to Java 9 Modularity](https://www.baeldung.com/java-9-modularity) - [Java 9 Platform Module API](https://www.baeldung.com/java-9-module-api) - [Java 9 Platform Logging API](https://www.baeldung.com/java-9-logging-api) + diff --git a/core-java-9/compile-aot.sh b/core-java-modules/core-java-9/compile-aot.sh old mode 100755 new mode 100644 similarity index 100% rename from core-java-9/compile-aot.sh rename to core-java-modules/core-java-9/compile-aot.sh diff --git a/core-java-9/compile-httpclient.bat b/core-java-modules/core-java-9/compile-httpclient.bat similarity index 100% rename from core-java-9/compile-httpclient.bat rename to core-java-modules/core-java-9/compile-httpclient.bat diff --git a/core-java-9/compile-modules.sh b/core-java-modules/core-java-9/compile-modules.sh old mode 100755 new mode 100644 similarity index 100% rename from core-java-9/compile-modules.sh rename to core-java-modules/core-java-9/compile-modules.sh diff --git a/core-java-9/compile-simple-modules.sh b/core-java-modules/core-java-9/compile-simple-modules.sh old mode 100755 new mode 100644 similarity index 100% rename from core-java-9/compile-simple-modules.sh rename to core-java-modules/core-java-9/compile-simple-modules.sh diff --git a/core-java-9/compile-student-client.bat b/core-java-modules/core-java-9/compile-student-client.bat similarity index 100% rename from core-java-9/compile-student-client.bat rename to core-java-modules/core-java-9/compile-student-client.bat diff --git a/core-java-9/compile-student-model.bat b/core-java-modules/core-java-9/compile-student-model.bat similarity index 100% rename from core-java-9/compile-student-model.bat rename to core-java-modules/core-java-9/compile-student-model.bat diff --git a/core-java-9/compile-student-service-dbimpl.bat b/core-java-modules/core-java-9/compile-student-service-dbimpl.bat similarity index 100% rename from core-java-9/compile-student-service-dbimpl.bat rename to core-java-modules/core-java-9/compile-student-service-dbimpl.bat diff --git a/core-java-9/compile-student-service.bat b/core-java-modules/core-java-9/compile-student-service.bat similarity index 100% rename from core-java-9/compile-student-service.bat rename to core-java-modules/core-java-9/compile-student-service.bat diff --git a/core-java-9/logging.sh b/core-java-modules/core-java-9/logging.sh old mode 100755 new mode 100644 similarity index 100% rename from core-java-9/logging.sh rename to core-java-modules/core-java-9/logging.sh diff --git a/core-java-9/mods/logback.xml b/core-java-modules/core-java-9/mods/logback.xml similarity index 100% rename from core-java-9/mods/logback.xml rename to core-java-modules/core-java-9/mods/logback.xml diff --git a/core-java-9/pom.xml b/core-java-modules/core-java-9/pom.xml similarity index 98% rename from core-java-9/pom.xml rename to core-java-modules/core-java-9/pom.xml index cd1fa74dbb..aee289c79f 100644 --- a/core-java-9/pom.xml +++ b/core-java-modules/core-java-9/pom.xml @@ -9,6 +9,7 @@ com.baeldung parent-modules 1.0.0-SNAPSHOT + ../../ diff --git a/core-java-9/run-aot.sh b/core-java-modules/core-java-9/run-aot.sh old mode 100755 new mode 100644 similarity index 100% rename from core-java-9/run-aot.sh rename to core-java-modules/core-java-9/run-aot.sh diff --git a/core-java-9/run-httpclient.bat b/core-java-modules/core-java-9/run-httpclient.bat similarity index 100% rename from core-java-9/run-httpclient.bat rename to core-java-modules/core-java-9/run-httpclient.bat diff --git a/core-java-9/run-simple-module-app.sh b/core-java-modules/core-java-9/run-simple-module-app.sh old mode 100755 new mode 100644 similarity index 100% rename from core-java-9/run-simple-module-app.sh rename to core-java-modules/core-java-9/run-simple-module-app.sh diff --git a/core-java-9/run-student-client.bat b/core-java-modules/core-java-9/run-student-client.bat similarity index 100% rename from core-java-9/run-student-client.bat rename to core-java-modules/core-java-9/run-student-client.bat diff --git a/core-java-9/run-student-client.sh b/core-java-modules/core-java-9/run-student-client.sh old mode 100755 new mode 100644 similarity index 100% rename from core-java-9/run-student-client.sh rename to core-java-modules/core-java-9/run-student-client.sh diff --git a/core-java-9/src/main/java/.gitignore b/core-java-modules/core-java-9/src/main/java/.gitignore similarity index 100% rename from core-java-9/src/main/java/.gitignore rename to core-java-modules/core-java-9/src/main/java/.gitignore diff --git a/core-java-9/src/main/java/com/baeldung/java9/aot/JaotCompilation.java b/core-java-modules/core-java-9/src/main/java/com/baeldung/java9/aot/JaotCompilation.java similarity index 100% rename from core-java-9/src/main/java/com/baeldung/java9/aot/JaotCompilation.java rename to core-java-modules/core-java-9/src/main/java/com/baeldung/java9/aot/JaotCompilation.java diff --git a/core-java-9/src/main/java/com/baeldung/java9/language/PrivateInterface.java b/core-java-modules/core-java-9/src/main/java/com/baeldung/java9/language/PrivateInterface.java similarity index 96% rename from core-java-9/src/main/java/com/baeldung/java9/language/PrivateInterface.java rename to core-java-modules/core-java-9/src/main/java/com/baeldung/java9/language/PrivateInterface.java index f7b2fad891..3055f82fdb 100644 --- a/core-java-9/src/main/java/com/baeldung/java9/language/PrivateInterface.java +++ b/core-java-modules/core-java-9/src/main/java/com/baeldung/java9/language/PrivateInterface.java @@ -1,23 +1,23 @@ -package com.baeldung.java9.language; - -public interface PrivateInterface { - - private static String staticPrivate() { - return "static private"; - } - - private String instancePrivate() { - return "instance private"; - } - - public default void check() { - String result = staticPrivate(); - if (!result.equals("static private")) - throw new AssertionError("Incorrect result for static private interface method"); - PrivateInterface pvt = new PrivateInterface() { - }; - result = pvt.instancePrivate(); - if (!result.equals("instance private")) - throw new AssertionError("Incorrect result for instance private interface method"); - } -} +package com.baeldung.java9.language; + +public interface PrivateInterface { + + private static String staticPrivate() { + return "static private"; + } + + private String instancePrivate() { + return "instance private"; + } + + public default void check() { + String result = staticPrivate(); + if (!result.equals("static private")) + throw new AssertionError("Incorrect result for static private interface method"); + PrivateInterface pvt = new PrivateInterface() { + }; + result = pvt.instancePrivate(); + if (!result.equals("instance private")) + throw new AssertionError("Incorrect result for instance private interface method"); + } +} diff --git a/core-java-9/src/main/java/com/baeldung/java9/language/stream/StreamsGroupingCollectionFilter.java b/core-java-modules/core-java-9/src/main/java/com/baeldung/java9/language/stream/StreamsGroupingCollectionFilter.java similarity index 100% rename from core-java-9/src/main/java/com/baeldung/java9/language/stream/StreamsGroupingCollectionFilter.java rename to core-java-modules/core-java-9/src/main/java/com/baeldung/java9/language/stream/StreamsGroupingCollectionFilter.java diff --git a/core-java-9/src/main/java/com/baeldung/java9/maps/initialize/MapsInitializer.java b/core-java-modules/core-java-9/src/main/java/com/baeldung/java9/maps/initialize/MapsInitializer.java similarity index 100% rename from core-java-9/src/main/java/com/baeldung/java9/maps/initialize/MapsInitializer.java rename to core-java-modules/core-java-9/src/main/java/com/baeldung/java9/maps/initialize/MapsInitializer.java diff --git a/core-java-9/src/main/java/com/baeldung/java9/methodhandles/Book.java b/core-java-modules/core-java-9/src/main/java/com/baeldung/java9/methodhandles/Book.java similarity index 100% rename from core-java-9/src/main/java/com/baeldung/java9/methodhandles/Book.java rename to core-java-modules/core-java-9/src/main/java/com/baeldung/java9/methodhandles/Book.java diff --git a/core-java-9/src/main/java/com/baeldung/java9/rangedates/DatesCollectionIteration.java b/core-java-modules/core-java-9/src/main/java/com/baeldung/java9/rangedates/DatesCollectionIteration.java similarity index 100% rename from core-java-9/src/main/java/com/baeldung/java9/rangedates/DatesCollectionIteration.java rename to core-java-modules/core-java-9/src/main/java/com/baeldung/java9/rangedates/DatesCollectionIteration.java diff --git a/core-java-9/src/main/java/com/baeldung/java9/rangedates/RangeDatesIteration.java b/core-java-modules/core-java-9/src/main/java/com/baeldung/java9/rangedates/RangeDatesIteration.java similarity index 100% rename from core-java-9/src/main/java/com/baeldung/java9/rangedates/RangeDatesIteration.java rename to core-java-modules/core-java-9/src/main/java/com/baeldung/java9/rangedates/RangeDatesIteration.java diff --git a/core-java-9/src/main/java/com/baeldung/java9/reactive/BaeldungBatchSubscriberImpl.java b/core-java-modules/core-java-9/src/main/java/com/baeldung/java9/reactive/BaeldungBatchSubscriberImpl.java similarity index 96% rename from core-java-9/src/main/java/com/baeldung/java9/reactive/BaeldungBatchSubscriberImpl.java rename to core-java-modules/core-java-9/src/main/java/com/baeldung/java9/reactive/BaeldungBatchSubscriberImpl.java index 46eee4883a..962df447b6 100644 --- a/core-java-9/src/main/java/com/baeldung/java9/reactive/BaeldungBatchSubscriberImpl.java +++ b/core-java-modules/core-java-9/src/main/java/com/baeldung/java9/reactive/BaeldungBatchSubscriberImpl.java @@ -1,82 +1,82 @@ -package com.baeldung.java9.reactive; - -import java.util.ArrayList; -import java.util.concurrent.Flow.Subscriber; -import java.util.concurrent.Flow.Subscription; - -public class BaeldungBatchSubscriberImpl implements Subscriber { - private Subscription subscription; - private boolean completed = false; - private int counter; - private ArrayList buffer; - public static final int BUFFER_SIZE = 5; - - public BaeldungBatchSubscriberImpl() { - buffer = new ArrayList(); - } - - public boolean isCompleted() { - return completed; - } - - public void setCompleted(boolean completed) { - this.completed = completed; - } - - public int getCounter() { - return counter; - } - - public void setCounter(int counter) { - this.counter = counter; - } - - @Override - public void onSubscribe(Subscription subscription) { - this.subscription = subscription; - subscription.request(BUFFER_SIZE); - } - - @Override - public void onNext(String item) { - buffer.add(item); - // if buffer is full, process the items. - if (buffer.size() >= BUFFER_SIZE) { - processBuffer(); - } - //request more items. - subscription.request(1); - } - - private void processBuffer() { - if (buffer.isEmpty()) - return; - // Process all items in the buffer. Here, we just print it and sleep for 1 second. - System.out.print("Processed items: "); - buffer.stream() - .forEach(item -> { - System.out.print(" " + item); - }); - System.out.println(); - try { - Thread.sleep(1000); - } catch (InterruptedException e) { - e.printStackTrace(); - } - counter = counter + buffer.size(); - buffer.clear(); - } - - @Override - public void onError(Throwable t) { - t.printStackTrace(); - } - - @Override - public void onComplete() { - completed = true; - // process any remaining items in buffer before - processBuffer(); - subscription.cancel(); - } -} +package com.baeldung.java9.reactive; + +import java.util.ArrayList; +import java.util.concurrent.Flow.Subscriber; +import java.util.concurrent.Flow.Subscription; + +public class BaeldungBatchSubscriberImpl implements Subscriber { + private Subscription subscription; + private boolean completed = false; + private int counter; + private ArrayList buffer; + public static final int BUFFER_SIZE = 5; + + public BaeldungBatchSubscriberImpl() { + buffer = new ArrayList(); + } + + public boolean isCompleted() { + return completed; + } + + public void setCompleted(boolean completed) { + this.completed = completed; + } + + public int getCounter() { + return counter; + } + + public void setCounter(int counter) { + this.counter = counter; + } + + @Override + public void onSubscribe(Subscription subscription) { + this.subscription = subscription; + subscription.request(BUFFER_SIZE); + } + + @Override + public void onNext(String item) { + buffer.add(item); + // if buffer is full, process the items. + if (buffer.size() >= BUFFER_SIZE) { + processBuffer(); + } + //request more items. + subscription.request(1); + } + + private void processBuffer() { + if (buffer.isEmpty()) + return; + // Process all items in the buffer. Here, we just print it and sleep for 1 second. + System.out.print("Processed items: "); + buffer.stream() + .forEach(item -> { + System.out.print(" " + item); + }); + System.out.println(); + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + counter = counter + buffer.size(); + buffer.clear(); + } + + @Override + public void onError(Throwable t) { + t.printStackTrace(); + } + + @Override + public void onComplete() { + completed = true; + // process any remaining items in buffer before + processBuffer(); + subscription.cancel(); + } +} diff --git a/core-java-9/src/main/java/com/baeldung/java9/reactive/BaeldungSubscriberImpl.java b/core-java-modules/core-java-9/src/main/java/com/baeldung/java9/reactive/BaeldungSubscriberImpl.java similarity index 95% rename from core-java-9/src/main/java/com/baeldung/java9/reactive/BaeldungSubscriberImpl.java rename to core-java-modules/core-java-9/src/main/java/com/baeldung/java9/reactive/BaeldungSubscriberImpl.java index bacd777255..3534324675 100644 --- a/core-java-9/src/main/java/com/baeldung/java9/reactive/BaeldungSubscriberImpl.java +++ b/core-java-modules/core-java-9/src/main/java/com/baeldung/java9/reactive/BaeldungSubscriberImpl.java @@ -1,55 +1,55 @@ -package com.baeldung.java9.reactive; - -import java.util.concurrent.Flow.Subscriber; -import java.util.concurrent.Flow.Subscription; - -public class BaeldungSubscriberImpl implements Subscriber { - private Subscription subscription; - private boolean completed = false; - private int counter; - - public boolean isCompleted() { - return completed; - } - - public void setCompleted(boolean completed) { - this.completed = completed; - } - - public int getCounter() { - return counter; - } - - public void setCounter(int counter) { - this.counter = counter; - } - - @Override - public void onSubscribe(Subscription subscription) { - this.subscription = subscription; - subscription.request(1); - } - - @Override - public void onNext(String item) { - try { - Thread.sleep(1000); - } catch (InterruptedException e) { - e.printStackTrace(); - } - counter++; - System.out.println("Processed item : " + item); - subscription.request(1); - } - - @Override - public void onError(Throwable t) { - t.printStackTrace(); - } - - @Override - public void onComplete() { - completed = true; - subscription.cancel(); - } -} +package com.baeldung.java9.reactive; + +import java.util.concurrent.Flow.Subscriber; +import java.util.concurrent.Flow.Subscription; + +public class BaeldungSubscriberImpl implements Subscriber { + private Subscription subscription; + private boolean completed = false; + private int counter; + + public boolean isCompleted() { + return completed; + } + + public void setCompleted(boolean completed) { + this.completed = completed; + } + + public int getCounter() { + return counter; + } + + public void setCounter(int counter) { + this.counter = counter; + } + + @Override + public void onSubscribe(Subscription subscription) { + this.subscription = subscription; + subscription.request(1); + } + + @Override + public void onNext(String item) { + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + counter++; + System.out.println("Processed item : " + item); + subscription.request(1); + } + + @Override + public void onError(Throwable t) { + t.printStackTrace(); + } + + @Override + public void onComplete() { + completed = true; + subscription.cancel(); + } +} diff --git a/core-java-9/src/main/java/com/baeldung/java9/set/UnmodifiableSet.java b/core-java-modules/core-java-9/src/main/java/com/baeldung/java9/set/UnmodifiableSet.java similarity index 100% rename from core-java-9/src/main/java/com/baeldung/java9/set/UnmodifiableSet.java rename to core-java-modules/core-java-9/src/main/java/com/baeldung/java9/set/UnmodifiableSet.java diff --git a/core-java-9/src/main/java/com/baeldung/java9/stackwalker/StackWalkerDemo.java b/core-java-modules/core-java-9/src/main/java/com/baeldung/java9/stackwalker/StackWalkerDemo.java similarity index 100% rename from core-java-9/src/main/java/com/baeldung/java9/stackwalker/StackWalkerDemo.java rename to core-java-modules/core-java-9/src/main/java/com/baeldung/java9/stackwalker/StackWalkerDemo.java diff --git a/core-java-9/src/main/java/com/baeldung/java9/streams.reactive/EndSubscriber.java b/core-java-modules/core-java-9/src/main/java/com/baeldung/java9/streams.reactive/EndSubscriber.java similarity index 100% rename from core-java-9/src/main/java/com/baeldung/java9/streams.reactive/EndSubscriber.java rename to core-java-modules/core-java-9/src/main/java/com/baeldung/java9/streams.reactive/EndSubscriber.java diff --git a/core-java-9/src/main/java/com/baeldung/java9/streams.reactive/TransformProcessor.java b/core-java-modules/core-java-9/src/main/java/com/baeldung/java9/streams.reactive/TransformProcessor.java similarity index 100% rename from core-java-9/src/main/java/com/baeldung/java9/streams.reactive/TransformProcessor.java rename to core-java-modules/core-java-9/src/main/java/com/baeldung/java9/streams.reactive/TransformProcessor.java diff --git a/core-java-9/src/main/java/com/baeldung/multireleaseapp/App.java b/core-java-modules/core-java-9/src/main/java/com/baeldung/multireleaseapp/App.java similarity index 100% rename from core-java-9/src/main/java/com/baeldung/multireleaseapp/App.java rename to core-java-modules/core-java-9/src/main/java/com/baeldung/multireleaseapp/App.java diff --git a/core-java-9/src/main/java/com/baeldung/multireleaseapp/DateHelper.java b/core-java-modules/core-java-9/src/main/java/com/baeldung/multireleaseapp/DateHelper.java similarity index 100% rename from core-java-9/src/main/java/com/baeldung/multireleaseapp/DateHelper.java rename to core-java-modules/core-java-9/src/main/java/com/baeldung/multireleaseapp/DateHelper.java diff --git a/core-java-9/src/main/java/com/baeldung/optionals/Optionals.java b/core-java-modules/core-java-9/src/main/java/com/baeldung/optionals/Optionals.java similarity index 100% rename from core-java-9/src/main/java/com/baeldung/optionals/Optionals.java rename to core-java-modules/core-java-9/src/main/java/com/baeldung/optionals/Optionals.java diff --git a/core-java-9/src/main/java9/com/baeldung/multireleaseapp/DateHelper.java b/core-java-modules/core-java-9/src/main/java9/com/baeldung/multireleaseapp/DateHelper.java similarity index 100% rename from core-java-9/src/main/java9/com/baeldung/multireleaseapp/DateHelper.java rename to core-java-modules/core-java-9/src/main/java9/com/baeldung/multireleaseapp/DateHelper.java diff --git a/core-java-9/src/main/resources/logback.xml b/core-java-modules/core-java-9/src/main/resources/logback.xml similarity index 100% rename from core-java-9/src/main/resources/logback.xml rename to core-java-modules/core-java-9/src/main/resources/logback.xml diff --git a/core-java-9/src/modules/com.baeldung.httpclient/com/baeldung/httpclient/HttpClientExample.java b/core-java-modules/core-java-9/src/modules/com.baeldung.httpclient/com/baeldung/httpclient/HttpClientExample.java similarity index 100% rename from core-java-9/src/modules/com.baeldung.httpclient/com/baeldung/httpclient/HttpClientExample.java rename to core-java-modules/core-java-9/src/modules/com.baeldung.httpclient/com/baeldung/httpclient/HttpClientExample.java diff --git a/core-java-9/src/modules/com.baeldung.httpclient/module-info.java b/core-java-modules/core-java-9/src/modules/com.baeldung.httpclient/module-info.java similarity index 100% rename from core-java-9/src/modules/com.baeldung.httpclient/module-info.java rename to core-java-modules/core-java-9/src/modules/com.baeldung.httpclient/module-info.java diff --git a/core-java-9/src/modules/com.baeldung.logging.app/com/baeldung/logging/app/MainApp.java b/core-java-modules/core-java-9/src/modules/com.baeldung.logging.app/com/baeldung/logging/app/MainApp.java similarity index 100% rename from core-java-9/src/modules/com.baeldung.logging.app/com/baeldung/logging/app/MainApp.java rename to core-java-modules/core-java-9/src/modules/com.baeldung.logging.app/com/baeldung/logging/app/MainApp.java diff --git a/core-java-9/src/modules/com.baeldung.logging.app/module-info.java b/core-java-modules/core-java-9/src/modules/com.baeldung.logging.app/module-info.java similarity index 100% rename from core-java-9/src/modules/com.baeldung.logging.app/module-info.java rename to core-java-modules/core-java-9/src/modules/com.baeldung.logging.app/module-info.java diff --git a/core-java-9/src/modules/com.baeldung.logging.slf4j/com/baeldung/logging/slf4j/Slf4jLogger.java b/core-java-modules/core-java-9/src/modules/com.baeldung.logging.slf4j/com/baeldung/logging/slf4j/Slf4jLogger.java similarity index 100% rename from core-java-9/src/modules/com.baeldung.logging.slf4j/com/baeldung/logging/slf4j/Slf4jLogger.java rename to core-java-modules/core-java-9/src/modules/com.baeldung.logging.slf4j/com/baeldung/logging/slf4j/Slf4jLogger.java diff --git a/core-java-9/src/modules/com.baeldung.logging.slf4j/com/baeldung/logging/slf4j/Slf4jLoggerFinder.java b/core-java-modules/core-java-9/src/modules/com.baeldung.logging.slf4j/com/baeldung/logging/slf4j/Slf4jLoggerFinder.java similarity index 100% rename from core-java-9/src/modules/com.baeldung.logging.slf4j/com/baeldung/logging/slf4j/Slf4jLoggerFinder.java rename to core-java-modules/core-java-9/src/modules/com.baeldung.logging.slf4j/com/baeldung/logging/slf4j/Slf4jLoggerFinder.java diff --git a/core-java-9/src/modules/com.baeldung.logging.slf4j/module-info.java b/core-java-modules/core-java-9/src/modules/com.baeldung.logging.slf4j/module-info.java similarity index 100% rename from core-java-9/src/modules/com.baeldung.logging.slf4j/module-info.java rename to core-java-modules/core-java-9/src/modules/com.baeldung.logging.slf4j/module-info.java diff --git a/core-java-9/src/modules/com.baeldung.logging/com/baeldung/logging/ConsoleLogger.java b/core-java-modules/core-java-9/src/modules/com.baeldung.logging/com/baeldung/logging/ConsoleLogger.java similarity index 100% rename from core-java-9/src/modules/com.baeldung.logging/com/baeldung/logging/ConsoleLogger.java rename to core-java-modules/core-java-9/src/modules/com.baeldung.logging/com/baeldung/logging/ConsoleLogger.java diff --git a/core-java-9/src/modules/com.baeldung.logging/com/baeldung/logging/CustomLoggerFinder.java b/core-java-modules/core-java-9/src/modules/com.baeldung.logging/com/baeldung/logging/CustomLoggerFinder.java similarity index 100% rename from core-java-9/src/modules/com.baeldung.logging/com/baeldung/logging/CustomLoggerFinder.java rename to core-java-modules/core-java-9/src/modules/com.baeldung.logging/com/baeldung/logging/CustomLoggerFinder.java diff --git a/core-java-9/src/modules/com.baeldung.logging/module-info.java b/core-java-modules/core-java-9/src/modules/com.baeldung.logging/module-info.java similarity index 100% rename from core-java-9/src/modules/com.baeldung.logging/module-info.java rename to core-java-modules/core-java-9/src/modules/com.baeldung.logging/module-info.java diff --git a/core-java-9/src/modules/com.baeldung.student.client/com/baeldung/student/client/StudentClient.java b/core-java-modules/core-java-9/src/modules/com.baeldung.student.client/com/baeldung/student/client/StudentClient.java similarity index 100% rename from core-java-9/src/modules/com.baeldung.student.client/com/baeldung/student/client/StudentClient.java rename to core-java-modules/core-java-9/src/modules/com.baeldung.student.client/com/baeldung/student/client/StudentClient.java diff --git a/core-java-9/src/modules/com.baeldung.student.client/module-info.java b/core-java-modules/core-java-9/src/modules/com.baeldung.student.client/module-info.java similarity index 100% rename from core-java-9/src/modules/com.baeldung.student.client/module-info.java rename to core-java-modules/core-java-9/src/modules/com.baeldung.student.client/module-info.java diff --git a/core-java-9/src/modules/com.baeldung.student.model/com/baeldung/student/model/Student.java b/core-java-modules/core-java-9/src/modules/com.baeldung.student.model/com/baeldung/student/model/Student.java similarity index 100% rename from core-java-9/src/modules/com.baeldung.student.model/com/baeldung/student/model/Student.java rename to core-java-modules/core-java-9/src/modules/com.baeldung.student.model/com/baeldung/student/model/Student.java diff --git a/core-java-9/src/modules/com.baeldung.student.model/module-info.java b/core-java-modules/core-java-9/src/modules/com.baeldung.student.model/module-info.java similarity index 100% rename from core-java-9/src/modules/com.baeldung.student.model/module-info.java rename to core-java-modules/core-java-9/src/modules/com.baeldung.student.model/module-info.java diff --git a/core-java-9/src/modules/com.baeldung.student.service.dbimpl/com/baeldung/student/service/dbimpl/StudentDbService.java b/core-java-modules/core-java-9/src/modules/com.baeldung.student.service.dbimpl/com/baeldung/student/service/dbimpl/StudentDbService.java similarity index 100% rename from core-java-9/src/modules/com.baeldung.student.service.dbimpl/com/baeldung/student/service/dbimpl/StudentDbService.java rename to core-java-modules/core-java-9/src/modules/com.baeldung.student.service.dbimpl/com/baeldung/student/service/dbimpl/StudentDbService.java diff --git a/core-java-9/src/modules/com.baeldung.student.service.dbimpl/module-info.java b/core-java-modules/core-java-9/src/modules/com.baeldung.student.service.dbimpl/module-info.java similarity index 100% rename from core-java-9/src/modules/com.baeldung.student.service.dbimpl/module-info.java rename to core-java-modules/core-java-9/src/modules/com.baeldung.student.service.dbimpl/module-info.java diff --git a/core-java-9/src/modules/com.baeldung.student.service/com/baeldung/student/service/StudentService.java b/core-java-modules/core-java-9/src/modules/com.baeldung.student.service/com/baeldung/student/service/StudentService.java similarity index 100% rename from core-java-9/src/modules/com.baeldung.student.service/com/baeldung/student/service/StudentService.java rename to core-java-modules/core-java-9/src/modules/com.baeldung.student.service/com/baeldung/student/service/StudentService.java diff --git a/core-java-9/src/modules/com.baeldung.student.service/module-info.java b/core-java-modules/core-java-9/src/modules/com.baeldung.student.service/module-info.java similarity index 100% rename from core-java-9/src/modules/com.baeldung.student.service/module-info.java rename to core-java-modules/core-java-9/src/modules/com.baeldung.student.service/module-info.java diff --git a/core-java-9/src/simple-modules/hello.modules/com/baeldung/modules/hello/HelloInterface.java b/core-java-modules/core-java-9/src/simple-modules/hello.modules/com/baeldung/modules/hello/HelloInterface.java similarity index 100% rename from core-java-9/src/simple-modules/hello.modules/com/baeldung/modules/hello/HelloInterface.java rename to core-java-modules/core-java-9/src/simple-modules/hello.modules/com/baeldung/modules/hello/HelloInterface.java diff --git a/core-java-9/src/simple-modules/hello.modules/com/baeldung/modules/hello/HelloModules.java b/core-java-modules/core-java-9/src/simple-modules/hello.modules/com/baeldung/modules/hello/HelloModules.java similarity index 100% rename from core-java-9/src/simple-modules/hello.modules/com/baeldung/modules/hello/HelloModules.java rename to core-java-modules/core-java-9/src/simple-modules/hello.modules/com/baeldung/modules/hello/HelloModules.java diff --git a/core-java-9/src/simple-modules/hello.modules/module-info.java b/core-java-modules/core-java-9/src/simple-modules/hello.modules/module-info.java similarity index 100% rename from core-java-9/src/simple-modules/hello.modules/module-info.java rename to core-java-modules/core-java-9/src/simple-modules/hello.modules/module-info.java diff --git a/core-java-9/src/simple-modules/main.app/com/baeldung/modules/main/MainApp.java b/core-java-modules/core-java-9/src/simple-modules/main.app/com/baeldung/modules/main/MainApp.java similarity index 100% rename from core-java-9/src/simple-modules/main.app/com/baeldung/modules/main/MainApp.java rename to core-java-modules/core-java-9/src/simple-modules/main.app/com/baeldung/modules/main/MainApp.java diff --git a/core-java-9/src/simple-modules/main.app/module-info.java b/core-java-modules/core-java-9/src/simple-modules/main.app/module-info.java similarity index 100% rename from core-java-9/src/simple-modules/main.app/module-info.java rename to core-java-modules/core-java-9/src/simple-modules/main.app/module-info.java diff --git a/core-java-9/src/test/java/com/baeldung/java9/Java9OptionalTest.java b/core-java-modules/core-java-9/src/test/java/com/baeldung/java9/Java9OptionalTest.java similarity index 100% rename from core-java-9/src/test/java/com/baeldung/java9/Java9OptionalTest.java rename to core-java-modules/core-java-9/src/test/java/com/baeldung/java9/Java9OptionalTest.java diff --git a/core-java-9/src/test/java/com/baeldung/java9/Java9OptionalsStreamUnitTest.java b/core-java-modules/core-java-9/src/test/java/com/baeldung/java9/Java9OptionalsStreamUnitTest.java similarity index 100% rename from core-java-9/src/test/java/com/baeldung/java9/Java9OptionalsStreamUnitTest.java rename to core-java-modules/core-java-9/src/test/java/com/baeldung/java9/Java9OptionalsStreamUnitTest.java diff --git a/core-java-9/src/test/java/com/baeldung/java9/MultiResultionImageUnitTest.java b/core-java-modules/core-java-9/src/test/java/com/baeldung/java9/MultiResultionImageUnitTest.java similarity index 97% rename from core-java-9/src/test/java/com/baeldung/java9/MultiResultionImageUnitTest.java rename to core-java-modules/core-java-9/src/test/java/com/baeldung/java9/MultiResultionImageUnitTest.java index 2c383a44b4..442d85e3f2 100644 --- a/core-java-9/src/test/java/com/baeldung/java9/MultiResultionImageUnitTest.java +++ b/core-java-modules/core-java-9/src/test/java/com/baeldung/java9/MultiResultionImageUnitTest.java @@ -1,44 +1,44 @@ -package com.baeldung.java9; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertSame; - -import java.awt.Image; -import java.awt.image.BaseMultiResolutionImage; -import java.awt.image.BufferedImage; -import java.awt.image.MultiResolutionImage; -import java.util.List; - -import org.junit.Test; - -public class MultiResultionImageUnitTest { - - @Test - public void baseMultiResImageTest() { - int baseIndex = 1; - int length = 4; - BufferedImage[] resolutionVariants = new BufferedImage[length]; - for (int i = 0; i < length; i++) { - resolutionVariants[i] = createImage(i); - } - MultiResolutionImage bmrImage = new BaseMultiResolutionImage(baseIndex, resolutionVariants); - List rvImageList = bmrImage.getResolutionVariants(); - assertEquals("MultiResoltion Image shoudl contain the same number of resolution variants!", rvImageList.size(), length); - - for (int i = 0; i < length; i++) { - int imageSize = getSize(i); - Image testRVImage = bmrImage.getResolutionVariant(imageSize, imageSize); - assertSame("Images should be the same", testRVImage, resolutionVariants[i]); - } - - } - - private static int getSize(int i) { - return 8 * (i + 1); - } - - private static BufferedImage createImage(int i) { - return new BufferedImage(getSize(i), getSize(i), BufferedImage.TYPE_INT_RGB); - } - -} +package com.baeldung.java9; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertSame; + +import java.awt.Image; +import java.awt.image.BaseMultiResolutionImage; +import java.awt.image.BufferedImage; +import java.awt.image.MultiResolutionImage; +import java.util.List; + +import org.junit.Test; + +public class MultiResultionImageUnitTest { + + @Test + public void baseMultiResImageTest() { + int baseIndex = 1; + int length = 4; + BufferedImage[] resolutionVariants = new BufferedImage[length]; + for (int i = 0; i < length; i++) { + resolutionVariants[i] = createImage(i); + } + MultiResolutionImage bmrImage = new BaseMultiResolutionImage(baseIndex, resolutionVariants); + List rvImageList = bmrImage.getResolutionVariants(); + assertEquals("MultiResoltion Image shoudl contain the same number of resolution variants!", rvImageList.size(), length); + + for (int i = 0; i < length; i++) { + int imageSize = getSize(i); + Image testRVImage = bmrImage.getResolutionVariant(imageSize, imageSize); + assertSame("Images should be the same", testRVImage, resolutionVariants[i]); + } + + } + + private static int getSize(int i) { + return 8 * (i + 1); + } + + private static BufferedImage createImage(int i) { + return new BufferedImage(getSize(i), getSize(i), BufferedImage.TYPE_INT_RGB); + } + +} diff --git a/core-java-9/src/test/java/com/baeldung/java9/OptionalToStreamUnitTest.java b/core-java-modules/core-java-9/src/test/java/com/baeldung/java9/OptionalToStreamUnitTest.java similarity index 100% rename from core-java-9/src/test/java/com/baeldung/java9/OptionalToStreamUnitTest.java rename to core-java-modules/core-java-9/src/test/java/com/baeldung/java9/OptionalToStreamUnitTest.java diff --git a/core-java-9/src/test/java/com/baeldung/java9/README.MD b/core-java-modules/core-java-9/src/test/java/com/baeldung/java9/README.MD similarity index 100% rename from core-java-9/src/test/java/com/baeldung/java9/README.MD rename to core-java-modules/core-java-9/src/test/java/com/baeldung/java9/README.MD diff --git a/core-java-9/src/test/java/com/baeldung/java9/SetExamplesUnitTest.java b/core-java-modules/core-java-9/src/test/java/com/baeldung/java9/SetExamplesUnitTest.java similarity index 100% rename from core-java-9/src/test/java/com/baeldung/java9/SetExamplesUnitTest.java rename to core-java-modules/core-java-9/src/test/java/com/baeldung/java9/SetExamplesUnitTest.java diff --git a/core-java-9/src/test/java/com/baeldung/java9/concurrent/future/CompletableFutureUnitTest.java b/core-java-modules/core-java-9/src/test/java/com/baeldung/java9/concurrent/future/CompletableFutureUnitTest.java similarity index 100% rename from core-java-9/src/test/java/com/baeldung/java9/concurrent/future/CompletableFutureUnitTest.java rename to core-java-modules/core-java-9/src/test/java/com/baeldung/java9/concurrent/future/CompletableFutureUnitTest.java diff --git a/core-java-9/src/test/java/com/baeldung/java9/httpclient/HttpClientTest.java b/core-java-modules/core-java-9/src/test/java/com/baeldung/java9/httpclient/HttpClientTest.java similarity index 100% rename from core-java-9/src/test/java/com/baeldung/java9/httpclient/HttpClientTest.java rename to core-java-modules/core-java-9/src/test/java/com/baeldung/java9/httpclient/HttpClientTest.java diff --git a/core-java-9/src/test/java/com/baeldung/java9/httpclient/HttpRequestTest.java b/core-java-modules/core-java-9/src/test/java/com/baeldung/java9/httpclient/HttpRequestTest.java similarity index 100% rename from core-java-9/src/test/java/com/baeldung/java9/httpclient/HttpRequestTest.java rename to core-java-modules/core-java-9/src/test/java/com/baeldung/java9/httpclient/HttpRequestTest.java diff --git a/core-java-9/src/test/java/com/baeldung/java9/httpclient/HttpResponseTest.java b/core-java-modules/core-java-9/src/test/java/com/baeldung/java9/httpclient/HttpResponseTest.java similarity index 100% rename from core-java-9/src/test/java/com/baeldung/java9/httpclient/HttpResponseTest.java rename to core-java-modules/core-java-9/src/test/java/com/baeldung/java9/httpclient/HttpResponseTest.java diff --git a/core-java-9/src/test/java/com/baeldung/java9/language/DiamondUnitTest.java b/core-java-modules/core-java-9/src/test/java/com/baeldung/java9/language/DiamondUnitTest.java similarity index 95% rename from core-java-9/src/test/java/com/baeldung/java9/language/DiamondUnitTest.java rename to core-java-modules/core-java-9/src/test/java/com/baeldung/java9/language/DiamondUnitTest.java index 4868d37b6a..b1cb4ef63b 100644 --- a/core-java-9/src/test/java/com/baeldung/java9/language/DiamondUnitTest.java +++ b/core-java-modules/core-java-9/src/test/java/com/baeldung/java9/language/DiamondUnitTest.java @@ -1,36 +1,36 @@ -package com.baeldung.java9.language; - -import org.junit.Test; - -public class DiamondUnitTest { - - static class FooClass { - FooClass(X x) { - } - - FooClass(X x, Z z) { - } - } - - @Test - public void diamondTest() { - FooClass fc = new FooClass<>(1) { - }; - FooClass fc0 = new FooClass<>(1) { - }; - FooClass fc1 = new FooClass<>(1) { - }; - FooClass fc2 = new FooClass<>(1) { - }; - - FooClass fc3 = new FooClass<>(1, "") { - }; - FooClass fc4 = new FooClass<>(1, "") { - }; - FooClass fc5 = new FooClass<>(1, "") { - }; - FooClass fc6 = new FooClass<>(1, "") { - }; - - } -} +package com.baeldung.java9.language; + +import org.junit.Test; + +public class DiamondUnitTest { + + static class FooClass { + FooClass(X x) { + } + + FooClass(X x, Z z) { + } + } + + @Test + public void diamondTest() { + FooClass fc = new FooClass<>(1) { + }; + FooClass fc0 = new FooClass<>(1) { + }; + FooClass fc1 = new FooClass<>(1) { + }; + FooClass fc2 = new FooClass<>(1) { + }; + + FooClass fc3 = new FooClass<>(1, "") { + }; + FooClass fc4 = new FooClass<>(1, "") { + }; + FooClass fc5 = new FooClass<>(1, "") { + }; + FooClass fc6 = new FooClass<>(1, "") { + }; + + } +} diff --git a/core-java-9/src/test/java/com/baeldung/java9/language/Java9ObjectsAPIUnitTest.java b/core-java-modules/core-java-9/src/test/java/com/baeldung/java9/language/Java9ObjectsAPIUnitTest.java similarity index 100% rename from core-java-9/src/test/java/com/baeldung/java9/language/Java9ObjectsAPIUnitTest.java rename to core-java-modules/core-java-9/src/test/java/com/baeldung/java9/language/Java9ObjectsAPIUnitTest.java diff --git a/core-java-9/src/test/java/com/baeldung/java9/language/PrivateInterfaceUnitTest.java b/core-java-modules/core-java-9/src/test/java/com/baeldung/java9/language/PrivateInterfaceUnitTest.java similarity index 95% rename from core-java-9/src/test/java/com/baeldung/java9/language/PrivateInterfaceUnitTest.java rename to core-java-modules/core-java-9/src/test/java/com/baeldung/java9/language/PrivateInterfaceUnitTest.java index fb00fe45c3..08aee72f6e 100644 --- a/core-java-9/src/test/java/com/baeldung/java9/language/PrivateInterfaceUnitTest.java +++ b/core-java-modules/core-java-9/src/test/java/com/baeldung/java9/language/PrivateInterfaceUnitTest.java @@ -1,15 +1,15 @@ -package com.baeldung.java9.language; - -import com.baeldung.java9.language.PrivateInterface; -import org.junit.Test; - -public class PrivateInterfaceUnitTest { - - @Test - public void test() { - PrivateInterface piClass = new PrivateInterface() { - }; - piClass.check(); - } - -} +package com.baeldung.java9.language; + +import com.baeldung.java9.language.PrivateInterface; +import org.junit.Test; + +public class PrivateInterfaceUnitTest { + + @Test + public void test() { + PrivateInterface piClass = new PrivateInterface() { + }; + piClass.check(); + } + +} diff --git a/core-java-9/src/test/java/com/baeldung/java9/language/TryWithResourcesUnitTest.java b/core-java-modules/core-java-9/src/test/java/com/baeldung/java9/language/TryWithResourcesUnitTest.java similarity index 96% rename from core-java-9/src/test/java/com/baeldung/java9/language/TryWithResourcesUnitTest.java rename to core-java-modules/core-java-9/src/test/java/com/baeldung/java9/language/TryWithResourcesUnitTest.java index d623bd9965..9afa1c90dd 100644 --- a/core-java-9/src/test/java/com/baeldung/java9/language/TryWithResourcesUnitTest.java +++ b/core-java-modules/core-java-9/src/test/java/com/baeldung/java9/language/TryWithResourcesUnitTest.java @@ -1,67 +1,67 @@ -package com.baeldung.java9.language; - -import static org.junit.Assert.assertEquals; -import org.junit.Test; - -public class TryWithResourcesUnitTest { - - static int closeCount = 0; - - static class MyAutoCloseable implements AutoCloseable { - final FinalWrapper finalWrapper = new FinalWrapper(); - - public void close() { - closeCount++; - } - - static class FinalWrapper { - public final AutoCloseable finalCloseable = new AutoCloseable() { - @Override - public void close() throws Exception { - closeCount++; - } - }; - } - } - - @Test - public void tryWithResourcesTest() { - MyAutoCloseable mac = new MyAutoCloseable(); - - try (mac) { - assertEquals("Expected and Actual does not match", 0, closeCount); - } - - try (mac.finalWrapper.finalCloseable) { - assertEquals("Expected and Actual does not match", 1, closeCount); - } catch (Exception ex) { - } - - try (new MyAutoCloseable() { }.finalWrapper.finalCloseable) { - assertEquals("Expected and Actual does not match", 2, closeCount); - } catch (Exception ex) { - } - - try ((closeCount > 0 ? mac : new MyAutoCloseable()).finalWrapper.finalCloseable) { - assertEquals("Expected and Actual does not match", 3, closeCount); - } catch (Exception ex) { - } - - try { - throw new CloseableException(); - } catch (CloseableException ex) { - try (ex) { - assertEquals("Expected and Actual does not match", 4, closeCount); - } - } - assertEquals("Expected and Actual does not match", 5, closeCount); - } - - static class CloseableException extends Exception implements AutoCloseable { - @Override - public void close() { - closeCount++; - } - } - -} +package com.baeldung.java9.language; + +import static org.junit.Assert.assertEquals; +import org.junit.Test; + +public class TryWithResourcesUnitTest { + + static int closeCount = 0; + + static class MyAutoCloseable implements AutoCloseable { + final FinalWrapper finalWrapper = new FinalWrapper(); + + public void close() { + closeCount++; + } + + static class FinalWrapper { + public final AutoCloseable finalCloseable = new AutoCloseable() { + @Override + public void close() throws Exception { + closeCount++; + } + }; + } + } + + @Test + public void tryWithResourcesTest() { + MyAutoCloseable mac = new MyAutoCloseable(); + + try (mac) { + assertEquals("Expected and Actual does not match", 0, closeCount); + } + + try (mac.finalWrapper.finalCloseable) { + assertEquals("Expected and Actual does not match", 1, closeCount); + } catch (Exception ex) { + } + + try (new MyAutoCloseable() { }.finalWrapper.finalCloseable) { + assertEquals("Expected and Actual does not match", 2, closeCount); + } catch (Exception ex) { + } + + try ((closeCount > 0 ? mac : new MyAutoCloseable()).finalWrapper.finalCloseable) { + assertEquals("Expected and Actual does not match", 3, closeCount); + } catch (Exception ex) { + } + + try { + throw new CloseableException(); + } catch (CloseableException ex) { + try (ex) { + assertEquals("Expected and Actual does not match", 4, closeCount); + } + } + assertEquals("Expected and Actual does not match", 5, closeCount); + } + + static class CloseableException extends Exception implements AutoCloseable { + @Override + public void close() { + closeCount++; + } + } + +} diff --git a/core-java-9/src/test/java/com/baeldung/java9/language/collections/ListFactoryMethodsUnitTest.java b/core-java-modules/core-java-9/src/test/java/com/baeldung/java9/language/collections/ListFactoryMethodsUnitTest.java similarity index 100% rename from core-java-9/src/test/java/com/baeldung/java9/language/collections/ListFactoryMethodsUnitTest.java rename to core-java-modules/core-java-9/src/test/java/com/baeldung/java9/language/collections/ListFactoryMethodsUnitTest.java diff --git a/core-java-9/src/test/java/com/baeldung/java9/language/collections/MapFactoryMethodsUnitTest.java b/core-java-modules/core-java-9/src/test/java/com/baeldung/java9/language/collections/MapFactoryMethodsUnitTest.java similarity index 100% rename from core-java-9/src/test/java/com/baeldung/java9/language/collections/MapFactoryMethodsUnitTest.java rename to core-java-modules/core-java-9/src/test/java/com/baeldung/java9/language/collections/MapFactoryMethodsUnitTest.java diff --git a/core-java-9/src/test/java/com/baeldung/java9/language/collections/SetFactoryMethodsUnitTest.java b/core-java-modules/core-java-9/src/test/java/com/baeldung/java9/language/collections/SetFactoryMethodsUnitTest.java similarity index 100% rename from core-java-9/src/test/java/com/baeldung/java9/language/collections/SetFactoryMethodsUnitTest.java rename to core-java-modules/core-java-9/src/test/java/com/baeldung/java9/language/collections/SetFactoryMethodsUnitTest.java diff --git a/core-java-9/src/test/java/com/baeldung/java9/language/stream/CollectionFilterUnitTest.java b/core-java-modules/core-java-9/src/test/java/com/baeldung/java9/language/stream/CollectionFilterUnitTest.java similarity index 100% rename from core-java-9/src/test/java/com/baeldung/java9/language/stream/CollectionFilterUnitTest.java rename to core-java-modules/core-java-9/src/test/java/com/baeldung/java9/language/stream/CollectionFilterUnitTest.java diff --git a/core-java-9/src/test/java/com/baeldung/java9/language/stream/CollectorImprovementUnitTest.java b/core-java-modules/core-java-9/src/test/java/com/baeldung/java9/language/stream/CollectorImprovementUnitTest.java similarity index 100% rename from core-java-9/src/test/java/com/baeldung/java9/language/stream/CollectorImprovementUnitTest.java rename to core-java-modules/core-java-9/src/test/java/com/baeldung/java9/language/stream/CollectorImprovementUnitTest.java diff --git a/core-java-9/src/test/java/com/baeldung/java9/language/stream/StreamFeaturesUnitTest.java b/core-java-modules/core-java-9/src/test/java/com/baeldung/java9/language/stream/StreamFeaturesUnitTest.java similarity index 100% rename from core-java-9/src/test/java/com/baeldung/java9/language/stream/StreamFeaturesUnitTest.java rename to core-java-modules/core-java-9/src/test/java/com/baeldung/java9/language/stream/StreamFeaturesUnitTest.java diff --git a/core-java-9/src/test/java/com/baeldung/java9/methodhandles/MethodHandlesTest.java b/core-java-modules/core-java-9/src/test/java/com/baeldung/java9/methodhandles/MethodHandlesTest.java similarity index 100% rename from core-java-9/src/test/java/com/baeldung/java9/methodhandles/MethodHandlesTest.java rename to core-java-modules/core-java-9/src/test/java/com/baeldung/java9/methodhandles/MethodHandlesTest.java diff --git a/core-java-9/src/test/java/com/baeldung/java9/modules/ModuleAPIUnitTest.java b/core-java-modules/core-java-9/src/test/java/com/baeldung/java9/modules/ModuleAPIUnitTest.java similarity index 100% rename from core-java-9/src/test/java/com/baeldung/java9/modules/ModuleAPIUnitTest.java rename to core-java-modules/core-java-9/src/test/java/com/baeldung/java9/modules/ModuleAPIUnitTest.java diff --git a/core-java-9/src/test/java/com/baeldung/java9/rangedates/DatesCollectionIterationUnitTest.java b/core-java-modules/core-java-9/src/test/java/com/baeldung/java9/rangedates/DatesCollectionIterationUnitTest.java similarity index 100% rename from core-java-9/src/test/java/com/baeldung/java9/rangedates/DatesCollectionIterationUnitTest.java rename to core-java-modules/core-java-9/src/test/java/com/baeldung/java9/rangedates/DatesCollectionIterationUnitTest.java diff --git a/core-java-9/src/test/java/com/baeldung/java9/rangedates/RangeDatesIterationUnitTest.java b/core-java-modules/core-java-9/src/test/java/com/baeldung/java9/rangedates/RangeDatesIterationUnitTest.java similarity index 100% rename from core-java-9/src/test/java/com/baeldung/java9/rangedates/RangeDatesIterationUnitTest.java rename to core-java-modules/core-java-9/src/test/java/com/baeldung/java9/rangedates/RangeDatesIterationUnitTest.java diff --git a/core-java-9/src/test/java/com/baeldung/java9/reactive/BaeldungBatchSubscriberImplIntegrationTest.java b/core-java-modules/core-java-9/src/test/java/com/baeldung/java9/reactive/BaeldungBatchSubscriberImplIntegrationTest.java similarity index 96% rename from core-java-9/src/test/java/com/baeldung/java9/reactive/BaeldungBatchSubscriberImplIntegrationTest.java rename to core-java-modules/core-java-9/src/test/java/com/baeldung/java9/reactive/BaeldungBatchSubscriberImplIntegrationTest.java index cbc3946999..15dc13ec71 100644 --- a/core-java-9/src/test/java/com/baeldung/java9/reactive/BaeldungBatchSubscriberImplIntegrationTest.java +++ b/core-java-modules/core-java-9/src/test/java/com/baeldung/java9/reactive/BaeldungBatchSubscriberImplIntegrationTest.java @@ -1,75 +1,75 @@ -package com.baeldung.java9.reactive; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import java.util.concurrent.ForkJoinPool; -import java.util.concurrent.SubmissionPublisher; -import java.util.concurrent.TimeUnit; -import java.util.stream.IntStream; - -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.Stopwatch; - -public class BaeldungBatchSubscriberImplIntegrationTest { - - private static final int ITEM_SIZE = 10; - private SubmissionPublisher publisher; - private BaeldungBatchSubscriberImpl subscriber; - - @Before - public void initialize() { - this.publisher = new SubmissionPublisher(ForkJoinPool.commonPool(), 6); - this.subscriber = new BaeldungBatchSubscriberImpl(); - publisher.subscribe(subscriber); - } - - @Rule - public Stopwatch stopwatch = new Stopwatch() { - - }; - - @Test - public void testReactiveStreamCount() { - IntStream.range(0, ITEM_SIZE) - .forEach(item -> publisher.submit(item + "")); - publisher.close(); - - do { - // wait for subscribers to complete all processing. - try { - Thread.sleep(100); - } catch (InterruptedException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } while (!subscriber.isCompleted()); - - int count = subscriber.getCounter(); - - assertEquals(ITEM_SIZE, count); - } - - @Test - public void testReactiveStreamTime() { - IntStream.range(0, ITEM_SIZE) - .forEach(item -> publisher.submit(item + "")); - publisher.close(); - - do { - // wait for subscribers to complete all processing. - try { - Thread.sleep(100); - } catch (InterruptedException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } while (!subscriber.isCompleted()); - - // The runtime in seconds should be equal to the number of items in each batch. - assertTrue(stopwatch.runtime(TimeUnit.SECONDS) >= (ITEM_SIZE / subscriber.BUFFER_SIZE)); - } - -} +package com.baeldung.java9.reactive; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import java.util.concurrent.ForkJoinPool; +import java.util.concurrent.SubmissionPublisher; +import java.util.concurrent.TimeUnit; +import java.util.stream.IntStream; + +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.Stopwatch; + +public class BaeldungBatchSubscriberImplIntegrationTest { + + private static final int ITEM_SIZE = 10; + private SubmissionPublisher publisher; + private BaeldungBatchSubscriberImpl subscriber; + + @Before + public void initialize() { + this.publisher = new SubmissionPublisher(ForkJoinPool.commonPool(), 6); + this.subscriber = new BaeldungBatchSubscriberImpl(); + publisher.subscribe(subscriber); + } + + @Rule + public Stopwatch stopwatch = new Stopwatch() { + + }; + + @Test + public void testReactiveStreamCount() { + IntStream.range(0, ITEM_SIZE) + .forEach(item -> publisher.submit(item + "")); + publisher.close(); + + do { + // wait for subscribers to complete all processing. + try { + Thread.sleep(100); + } catch (InterruptedException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } while (!subscriber.isCompleted()); + + int count = subscriber.getCounter(); + + assertEquals(ITEM_SIZE, count); + } + + @Test + public void testReactiveStreamTime() { + IntStream.range(0, ITEM_SIZE) + .forEach(item -> publisher.submit(item + "")); + publisher.close(); + + do { + // wait for subscribers to complete all processing. + try { + Thread.sleep(100); + } catch (InterruptedException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } while (!subscriber.isCompleted()); + + // The runtime in seconds should be equal to the number of items in each batch. + assertTrue(stopwatch.runtime(TimeUnit.SECONDS) >= (ITEM_SIZE / subscriber.BUFFER_SIZE)); + } + +} diff --git a/core-java-9/src/test/java/com/baeldung/java9/reactive/BaeldungSubscriberImplIntegrationTest.java b/core-java-modules/core-java-9/src/test/java/com/baeldung/java9/reactive/BaeldungSubscriberImplIntegrationTest.java similarity index 96% rename from core-java-9/src/test/java/com/baeldung/java9/reactive/BaeldungSubscriberImplIntegrationTest.java rename to core-java-modules/core-java-9/src/test/java/com/baeldung/java9/reactive/BaeldungSubscriberImplIntegrationTest.java index 6fd093b362..84877db500 100644 --- a/core-java-9/src/test/java/com/baeldung/java9/reactive/BaeldungSubscriberImplIntegrationTest.java +++ b/core-java-modules/core-java-9/src/test/java/com/baeldung/java9/reactive/BaeldungSubscriberImplIntegrationTest.java @@ -1,100 +1,100 @@ -package com.baeldung.java9.reactive; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import java.util.concurrent.ForkJoinPool; -import java.util.concurrent.SubmissionPublisher; -import java.util.concurrent.TimeUnit; -import java.util.stream.IntStream; - -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.Stopwatch; - -public class BaeldungSubscriberImplIntegrationTest { - - private static final int ITEM_SIZE = 10; - private SubmissionPublisher publisher; - private BaeldungSubscriberImpl subscriber; - - @Before - public void initialize() { - // create Publisher with max buffer capacity 3. - this.publisher = new SubmissionPublisher(ForkJoinPool.commonPool(), 3); - this.subscriber = new BaeldungSubscriberImpl(); - publisher.subscribe(subscriber); - } - - @Rule - public Stopwatch stopwatch = new Stopwatch() { - - }; - - @Test - public void testReactiveStreamCount() { - IntStream.range(0, ITEM_SIZE) - .forEach(item -> publisher.submit(item + "")); - publisher.close(); - - do { - // wait for subscribers to complete all processing. - try { - Thread.sleep(100); - } catch (InterruptedException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } while (!subscriber.isCompleted()); - - int count = subscriber.getCounter(); - - assertEquals(ITEM_SIZE, count); - } - - @Test - public void testReactiveStreamTime() { - IntStream.range(0, ITEM_SIZE) - .forEach(item -> publisher.submit(item + "")); - publisher.close(); - - do { - // wait for subscribers to complete all processing. - try { - Thread.sleep(100); - } catch (InterruptedException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } while (!subscriber.isCompleted()); - - // The runtime in seconds should be equal to the number of items. - assertTrue(stopwatch.runtime(TimeUnit.SECONDS) >= ITEM_SIZE); - } - - @Test - public void testReactiveStreamOffer() { - IntStream.range(0, ITEM_SIZE) - .forEach(item -> publisher.offer(item + "", (subscriber, string) -> { - // Returning false means this item will be dropped (no retry), if blocked. - return false; - })); - publisher.close(); - - do { - // wait for subscribers to complete all processing. - try { - Thread.sleep(100); - } catch (InterruptedException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } while (!subscriber.isCompleted()); - - int count = subscriber.getCounter(); - // Because 10 items were offered and the buffer capacity was 3, few items will not be processed. - assertTrue(ITEM_SIZE > count); - } - -} +package com.baeldung.java9.reactive; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import java.util.concurrent.ForkJoinPool; +import java.util.concurrent.SubmissionPublisher; +import java.util.concurrent.TimeUnit; +import java.util.stream.IntStream; + +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.Stopwatch; + +public class BaeldungSubscriberImplIntegrationTest { + + private static final int ITEM_SIZE = 10; + private SubmissionPublisher publisher; + private BaeldungSubscriberImpl subscriber; + + @Before + public void initialize() { + // create Publisher with max buffer capacity 3. + this.publisher = new SubmissionPublisher(ForkJoinPool.commonPool(), 3); + this.subscriber = new BaeldungSubscriberImpl(); + publisher.subscribe(subscriber); + } + + @Rule + public Stopwatch stopwatch = new Stopwatch() { + + }; + + @Test + public void testReactiveStreamCount() { + IntStream.range(0, ITEM_SIZE) + .forEach(item -> publisher.submit(item + "")); + publisher.close(); + + do { + // wait for subscribers to complete all processing. + try { + Thread.sleep(100); + } catch (InterruptedException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } while (!subscriber.isCompleted()); + + int count = subscriber.getCounter(); + + assertEquals(ITEM_SIZE, count); + } + + @Test + public void testReactiveStreamTime() { + IntStream.range(0, ITEM_SIZE) + .forEach(item -> publisher.submit(item + "")); + publisher.close(); + + do { + // wait for subscribers to complete all processing. + try { + Thread.sleep(100); + } catch (InterruptedException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } while (!subscriber.isCompleted()); + + // The runtime in seconds should be equal to the number of items. + assertTrue(stopwatch.runtime(TimeUnit.SECONDS) >= ITEM_SIZE); + } + + @Test + public void testReactiveStreamOffer() { + IntStream.range(0, ITEM_SIZE) + .forEach(item -> publisher.offer(item + "", (subscriber, string) -> { + // Returning false means this item will be dropped (no retry), if blocked. + return false; + })); + publisher.close(); + + do { + // wait for subscribers to complete all processing. + try { + Thread.sleep(100); + } catch (InterruptedException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } while (!subscriber.isCompleted()); + + int count = subscriber.getCounter(); + // Because 10 items were offered and the buffer capacity was 3, few items will not be processed. + assertTrue(ITEM_SIZE > count); + } + +} diff --git a/core-java-9/src/test/java/com/baeldung/java9/stackwalker/StackWalkerDemoUnitTest.java b/core-java-modules/core-java-9/src/test/java/com/baeldung/java9/stackwalker/StackWalkerDemoUnitTest.java similarity index 100% rename from core-java-9/src/test/java/com/baeldung/java9/stackwalker/StackWalkerDemoUnitTest.java rename to core-java-modules/core-java-9/src/test/java/com/baeldung/java9/stackwalker/StackWalkerDemoUnitTest.java diff --git a/core-java-9/src/test/java/com/baeldung/java9/streams.reactive/ReactiveStreamsTest.java b/core-java-modules/core-java-9/src/test/java/com/baeldung/java9/streams.reactive/ReactiveStreamsTest.java similarity index 100% rename from core-java-9/src/test/java/com/baeldung/java9/streams.reactive/ReactiveStreamsTest.java rename to core-java-modules/core-java-9/src/test/java/com/baeldung/java9/streams.reactive/ReactiveStreamsTest.java diff --git a/core-java-9/src/test/java/com/baeldung/java9/varhandles/VariableHandlesTest.java b/core-java-modules/core-java-9/src/test/java/com/baeldung/java9/varhandles/VariableHandlesTest.java similarity index 100% rename from core-java-9/src/test/java/com/baeldung/java9/varhandles/VariableHandlesTest.java rename to core-java-modules/core-java-9/src/test/java/com/baeldung/java9/varhandles/VariableHandlesTest.java diff --git a/core-java-9/src/test/java/com/baeldung/optionals/OptionalsTest.java b/core-java-modules/core-java-9/src/test/java/com/baeldung/optionals/OptionalsTest.java similarity index 100% rename from core-java-9/src/test/java/com/baeldung/optionals/OptionalsTest.java rename to core-java-modules/core-java-9/src/test/java/com/baeldung/optionals/OptionalsTest.java diff --git a/core-java-9/src/test/resources/.gitignore b/core-java-modules/core-java-9/src/test/resources/.gitignore similarity index 100% rename from core-java-9/src/test/resources/.gitignore rename to core-java-modules/core-java-9/src/test/resources/.gitignore diff --git a/core-java-lang-syntax/.gitignore b/core-java-modules/core-java-arrays/.gitignore similarity index 100% rename from core-java-lang-syntax/.gitignore rename to core-java-modules/core-java-arrays/.gitignore diff --git a/core-java-arrays/README.md b/core-java-modules/core-java-arrays/README.md similarity index 100% rename from core-java-arrays/README.md rename to core-java-modules/core-java-arrays/README.md diff --git a/core-java-arrays/pom.xml b/core-java-modules/core-java-arrays/pom.xml similarity index 99% rename from core-java-arrays/pom.xml rename to core-java-modules/core-java-arrays/pom.xml index ac9f7d08f0..b713c196b5 100644 --- a/core-java-arrays/pom.xml +++ b/core-java-modules/core-java-arrays/pom.xml @@ -11,7 +11,7 @@ com.baeldung parent-java 0.0.1-SNAPSHOT - ../parent-java + ../../parent-java diff --git a/core-java-arrays/src/main/java/com/baeldung/array/AddElementToEndOfArray.java b/core-java-modules/core-java-arrays/src/main/java/com/baeldung/array/AddElementToEndOfArray.java similarity index 100% rename from core-java-arrays/src/main/java/com/baeldung/array/AddElementToEndOfArray.java rename to core-java-modules/core-java-arrays/src/main/java/com/baeldung/array/AddElementToEndOfArray.java diff --git a/core-java-arrays/src/main/java/com/baeldung/array/ArrayBenchmarkRunner.java b/core-java-modules/core-java-arrays/src/main/java/com/baeldung/array/ArrayBenchmarkRunner.java similarity index 100% rename from core-java-arrays/src/main/java/com/baeldung/array/ArrayBenchmarkRunner.java rename to core-java-modules/core-java-arrays/src/main/java/com/baeldung/array/ArrayBenchmarkRunner.java diff --git a/core-java-arrays/src/main/java/com/baeldung/array/ArrayInitializer.java b/core-java-modules/core-java-arrays/src/main/java/com/baeldung/array/ArrayInitializer.java similarity index 100% rename from core-java-arrays/src/main/java/com/baeldung/array/ArrayInitializer.java rename to core-java-modules/core-java-arrays/src/main/java/com/baeldung/array/ArrayInitializer.java diff --git a/core-java-arrays/src/main/java/com/baeldung/array/ArrayInverter.java b/core-java-modules/core-java-arrays/src/main/java/com/baeldung/array/ArrayInverter.java similarity index 100% rename from core-java-arrays/src/main/java/com/baeldung/array/ArrayInverter.java rename to core-java-modules/core-java-arrays/src/main/java/com/baeldung/array/ArrayInverter.java diff --git a/core-java-arrays/src/main/java/com/baeldung/array/ArrayReferenceGuide.java b/core-java-modules/core-java-arrays/src/main/java/com/baeldung/array/ArrayReferenceGuide.java similarity index 100% rename from core-java-arrays/src/main/java/com/baeldung/array/ArrayReferenceGuide.java rename to core-java-modules/core-java-arrays/src/main/java/com/baeldung/array/ArrayReferenceGuide.java diff --git a/core-java-arrays/src/main/java/com/baeldung/array/Find2ndLargestInArray.java b/core-java-modules/core-java-arrays/src/main/java/com/baeldung/array/Find2ndLargestInArray.java similarity index 100% rename from core-java-arrays/src/main/java/com/baeldung/array/Find2ndLargestInArray.java rename to core-java-modules/core-java-arrays/src/main/java/com/baeldung/array/Find2ndLargestInArray.java diff --git a/core-java-arrays/src/main/java/com/baeldung/array/FindElementInArray.java b/core-java-modules/core-java-arrays/src/main/java/com/baeldung/array/FindElementInArray.java similarity index 100% rename from core-java-arrays/src/main/java/com/baeldung/array/FindElementInArray.java rename to core-java-modules/core-java-arrays/src/main/java/com/baeldung/array/FindElementInArray.java diff --git a/core-java-arrays/src/main/java/com/baeldung/array/JaggedArray.java b/core-java-modules/core-java-arrays/src/main/java/com/baeldung/array/JaggedArray.java similarity index 100% rename from core-java-arrays/src/main/java/com/baeldung/array/JaggedArray.java rename to core-java-modules/core-java-arrays/src/main/java/com/baeldung/array/JaggedArray.java diff --git a/core-java-arrays/src/main/java/com/baeldung/array/SearchArrayUnitTest.java b/core-java-modules/core-java-arrays/src/main/java/com/baeldung/array/SearchArrayUnitTest.java similarity index 100% rename from core-java-arrays/src/main/java/com/baeldung/array/SearchArrayUnitTest.java rename to core-java-modules/core-java-arrays/src/main/java/com/baeldung/array/SearchArrayUnitTest.java diff --git a/core-java-arrays/src/main/java/com/baeldung/array/SumAndAverageInArray.java b/core-java-modules/core-java-arrays/src/main/java/com/baeldung/array/SumAndAverageInArray.java similarity index 100% rename from core-java-arrays/src/main/java/com/baeldung/array/SumAndAverageInArray.java rename to core-java-modules/core-java-arrays/src/main/java/com/baeldung/array/SumAndAverageInArray.java diff --git a/core-java-arrays/src/main/java/com/baeldung/array/conversions/FloatToByteArray.java b/core-java-modules/core-java-arrays/src/main/java/com/baeldung/array/conversions/FloatToByteArray.java similarity index 100% rename from core-java-arrays/src/main/java/com/baeldung/array/conversions/FloatToByteArray.java rename to core-java-modules/core-java-arrays/src/main/java/com/baeldung/array/conversions/FloatToByteArray.java diff --git a/core-java-arrays/src/main/java/com/baeldung/array/operations/ArrayOperations.java b/core-java-modules/core-java-arrays/src/main/java/com/baeldung/array/operations/ArrayOperations.java similarity index 100% rename from core-java-arrays/src/main/java/com/baeldung/array/operations/ArrayOperations.java rename to core-java-modules/core-java-arrays/src/main/java/com/baeldung/array/operations/ArrayOperations.java diff --git a/core-java-arrays/src/main/java/com/baeldung/arraycopy/model/Address.java b/core-java-modules/core-java-arrays/src/main/java/com/baeldung/arraycopy/model/Address.java similarity index 100% rename from core-java-arrays/src/main/java/com/baeldung/arraycopy/model/Address.java rename to core-java-modules/core-java-arrays/src/main/java/com/baeldung/arraycopy/model/Address.java diff --git a/core-java-arrays/src/main/java/com/baeldung/arraycopy/model/Employee.java b/core-java-modules/core-java-arrays/src/main/java/com/baeldung/arraycopy/model/Employee.java similarity index 100% rename from core-java-arrays/src/main/java/com/baeldung/arraycopy/model/Employee.java rename to core-java-modules/core-java-arrays/src/main/java/com/baeldung/arraycopy/model/Employee.java diff --git a/core-java-arrays/src/main/java/com/baeldung/arrays/ParallelPrefixBenchmark.java b/core-java-modules/core-java-arrays/src/main/java/com/baeldung/arrays/ParallelPrefixBenchmark.java similarity index 100% rename from core-java-arrays/src/main/java/com/baeldung/arrays/ParallelPrefixBenchmark.java rename to core-java-modules/core-java-arrays/src/main/java/com/baeldung/arrays/ParallelPrefixBenchmark.java diff --git a/core-java-arrays/src/test/java/com/baeldung/array/AddElementToEndOfArrayUnitTest.java b/core-java-modules/core-java-arrays/src/test/java/com/baeldung/array/AddElementToEndOfArrayUnitTest.java similarity index 100% rename from core-java-arrays/src/test/java/com/baeldung/array/AddElementToEndOfArrayUnitTest.java rename to core-java-modules/core-java-arrays/src/test/java/com/baeldung/array/AddElementToEndOfArrayUnitTest.java diff --git a/core-java-arrays/src/test/java/com/baeldung/array/ArrayInitializerUnitTest.java b/core-java-modules/core-java-arrays/src/test/java/com/baeldung/array/ArrayInitializerUnitTest.java similarity index 100% rename from core-java-arrays/src/test/java/com/baeldung/array/ArrayInitializerUnitTest.java rename to core-java-modules/core-java-arrays/src/test/java/com/baeldung/array/ArrayInitializerUnitTest.java diff --git a/core-java-arrays/src/test/java/com/baeldung/array/ArrayInverterUnitTest.java b/core-java-modules/core-java-arrays/src/test/java/com/baeldung/array/ArrayInverterUnitTest.java similarity index 100% rename from core-java-arrays/src/test/java/com/baeldung/array/ArrayInverterUnitTest.java rename to core-java-modules/core-java-arrays/src/test/java/com/baeldung/array/ArrayInverterUnitTest.java diff --git a/core-java-arrays/src/test/java/com/baeldung/array/Find2ndLargestInArrayUnitTest.java b/core-java-modules/core-java-arrays/src/test/java/com/baeldung/array/Find2ndLargestInArrayUnitTest.java similarity index 100% rename from core-java-arrays/src/test/java/com/baeldung/array/Find2ndLargestInArrayUnitTest.java rename to core-java-modules/core-java-arrays/src/test/java/com/baeldung/array/Find2ndLargestInArrayUnitTest.java diff --git a/core-java-arrays/src/test/java/com/baeldung/array/FindElementInArrayUnitTest.java b/core-java-modules/core-java-arrays/src/test/java/com/baeldung/array/FindElementInArrayUnitTest.java similarity index 100% rename from core-java-arrays/src/test/java/com/baeldung/array/FindElementInArrayUnitTest.java rename to core-java-modules/core-java-arrays/src/test/java/com/baeldung/array/FindElementInArrayUnitTest.java diff --git a/core-java-arrays/src/test/java/com/baeldung/array/JaggedArrayUnitTest.java b/core-java-modules/core-java-arrays/src/test/java/com/baeldung/array/JaggedArrayUnitTest.java similarity index 100% rename from core-java-arrays/src/test/java/com/baeldung/array/JaggedArrayUnitTest.java rename to core-java-modules/core-java-arrays/src/test/java/com/baeldung/array/JaggedArrayUnitTest.java diff --git a/core-java-arrays/src/test/java/com/baeldung/array/SumAndAverageInArrayUnitTest.java b/core-java-modules/core-java-arrays/src/test/java/com/baeldung/array/SumAndAverageInArrayUnitTest.java similarity index 100% rename from core-java-arrays/src/test/java/com/baeldung/array/SumAndAverageInArrayUnitTest.java rename to core-java-modules/core-java-arrays/src/test/java/com/baeldung/array/SumAndAverageInArrayUnitTest.java diff --git a/core-java-arrays/src/test/java/com/baeldung/array/conversions/FloatToByteArrayUnitTest.java b/core-java-modules/core-java-arrays/src/test/java/com/baeldung/array/conversions/FloatToByteArrayUnitTest.java similarity index 100% rename from core-java-arrays/src/test/java/com/baeldung/array/conversions/FloatToByteArrayUnitTest.java rename to core-java-modules/core-java-arrays/src/test/java/com/baeldung/array/conversions/FloatToByteArrayUnitTest.java diff --git a/core-java-arrays/src/test/java/com/baeldung/array/operations/ArrayOperationsUnitTest.java b/core-java-modules/core-java-arrays/src/test/java/com/baeldung/array/operations/ArrayOperationsUnitTest.java similarity index 100% rename from core-java-arrays/src/test/java/com/baeldung/array/operations/ArrayOperationsUnitTest.java rename to core-java-modules/core-java-arrays/src/test/java/com/baeldung/array/operations/ArrayOperationsUnitTest.java diff --git a/core-java-arrays/src/test/java/com/baeldung/array/operations/IntersectionUnitTest.java b/core-java-modules/core-java-arrays/src/test/java/com/baeldung/array/operations/IntersectionUnitTest.java similarity index 100% rename from core-java-arrays/src/test/java/com/baeldung/array/operations/IntersectionUnitTest.java rename to core-java-modules/core-java-arrays/src/test/java/com/baeldung/array/operations/IntersectionUnitTest.java diff --git a/core-java-arrays/src/test/java/com/baeldung/arraycopy/ArrayCopyUtilUnitTest.java b/core-java-modules/core-java-arrays/src/test/java/com/baeldung/arraycopy/ArrayCopyUtilUnitTest.java similarity index 100% rename from core-java-arrays/src/test/java/com/baeldung/arraycopy/ArrayCopyUtilUnitTest.java rename to core-java-modules/core-java-arrays/src/test/java/com/baeldung/arraycopy/ArrayCopyUtilUnitTest.java diff --git a/core-java-arrays/src/test/java/com/baeldung/arrays/ArraysUnitTest.java b/core-java-modules/core-java-arrays/src/test/java/com/baeldung/arrays/ArraysUnitTest.java similarity index 100% rename from core-java-arrays/src/test/java/com/baeldung/arrays/ArraysUnitTest.java rename to core-java-modules/core-java-arrays/src/test/java/com/baeldung/arrays/ArraysUnitTest.java diff --git a/core-java-arrays/src/test/java/com/baeldung/sort/ArraySortUnitTest.java b/core-java-modules/core-java-arrays/src/test/java/com/baeldung/sort/ArraySortUnitTest.java similarity index 100% rename from core-java-arrays/src/test/java/com/baeldung/sort/ArraySortUnitTest.java rename to core-java-modules/core-java-arrays/src/test/java/com/baeldung/sort/ArraySortUnitTest.java diff --git a/core-java-collections-list/README.md b/core-java-modules/core-java-collections-list/README.md similarity index 100% rename from core-java-collections-list/README.md rename to core-java-modules/core-java-collections-list/README.md diff --git a/core-java-collections-list/pom.xml b/core-java-modules/core-java-collections-list/pom.xml similarity index 98% rename from core-java-collections-list/pom.xml rename to core-java-modules/core-java-collections-list/pom.xml index 217278bdf6..1a0b1615c8 100644 --- a/core-java-collections-list/pom.xml +++ b/core-java-modules/core-java-collections-list/pom.xml @@ -10,7 +10,7 @@ com.baeldung parent-java 0.0.1-SNAPSHOT - ../parent-java + ../../parent-java diff --git a/core-java-collections-list/src/main/java/com/baeldung/allequalelements/VerifyAllEqualListElements.java b/core-java-modules/core-java-collections-list/src/main/java/com/baeldung/allequalelements/VerifyAllEqualListElements.java similarity index 100% rename from core-java-collections-list/src/main/java/com/baeldung/allequalelements/VerifyAllEqualListElements.java rename to core-java-modules/core-java-collections-list/src/main/java/com/baeldung/allequalelements/VerifyAllEqualListElements.java diff --git a/core-java-collections-list/src/main/java/com/baeldung/classcastexception/ClassCastException.java b/core-java-modules/core-java-collections-list/src/main/java/com/baeldung/classcastexception/ClassCastException.java similarity index 100% rename from core-java-collections-list/src/main/java/com/baeldung/classcastexception/ClassCastException.java rename to core-java-modules/core-java-collections-list/src/main/java/com/baeldung/classcastexception/ClassCastException.java diff --git a/core-java-collections-list/src/main/java/com/baeldung/collection/filtering/Employee.java b/core-java-modules/core-java-collections-list/src/main/java/com/baeldung/collection/filtering/Employee.java similarity index 100% rename from core-java-collections-list/src/main/java/com/baeldung/collection/filtering/Employee.java rename to core-java-modules/core-java-collections-list/src/main/java/com/baeldung/collection/filtering/Employee.java diff --git a/core-java-collections-list/src/main/java/com/baeldung/findanelement/Customer.java b/core-java-modules/core-java-collections-list/src/main/java/com/baeldung/findanelement/Customer.java similarity index 100% rename from core-java-collections-list/src/main/java/com/baeldung/findanelement/Customer.java rename to core-java-modules/core-java-collections-list/src/main/java/com/baeldung/findanelement/Customer.java diff --git a/core-java-collections-list/src/main/java/com/baeldung/findanelement/FindACustomerInGivenList.java b/core-java-modules/core-java-collections-list/src/main/java/com/baeldung/findanelement/FindACustomerInGivenList.java similarity index 100% rename from core-java-collections-list/src/main/java/com/baeldung/findanelement/FindACustomerInGivenList.java rename to core-java-modules/core-java-collections-list/src/main/java/com/baeldung/findanelement/FindACustomerInGivenList.java diff --git a/core-java-collections-list/src/main/java/com/baeldung/java/list/CopyListService.java b/core-java-modules/core-java-collections-list/src/main/java/com/baeldung/java/list/CopyListService.java similarity index 100% rename from core-java-collections-list/src/main/java/com/baeldung/java/list/CopyListService.java rename to core-java-modules/core-java-collections-list/src/main/java/com/baeldung/java/list/CopyListService.java diff --git a/core-java-collections-list/src/main/java/com/baeldung/java/list/CustomList.java b/core-java-modules/core-java-collections-list/src/main/java/com/baeldung/java/list/CustomList.java similarity index 100% rename from core-java-collections-list/src/main/java/com/baeldung/java/list/CustomList.java rename to core-java-modules/core-java-collections-list/src/main/java/com/baeldung/java/list/CustomList.java diff --git a/core-java-collections-list/src/main/java/com/baeldung/java/list/Flower.java b/core-java-modules/core-java-collections-list/src/main/java/com/baeldung/java/list/Flower.java similarity index 100% rename from core-java-collections-list/src/main/java/com/baeldung/java/list/Flower.java rename to core-java-modules/core-java-collections-list/src/main/java/com/baeldung/java/list/Flower.java diff --git a/core-java-collections-list/src/main/java/com/baeldung/java/list/ReverseIterator.java b/core-java-modules/core-java-collections-list/src/main/java/com/baeldung/java/list/ReverseIterator.java similarity index 100% rename from core-java-collections-list/src/main/java/com/baeldung/java/list/ReverseIterator.java rename to core-java-modules/core-java-collections-list/src/main/java/com/baeldung/java/list/ReverseIterator.java diff --git a/core-java-collections-list/src/main/java/com/baeldung/java/list/WaysToIterate.java b/core-java-modules/core-java-collections-list/src/main/java/com/baeldung/java/list/WaysToIterate.java similarity index 100% rename from core-java-collections-list/src/main/java/com/baeldung/java/list/WaysToIterate.java rename to core-java-modules/core-java-collections-list/src/main/java/com/baeldung/java/list/WaysToIterate.java diff --git a/core-java-collections-list/src/main/java/com/baeldung/java_8_features/Car.java b/core-java-modules/core-java-collections-list/src/main/java/com/baeldung/java_8_features/Car.java similarity index 100% rename from core-java-collections-list/src/main/java/com/baeldung/java_8_features/Car.java rename to core-java-modules/core-java-collections-list/src/main/java/com/baeldung/java_8_features/Car.java diff --git a/core-java-collections-list/src/main/java/com/baeldung/java_8_features/Person.java b/core-java-modules/core-java-collections-list/src/main/java/com/baeldung/java_8_features/Person.java similarity index 100% rename from core-java-collections-list/src/main/java/com/baeldung/java_8_features/Person.java rename to core-java-modules/core-java-collections-list/src/main/java/com/baeldung/java_8_features/Person.java diff --git a/core-java-collections-list/src/main/java/com/baeldung/list/Flower.java b/core-java-modules/core-java-collections-list/src/main/java/com/baeldung/list/Flower.java similarity index 100% rename from core-java-collections-list/src/main/java/com/baeldung/list/Flower.java rename to core-java-modules/core-java-collections-list/src/main/java/com/baeldung/list/Flower.java diff --git a/core-java-collections-list/src/main/java/com/baeldung/list/listoflist/Pen.java b/core-java-modules/core-java-collections-list/src/main/java/com/baeldung/list/listoflist/Pen.java similarity index 100% rename from core-java-collections-list/src/main/java/com/baeldung/list/listoflist/Pen.java rename to core-java-modules/core-java-collections-list/src/main/java/com/baeldung/list/listoflist/Pen.java diff --git a/core-java-collections-list/src/main/java/com/baeldung/list/listoflist/Pencil.java b/core-java-modules/core-java-collections-list/src/main/java/com/baeldung/list/listoflist/Pencil.java similarity index 100% rename from core-java-collections-list/src/main/java/com/baeldung/list/listoflist/Pencil.java rename to core-java-modules/core-java-collections-list/src/main/java/com/baeldung/list/listoflist/Pencil.java diff --git a/core-java-collections-list/src/main/java/com/baeldung/list/listoflist/Rubber.java b/core-java-modules/core-java-collections-list/src/main/java/com/baeldung/list/listoflist/Rubber.java similarity index 100% rename from core-java-collections-list/src/main/java/com/baeldung/list/listoflist/Rubber.java rename to core-java-modules/core-java-collections-list/src/main/java/com/baeldung/list/listoflist/Rubber.java diff --git a/core-java-collections-list/src/main/java/com/baeldung/list/listoflist/Stationery.java b/core-java-modules/core-java-collections-list/src/main/java/com/baeldung/list/listoflist/Stationery.java similarity index 100% rename from core-java-collections-list/src/main/java/com/baeldung/list/listoflist/Stationery.java rename to core-java-modules/core-java-collections-list/src/main/java/com/baeldung/list/listoflist/Stationery.java diff --git a/core-java-collections-list/src/main/java/com/baeldung/list/multidimensional/ArrayListOfArrayList.java b/core-java-modules/core-java-collections-list/src/main/java/com/baeldung/list/multidimensional/ArrayListOfArrayList.java similarity index 100% rename from core-java-collections-list/src/main/java/com/baeldung/list/multidimensional/ArrayListOfArrayList.java rename to core-java-modules/core-java-collections-list/src/main/java/com/baeldung/list/multidimensional/ArrayListOfArrayList.java diff --git a/core-java-collections-list/src/main/java/com/baeldung/list/multidimensional/ThreeDimensionalArrayList.java b/core-java-modules/core-java-collections-list/src/main/java/com/baeldung/list/multidimensional/ThreeDimensionalArrayList.java similarity index 100% rename from core-java-collections-list/src/main/java/com/baeldung/list/multidimensional/ThreeDimensionalArrayList.java rename to core-java-modules/core-java-collections-list/src/main/java/com/baeldung/list/multidimensional/ThreeDimensionalArrayList.java diff --git a/core-java-collections-list/src/main/java/com/baeldung/list/primitive/PrimitiveCollections.java b/core-java-modules/core-java-collections-list/src/main/java/com/baeldung/list/primitive/PrimitiveCollections.java similarity index 100% rename from core-java-collections-list/src/main/java/com/baeldung/list/primitive/PrimitiveCollections.java rename to core-java-modules/core-java-collections-list/src/main/java/com/baeldung/list/primitive/PrimitiveCollections.java diff --git a/core-java-collections-list/src/main/java/com/baeldung/list/primitive/PrimitivesListPerformance.java b/core-java-modules/core-java-collections-list/src/main/java/com/baeldung/list/primitive/PrimitivesListPerformance.java similarity index 100% rename from core-java-collections-list/src/main/java/com/baeldung/list/primitive/PrimitivesListPerformance.java rename to core-java-modules/core-java-collections-list/src/main/java/com/baeldung/list/primitive/PrimitivesListPerformance.java diff --git a/core-java-collections-list/src/main/java/com/baeldung/list/removeall/RemoveAll.java b/core-java-modules/core-java-collections-list/src/main/java/com/baeldung/list/removeall/RemoveAll.java similarity index 100% rename from core-java-collections-list/src/main/java/com/baeldung/list/removeall/RemoveAll.java rename to core-java-modules/core-java-collections-list/src/main/java/com/baeldung/list/removeall/RemoveAll.java diff --git a/core-java-collections-list/src/main/resources/logback.xml b/core-java-modules/core-java-collections-list/src/main/resources/logback.xml similarity index 100% rename from core-java-collections-list/src/main/resources/logback.xml rename to core-java-modules/core-java-collections-list/src/main/resources/logback.xml diff --git a/core-java-collections-list/src/test/java/com/baeldung/allequalelements/VerifyAllEqualListElementsUnitTest.java b/core-java-modules/core-java-collections-list/src/test/java/com/baeldung/allequalelements/VerifyAllEqualListElementsUnitTest.java similarity index 100% rename from core-java-collections-list/src/test/java/com/baeldung/allequalelements/VerifyAllEqualListElementsUnitTest.java rename to core-java-modules/core-java-collections-list/src/test/java/com/baeldung/allequalelements/VerifyAllEqualListElementsUnitTest.java diff --git a/core-java-collections-list/src/test/java/com/baeldung/array/converter/ArrayConvertToListUnitTest.java b/core-java-modules/core-java-collections-list/src/test/java/com/baeldung/array/converter/ArrayConvertToListUnitTest.java similarity index 100% rename from core-java-collections-list/src/test/java/com/baeldung/array/converter/ArrayConvertToListUnitTest.java rename to core-java-modules/core-java-collections-list/src/test/java/com/baeldung/array/converter/ArrayConvertToListUnitTest.java diff --git a/core-java-collections-list/src/test/java/com/baeldung/collection/ClearVsRemoveAllUnitTest.java b/core-java-modules/core-java-collections-list/src/test/java/com/baeldung/collection/ClearVsRemoveAllUnitTest.java similarity index 100% rename from core-java-collections-list/src/test/java/com/baeldung/collection/ClearVsRemoveAllUnitTest.java rename to core-java-modules/core-java-collections-list/src/test/java/com/baeldung/collection/ClearVsRemoveAllUnitTest.java diff --git a/core-java-collections-list/src/test/java/com/baeldung/collection/CollectionsEmpty.java b/core-java-modules/core-java-collections-list/src/test/java/com/baeldung/collection/CollectionsEmpty.java similarity index 100% rename from core-java-collections-list/src/test/java/com/baeldung/collection/CollectionsEmpty.java rename to core-java-modules/core-java-collections-list/src/test/java/com/baeldung/collection/CollectionsEmpty.java diff --git a/core-java-collections-list/src/test/java/com/baeldung/collection/filtering/CollectionFilteringUnitTest.java b/core-java-modules/core-java-collections-list/src/test/java/com/baeldung/collection/filtering/CollectionFilteringUnitTest.java similarity index 100% rename from core-java-collections-list/src/test/java/com/baeldung/collection/filtering/CollectionFilteringUnitTest.java rename to core-java-modules/core-java-collections-list/src/test/java/com/baeldung/collection/filtering/CollectionFilteringUnitTest.java diff --git a/core-java-collections-list/src/test/java/com/baeldung/findItems/FindItemsBasedOnOtherStreamUnitTest.java b/core-java-modules/core-java-collections-list/src/test/java/com/baeldung/findItems/FindItemsBasedOnOtherStreamUnitTest.java similarity index 100% rename from core-java-collections-list/src/test/java/com/baeldung/findItems/FindItemsBasedOnOtherStreamUnitTest.java rename to core-java-modules/core-java-collections-list/src/test/java/com/baeldung/findItems/FindItemsBasedOnOtherStreamUnitTest.java diff --git a/core-java-collections-list/src/test/java/com/baeldung/findanelement/FindACustomerInGivenListUnitTest.java b/core-java-modules/core-java-collections-list/src/test/java/com/baeldung/findanelement/FindACustomerInGivenListUnitTest.java similarity index 100% rename from core-java-collections-list/src/test/java/com/baeldung/findanelement/FindACustomerInGivenListUnitTest.java rename to core-java-modules/core-java-collections-list/src/test/java/com/baeldung/findanelement/FindACustomerInGivenListUnitTest.java diff --git a/core-java-collections-list/src/test/java/com/baeldung/java/list/CopyListServiceUnitTest.java b/core-java-modules/core-java-collections-list/src/test/java/com/baeldung/java/list/CopyListServiceUnitTest.java similarity index 100% rename from core-java-collections-list/src/test/java/com/baeldung/java/list/CopyListServiceUnitTest.java rename to core-java-modules/core-java-collections-list/src/test/java/com/baeldung/java/list/CopyListServiceUnitTest.java diff --git a/core-java-collections-list/src/test/java/com/baeldung/java/list/CustomListUnitTest.java b/core-java-modules/core-java-collections-list/src/test/java/com/baeldung/java/list/CustomListUnitTest.java similarity index 100% rename from core-java-collections-list/src/test/java/com/baeldung/java/list/CustomListUnitTest.java rename to core-java-modules/core-java-collections-list/src/test/java/com/baeldung/java/list/CustomListUnitTest.java diff --git a/core-java-collections-list/src/test/java/com/baeldung/java/list/ReverseIteratorUnitTest.java b/core-java-modules/core-java-collections-list/src/test/java/com/baeldung/java/list/ReverseIteratorUnitTest.java similarity index 100% rename from core-java-collections-list/src/test/java/com/baeldung/java/list/ReverseIteratorUnitTest.java rename to core-java-modules/core-java-collections-list/src/test/java/com/baeldung/java/list/ReverseIteratorUnitTest.java diff --git a/core-java-collections-list/src/test/java/com/baeldung/java/list/WaysToIterateUnitTest.java b/core-java-modules/core-java-collections-list/src/test/java/com/baeldung/java/list/WaysToIterateUnitTest.java similarity index 100% rename from core-java-collections-list/src/test/java/com/baeldung/java/list/WaysToIterateUnitTest.java rename to core-java-modules/core-java-collections-list/src/test/java/com/baeldung/java/list/WaysToIterateUnitTest.java diff --git a/core-java-collections-list/src/test/java/com/baeldung/java/listInitialization/ListInitializationUnitTest.java b/core-java-modules/core-java-collections-list/src/test/java/com/baeldung/java/listInitialization/ListInitializationUnitTest.java similarity index 100% rename from core-java-collections-list/src/test/java/com/baeldung/java/listInitialization/ListInitializationUnitTest.java rename to core-java-modules/core-java-collections-list/src/test/java/com/baeldung/java/listInitialization/ListInitializationUnitTest.java diff --git a/core-java-collections-list/src/test/java/com/baeldung/java8/Java8CollectionCleanupUnitTest.java b/core-java-modules/core-java-collections-list/src/test/java/com/baeldung/java8/Java8CollectionCleanupUnitTest.java similarity index 100% rename from core-java-collections-list/src/test/java/com/baeldung/java8/Java8CollectionCleanupUnitTest.java rename to core-java-modules/core-java-collections-list/src/test/java/com/baeldung/java8/Java8CollectionCleanupUnitTest.java diff --git a/core-java-collections-list/src/test/java/com/baeldung/java8/Java8MaxMinUnitTest.java b/core-java-modules/core-java-collections-list/src/test/java/com/baeldung/java8/Java8MaxMinUnitTest.java similarity index 100% rename from core-java-collections-list/src/test/java/com/baeldung/java8/Java8MaxMinUnitTest.java rename to core-java-modules/core-java-collections-list/src/test/java/com/baeldung/java8/Java8MaxMinUnitTest.java diff --git a/core-java-collections-list/src/test/java/com/baeldung/list/AddElementsUnitTest.java b/core-java-modules/core-java-collections-list/src/test/java/com/baeldung/list/AddElementsUnitTest.java similarity index 100% rename from core-java-collections-list/src/test/java/com/baeldung/list/AddElementsUnitTest.java rename to core-java-modules/core-java-collections-list/src/test/java/com/baeldung/list/AddElementsUnitTest.java diff --git a/core-java-collections-list/src/test/java/com/baeldung/list/flattennestedlist/FlattenNestedListUnitTest.java b/core-java-modules/core-java-collections-list/src/test/java/com/baeldung/list/flattennestedlist/FlattenNestedListUnitTest.java similarity index 100% rename from core-java-collections-list/src/test/java/com/baeldung/list/flattennestedlist/FlattenNestedListUnitTest.java rename to core-java-modules/core-java-collections-list/src/test/java/com/baeldung/list/flattennestedlist/FlattenNestedListUnitTest.java diff --git a/core-java-collections-list/src/test/java/com/baeldung/list/listoflist/AddElementsToListUnitTest.java b/core-java-modules/core-java-collections-list/src/test/java/com/baeldung/list/listoflist/AddElementsToListUnitTest.java similarity index 100% rename from core-java-collections-list/src/test/java/com/baeldung/list/listoflist/AddElementsToListUnitTest.java rename to core-java-modules/core-java-collections-list/src/test/java/com/baeldung/list/listoflist/AddElementsToListUnitTest.java diff --git a/core-java-collections-list/src/test/java/com/baeldung/list/listoflist/ListOfListsUnitTest.java b/core-java-modules/core-java-collections-list/src/test/java/com/baeldung/list/listoflist/ListOfListsUnitTest.java similarity index 100% rename from core-java-collections-list/src/test/java/com/baeldung/list/listoflist/ListOfListsUnitTest.java rename to core-java-modules/core-java-collections-list/src/test/java/com/baeldung/list/listoflist/ListOfListsUnitTest.java diff --git a/core-java-collections-list/src/test/java/com/baeldung/list/removeall/RemoveAllUnitTest.java b/core-java-modules/core-java-collections-list/src/test/java/com/baeldung/list/removeall/RemoveAllUnitTest.java similarity index 100% rename from core-java-collections-list/src/test/java/com/baeldung/list/removeall/RemoveAllUnitTest.java rename to core-java-modules/core-java-collections-list/src/test/java/com/baeldung/list/removeall/RemoveAllUnitTest.java diff --git a/core-java-collections-list/src/test/java/com/baeldung/list/removefirst/RemoveFirstElementUnitTest.java b/core-java-modules/core-java-collections-list/src/test/java/com/baeldung/list/removefirst/RemoveFirstElementUnitTest.java similarity index 100% rename from core-java-collections-list/src/test/java/com/baeldung/list/removefirst/RemoveFirstElementUnitTest.java rename to core-java-modules/core-java-collections-list/src/test/java/com/baeldung/list/removefirst/RemoveFirstElementUnitTest.java diff --git a/core-java-collections-list/src/test/java/org/baeldung/RandomListElementUnitTest.java b/core-java-modules/core-java-collections-list/src/test/java/org/baeldung/RandomListElementUnitTest.java similarity index 100% rename from core-java-collections-list/src/test/java/org/baeldung/RandomListElementUnitTest.java rename to core-java-modules/core-java-collections-list/src/test/java/org/baeldung/RandomListElementUnitTest.java diff --git a/core-java-collections-list/src/test/java/org/baeldung/java/collections/ArrayListUnitTest.java b/core-java-modules/core-java-collections-list/src/test/java/org/baeldung/java/collections/ArrayListUnitTest.java similarity index 100% rename from core-java-collections-list/src/test/java/org/baeldung/java/collections/ArrayListUnitTest.java rename to core-java-modules/core-java-collections-list/src/test/java/org/baeldung/java/collections/ArrayListUnitTest.java diff --git a/core-java-collections-list/src/test/java/org/baeldung/java/collections/CoreJavaCollectionsUnitTest.java b/core-java-modules/core-java-collections-list/src/test/java/org/baeldung/java/collections/CoreJavaCollectionsUnitTest.java similarity index 100% rename from core-java-collections-list/src/test/java/org/baeldung/java/collections/CoreJavaCollectionsUnitTest.java rename to core-java-modules/core-java-collections-list/src/test/java/org/baeldung/java/collections/CoreJavaCollectionsUnitTest.java diff --git a/core-java-collections-list/src/test/java/org/baeldung/java/collections/JavaCollectionCleanupUnitTest.java b/core-java-modules/core-java-collections-list/src/test/java/org/baeldung/java/collections/JavaCollectionCleanupUnitTest.java similarity index 100% rename from core-java-collections-list/src/test/java/org/baeldung/java/collections/JavaCollectionCleanupUnitTest.java rename to core-java-modules/core-java-collections-list/src/test/java/org/baeldung/java/collections/JavaCollectionCleanupUnitTest.java diff --git a/core-java-collections-list/src/test/java/org/baeldung/java/lists/ListAssertJUnitTest.java b/core-java-modules/core-java-collections-list/src/test/java/org/baeldung/java/lists/ListAssertJUnitTest.java similarity index 100% rename from core-java-collections-list/src/test/java/org/baeldung/java/lists/ListAssertJUnitTest.java rename to core-java-modules/core-java-collections-list/src/test/java/org/baeldung/java/lists/ListAssertJUnitTest.java diff --git a/core-java-collections-list/src/test/java/org/baeldung/java/lists/ListJUnitTest.java b/core-java-modules/core-java-collections-list/src/test/java/org/baeldung/java/lists/ListJUnitTest.java similarity index 100% rename from core-java-collections-list/src/test/java/org/baeldung/java/lists/ListJUnitTest.java rename to core-java-modules/core-java-collections-list/src/test/java/org/baeldung/java/lists/ListJUnitTest.java diff --git a/core-java-collections-list/src/test/java/org/baeldung/java/lists/ListTestNgUnitTest.java b/core-java-modules/core-java-collections-list/src/test/java/org/baeldung/java/lists/ListTestNgUnitTest.java similarity index 100% rename from core-java-collections-list/src/test/java/org/baeldung/java/lists/ListTestNgUnitTest.java rename to core-java-modules/core-java-collections-list/src/test/java/org/baeldung/java/lists/ListTestNgUnitTest.java diff --git a/core-java-collections-list/src/test/java/org/baeldung/java/lists/README.md b/core-java-modules/core-java-collections-list/src/test/java/org/baeldung/java/lists/README.md similarity index 100% rename from core-java-collections-list/src/test/java/org/baeldung/java/lists/README.md rename to core-java-modules/core-java-collections-list/src/test/java/org/baeldung/java/lists/README.md diff --git a/core-java-collections-set/README.md b/core-java-modules/core-java-collections-set/README.md similarity index 100% rename from core-java-collections-set/README.md rename to core-java-modules/core-java-collections-set/README.md diff --git a/core-java-collections-set/pom.xml b/core-java-modules/core-java-collections-set/pom.xml similarity index 93% rename from core-java-collections-set/pom.xml rename to core-java-modules/core-java-collections-set/pom.xml index d5f7937645..2a930efde8 100644 --- a/core-java-collections-set/pom.xml +++ b/core-java-modules/core-java-collections-set/pom.xml @@ -1,33 +1,33 @@ - - 4.0.0 - core-java-collections-set - 0.1.0-SNAPSHOT - core-java-collections-set - jar - - - com.baeldung - parent-java - 0.0.1-SNAPSHOT - ../parent-java - - - - - com.google.guava - guava - ${guava.version} - - - org.apache.commons - commons-collections4 - ${commons-collections4.version} - - - - - 4.3 - 27.1-jre - - + + 4.0.0 + core-java-collections-set + 0.1.0-SNAPSHOT + core-java-collections-set + jar + + + com.baeldung + parent-java + 0.0.1-SNAPSHOT + ../../parent-java + + + + + com.google.guava + guava + ${guava.version} + + + org.apache.commons + commons-collections4 + ${commons-collections4.version} + + + + + 4.3 + 27.1-jre + + diff --git a/core-java-collections-set/src/main/java/com/baeldung/enumset/EnumSets.java b/core-java-modules/core-java-collections-set/src/main/java/com/baeldung/enumset/EnumSets.java similarity index 100% rename from core-java-collections-set/src/main/java/com/baeldung/enumset/EnumSets.java rename to core-java-modules/core-java-collections-set/src/main/java/com/baeldung/enumset/EnumSets.java diff --git a/core-java-collections-set/src/test/java/com/baeldung/collection/WhenUsingHashSet.java b/core-java-modules/core-java-collections-set/src/test/java/com/baeldung/collection/WhenUsingHashSet.java similarity index 100% rename from core-java-collections-set/src/test/java/com/baeldung/collection/WhenUsingHashSet.java rename to core-java-modules/core-java-collections-set/src/test/java/com/baeldung/collection/WhenUsingHashSet.java diff --git a/core-java-collections-set/src/test/java/com/baeldung/collection/WhenUsingTreeSet.java b/core-java-modules/core-java-collections-set/src/test/java/com/baeldung/collection/WhenUsingTreeSet.java similarity index 100% rename from core-java-collections-set/src/test/java/com/baeldung/collection/WhenUsingTreeSet.java rename to core-java-modules/core-java-collections-set/src/test/java/com/baeldung/collection/WhenUsingTreeSet.java diff --git a/core-java-collections-set/src/test/java/com/baeldung/java/set/HashSetInitalizingUnitTest.java b/core-java-modules/core-java-collections-set/src/test/java/com/baeldung/java/set/HashSetInitalizingUnitTest.java similarity index 100% rename from core-java-collections-set/src/test/java/com/baeldung/java/set/HashSetInitalizingUnitTest.java rename to core-java-modules/core-java-collections-set/src/test/java/com/baeldung/java/set/HashSetInitalizingUnitTest.java diff --git a/core-java-collections-set/src/test/java/com/baeldung/java/set/SetUnitTest.java b/core-java-modules/core-java-collections-set/src/test/java/com/baeldung/java/set/SetUnitTest.java similarity index 100% rename from core-java-collections-set/src/test/java/com/baeldung/java/set/SetUnitTest.java rename to core-java-modules/core-java-collections-set/src/test/java/com/baeldung/java/set/SetUnitTest.java diff --git a/core-java-collections-set/src/test/java/com/baeldung/set/SetOperationsUnitTest.java b/core-java-modules/core-java-collections-set/src/test/java/com/baeldung/set/SetOperationsUnitTest.java similarity index 100% rename from core-java-collections-set/src/test/java/com/baeldung/set/SetOperationsUnitTest.java rename to core-java-modules/core-java-collections-set/src/test/java/com/baeldung/set/SetOperationsUnitTest.java diff --git a/core-java-collections/README.md b/core-java-modules/core-java-collections/README.md similarity index 100% rename from core-java-collections/README.md rename to core-java-modules/core-java-collections/README.md diff --git a/core-java-collections/pom.xml b/core-java-modules/core-java-collections/pom.xml similarity index 95% rename from core-java-collections/pom.xml rename to core-java-modules/core-java-collections/pom.xml index b791f38b24..e5b89c3d16 100644 --- a/core-java-collections/pom.xml +++ b/core-java-modules/core-java-collections/pom.xml @@ -1,78 +1,78 @@ - - 4.0.0 - core-java-collections - 0.1.0-SNAPSHOT - core-java-collections - jar - - - com.baeldung - parent-java - 0.0.1-SNAPSHOT - ../parent-java - - - - - org.apache.commons - commons-collections4 - ${commons-collections4.version} - - - org.apache.commons - commons-lang3 - ${commons-lang3.version} - - - org.eclipse.collections - eclipse-collections - ${eclipse.collections.version} - - - org.assertj - assertj-core - ${assertj.version} - test - - - org.junit.platform - junit-platform-runner - ${junit.platform.version} - test - - - org.openjdk.jmh - jmh-core - ${openjdk.jmh.version} - - - org.openjdk.jmh - jmh-generator-annprocess - ${openjdk.jmh.version} - - - org.apache.commons - commons-exec - ${commons-exec.version} - - - org.projectlombok - lombok - ${lombok.version} - provided - - - - - 1.19 - 1.2.0 - 3.8.1 - 4.1 - 4.01 - 1.7.0 - 3.11.1 - 7.1.0 - 1.3 - - + + 4.0.0 + core-java-collections + 0.1.0-SNAPSHOT + core-java-collections + jar + + + com.baeldung + parent-java + 0.0.1-SNAPSHOT + ../../parent-java + + + + + org.apache.commons + commons-collections4 + ${commons-collections4.version} + + + org.apache.commons + commons-lang3 + ${commons-lang3.version} + + + org.eclipse.collections + eclipse-collections + ${eclipse.collections.version} + + + org.assertj + assertj-core + ${assertj.version} + test + + + org.junit.platform + junit-platform-runner + ${junit.platform.version} + test + + + org.openjdk.jmh + jmh-core + ${openjdk.jmh.version} + + + org.openjdk.jmh + jmh-generator-annprocess + ${openjdk.jmh.version} + + + org.apache.commons + commons-exec + ${commons-exec.version} + + + org.projectlombok + lombok + ${lombok.version} + provided + + + + + 1.19 + 1.2.0 + 3.8.1 + 4.1 + 4.01 + 1.7.0 + 3.11.1 + 7.1.0 + 1.3 + + diff --git a/core-java-collections/src/main/java/com/baeldung/charstack/CharStack.java b/core-java-modules/core-java-collections/src/main/java/com/baeldung/charstack/CharStack.java similarity index 100% rename from core-java-collections/src/main/java/com/baeldung/charstack/CharStack.java rename to core-java-modules/core-java-collections/src/main/java/com/baeldung/charstack/CharStack.java diff --git a/core-java-collections/src/main/java/com/baeldung/charstack/CharStackWithArray.java b/core-java-modules/core-java-collections/src/main/java/com/baeldung/charstack/CharStackWithArray.java similarity index 100% rename from core-java-collections/src/main/java/com/baeldung/charstack/CharStackWithArray.java rename to core-java-modules/core-java-collections/src/main/java/com/baeldung/charstack/CharStackWithArray.java diff --git a/core-java-collections/src/main/java/com/baeldung/charstack/EmptyStackException.java b/core-java-modules/core-java-collections/src/main/java/com/baeldung/charstack/EmptyStackException.java similarity index 100% rename from core-java-collections/src/main/java/com/baeldung/charstack/EmptyStackException.java rename to core-java-modules/core-java-collections/src/main/java/com/baeldung/charstack/EmptyStackException.java diff --git a/core-java-collections/src/main/java/com/baeldung/combiningcollections/CombiningArrays.java b/core-java-modules/core-java-collections/src/main/java/com/baeldung/combiningcollections/CombiningArrays.java similarity index 100% rename from core-java-collections/src/main/java/com/baeldung/combiningcollections/CombiningArrays.java rename to core-java-modules/core-java-collections/src/main/java/com/baeldung/combiningcollections/CombiningArrays.java diff --git a/core-java-collections/src/main/java/com/baeldung/combiningcollections/CombiningLists.java b/core-java-modules/core-java-collections/src/main/java/com/baeldung/combiningcollections/CombiningLists.java similarity index 100% rename from core-java-collections/src/main/java/com/baeldung/combiningcollections/CombiningLists.java rename to core-java-modules/core-java-collections/src/main/java/com/baeldung/combiningcollections/CombiningLists.java diff --git a/core-java-collections/src/main/java/com/baeldung/combiningcollections/CombiningMaps.java b/core-java-modules/core-java-collections/src/main/java/com/baeldung/combiningcollections/CombiningMaps.java similarity index 100% rename from core-java-collections/src/main/java/com/baeldung/combiningcollections/CombiningMaps.java rename to core-java-modules/core-java-collections/src/main/java/com/baeldung/combiningcollections/CombiningMaps.java diff --git a/core-java-collections/src/main/java/com/baeldung/combiningcollections/CombiningSets.java b/core-java-modules/core-java-collections/src/main/java/com/baeldung/combiningcollections/CombiningSets.java similarity index 100% rename from core-java-collections/src/main/java/com/baeldung/combiningcollections/CombiningSets.java rename to core-java-modules/core-java-collections/src/main/java/com/baeldung/combiningcollections/CombiningSets.java diff --git a/core-java-collections/src/main/java/com/baeldung/hashtable/Word.java b/core-java-modules/core-java-collections/src/main/java/com/baeldung/hashtable/Word.java similarity index 100% rename from core-java-collections/src/main/java/com/baeldung/hashtable/Word.java rename to core-java-modules/core-java-collections/src/main/java/com/baeldung/hashtable/Word.java diff --git a/core-java-collections/src/main/java/com/baeldung/iteratorguide/IteratorGuide.java b/core-java-modules/core-java-collections/src/main/java/com/baeldung/iteratorguide/IteratorGuide.java similarity index 100% rename from core-java-collections/src/main/java/com/baeldung/iteratorguide/IteratorGuide.java rename to core-java-modules/core-java-collections/src/main/java/com/baeldung/iteratorguide/IteratorGuide.java diff --git a/core-java-collections/src/main/java/com/baeldung/iterators/Iterators.java b/core-java-modules/core-java-collections/src/main/java/com/baeldung/iterators/Iterators.java similarity index 100% rename from core-java-collections/src/main/java/com/baeldung/iterators/Iterators.java rename to core-java-modules/core-java-collections/src/main/java/com/baeldung/iterators/Iterators.java diff --git a/core-java-collections/src/main/java/com/baeldung/java/filtering/CollectionUtilsCollectionFilter.java b/core-java-modules/core-java-collections/src/main/java/com/baeldung/java/filtering/CollectionUtilsCollectionFilter.java similarity index 100% rename from core-java-collections/src/main/java/com/baeldung/java/filtering/CollectionUtilsCollectionFilter.java rename to core-java-modules/core-java-collections/src/main/java/com/baeldung/java/filtering/CollectionUtilsCollectionFilter.java diff --git a/core-java-collections/src/main/java/com/baeldung/java/filtering/EclipseCollectionsCollectionFilter.java b/core-java-modules/core-java-collections/src/main/java/com/baeldung/java/filtering/EclipseCollectionsCollectionFilter.java similarity index 100% rename from core-java-collections/src/main/java/com/baeldung/java/filtering/EclipseCollectionsCollectionFilter.java rename to core-java-modules/core-java-collections/src/main/java/com/baeldung/java/filtering/EclipseCollectionsCollectionFilter.java diff --git a/core-java-collections/src/main/java/com/baeldung/java/filtering/GuavaCollectionFilter.java b/core-java-modules/core-java-collections/src/main/java/com/baeldung/java/filtering/GuavaCollectionFilter.java similarity index 100% rename from core-java-collections/src/main/java/com/baeldung/java/filtering/GuavaCollectionFilter.java rename to core-java-modules/core-java-collections/src/main/java/com/baeldung/java/filtering/GuavaCollectionFilter.java diff --git a/core-java-collections/src/main/java/com/baeldung/java/filtering/StreamsCollectionFilter.java b/core-java-modules/core-java-collections/src/main/java/com/baeldung/java/filtering/StreamsCollectionFilter.java similarity index 100% rename from core-java-collections/src/main/java/com/baeldung/java/filtering/StreamsCollectionFilter.java rename to core-java-modules/core-java-collections/src/main/java/com/baeldung/java/filtering/StreamsCollectionFilter.java diff --git a/core-java-collections/src/main/java/com/baeldung/java/iterable/IterableSize.java b/core-java-modules/core-java-collections/src/main/java/com/baeldung/java/iterable/IterableSize.java similarity index 100% rename from core-java-collections/src/main/java/com/baeldung/java/iterable/IterableSize.java rename to core-java-modules/core-java-collections/src/main/java/com/baeldung/java/iterable/IterableSize.java diff --git a/core-java-collections/src/main/java/com/baeldung/java/list/VectorExample.java b/core-java-modules/core-java-collections/src/main/java/com/baeldung/java/list/VectorExample.java similarity index 100% rename from core-java-collections/src/main/java/com/baeldung/java/list/VectorExample.java rename to core-java-modules/core-java-collections/src/main/java/com/baeldung/java/list/VectorExample.java diff --git a/core-java-collections/src/main/java/com/baeldung/java/sort/CollectionsSortCompare.java b/core-java-modules/core-java-collections/src/main/java/com/baeldung/java/sort/CollectionsSortCompare.java similarity index 100% rename from core-java-collections/src/main/java/com/baeldung/java/sort/CollectionsSortCompare.java rename to core-java-modules/core-java-collections/src/main/java/com/baeldung/java/sort/CollectionsSortCompare.java diff --git a/core-java-collections/src/main/java/com/baeldung/nullsafecollectionstreams/NullSafeCollectionStreamsUsingCommonsEmptyIfNull.java b/core-java-modules/core-java-collections/src/main/java/com/baeldung/nullsafecollectionstreams/NullSafeCollectionStreamsUsingCommonsEmptyIfNull.java similarity index 100% rename from core-java-collections/src/main/java/com/baeldung/nullsafecollectionstreams/NullSafeCollectionStreamsUsingCommonsEmptyIfNull.java rename to core-java-modules/core-java-collections/src/main/java/com/baeldung/nullsafecollectionstreams/NullSafeCollectionStreamsUsingCommonsEmptyIfNull.java diff --git a/core-java-collections/src/main/java/com/baeldung/nullsafecollectionstreams/NullSafeCollectionStreamsUsingJava8OptionalContainer.java b/core-java-modules/core-java-collections/src/main/java/com/baeldung/nullsafecollectionstreams/NullSafeCollectionStreamsUsingJava8OptionalContainer.java similarity index 100% rename from core-java-collections/src/main/java/com/baeldung/nullsafecollectionstreams/NullSafeCollectionStreamsUsingJava8OptionalContainer.java rename to core-java-modules/core-java-collections/src/main/java/com/baeldung/nullsafecollectionstreams/NullSafeCollectionStreamsUsingJava8OptionalContainer.java diff --git a/core-java-collections/src/main/java/com/baeldung/nullsafecollectionstreams/NullSafeCollectionStreamsUsingNullDereferenceCheck.java b/core-java-modules/core-java-collections/src/main/java/com/baeldung/nullsafecollectionstreams/NullSafeCollectionStreamsUsingNullDereferenceCheck.java similarity index 100% rename from core-java-collections/src/main/java/com/baeldung/nullsafecollectionstreams/NullSafeCollectionStreamsUsingNullDereferenceCheck.java rename to core-java-modules/core-java-collections/src/main/java/com/baeldung/nullsafecollectionstreams/NullSafeCollectionStreamsUsingNullDereferenceCheck.java diff --git a/core-java-collections/src/main/java/com/baeldung/performance/ArrayListBenchmark.java b/core-java-modules/core-java-collections/src/main/java/com/baeldung/performance/ArrayListBenchmark.java similarity index 100% rename from core-java-collections/src/main/java/com/baeldung/performance/ArrayListBenchmark.java rename to core-java-modules/core-java-collections/src/main/java/com/baeldung/performance/ArrayListBenchmark.java diff --git a/core-java-collections/src/main/java/com/baeldung/performance/ArraySortBenchmark.java b/core-java-modules/core-java-collections/src/main/java/com/baeldung/performance/ArraySortBenchmark.java similarity index 100% rename from core-java-collections/src/main/java/com/baeldung/performance/ArraySortBenchmark.java rename to core-java-modules/core-java-collections/src/main/java/com/baeldung/performance/ArraySortBenchmark.java diff --git a/core-java-collections/src/main/java/com/baeldung/performance/CollectionsBenchmark.java b/core-java-modules/core-java-collections/src/main/java/com/baeldung/performance/CollectionsBenchmark.java similarity index 100% rename from core-java-collections/src/main/java/com/baeldung/performance/CollectionsBenchmark.java rename to core-java-modules/core-java-collections/src/main/java/com/baeldung/performance/CollectionsBenchmark.java diff --git a/core-java-collections/src/main/java/com/baeldung/performance/CopyOnWriteBenchmark.java b/core-java-modules/core-java-collections/src/main/java/com/baeldung/performance/CopyOnWriteBenchmark.java similarity index 100% rename from core-java-collections/src/main/java/com/baeldung/performance/CopyOnWriteBenchmark.java rename to core-java-modules/core-java-collections/src/main/java/com/baeldung/performance/CopyOnWriteBenchmark.java diff --git a/core-java-collections/src/main/java/com/baeldung/performance/Employee.java b/core-java-modules/core-java-collections/src/main/java/com/baeldung/performance/Employee.java similarity index 100% rename from core-java-collections/src/main/java/com/baeldung/performance/Employee.java rename to core-java-modules/core-java-collections/src/main/java/com/baeldung/performance/Employee.java diff --git a/core-java-collections/src/main/java/com/baeldung/performance/HashMapBenchmark.java b/core-java-modules/core-java-collections/src/main/java/com/baeldung/performance/HashMapBenchmark.java similarity index 100% rename from core-java-collections/src/main/java/com/baeldung/performance/HashMapBenchmark.java rename to core-java-modules/core-java-collections/src/main/java/com/baeldung/performance/HashMapBenchmark.java diff --git a/core-java-collections/src/main/java/com/baeldung/performance/SetBenchMark.java b/core-java-modules/core-java-collections/src/main/java/com/baeldung/performance/SetBenchMark.java similarity index 100% rename from core-java-collections/src/main/java/com/baeldung/performance/SetBenchMark.java rename to core-java-modules/core-java-collections/src/main/java/com/baeldung/performance/SetBenchMark.java diff --git a/core-java-collections/src/main/java/com/baeldung/queueInterface/CustomBaeldungQueue.java b/core-java-modules/core-java-collections/src/main/java/com/baeldung/queueInterface/CustomBaeldungQueue.java similarity index 100% rename from core-java-collections/src/main/java/com/baeldung/queueInterface/CustomBaeldungQueue.java rename to core-java-modules/core-java-collections/src/main/java/com/baeldung/queueInterface/CustomBaeldungQueue.java diff --git a/core-java-collections/src/main/java/com/baeldung/removal/CollectionRemoveIf.java b/core-java-modules/core-java-collections/src/main/java/com/baeldung/removal/CollectionRemoveIf.java similarity index 100% rename from core-java-collections/src/main/java/com/baeldung/removal/CollectionRemoveIf.java rename to core-java-modules/core-java-collections/src/main/java/com/baeldung/removal/CollectionRemoveIf.java diff --git a/core-java-collections/src/main/java/com/baeldung/removal/Iterators.java b/core-java-modules/core-java-collections/src/main/java/com/baeldung/removal/Iterators.java similarity index 100% rename from core-java-collections/src/main/java/com/baeldung/removal/Iterators.java rename to core-java-modules/core-java-collections/src/main/java/com/baeldung/removal/Iterators.java diff --git a/core-java-collections/src/main/java/com/baeldung/removal/StreamFilterAndCollector.java b/core-java-modules/core-java-collections/src/main/java/com/baeldung/removal/StreamFilterAndCollector.java similarity index 100% rename from core-java-collections/src/main/java/com/baeldung/removal/StreamFilterAndCollector.java rename to core-java-modules/core-java-collections/src/main/java/com/baeldung/removal/StreamFilterAndCollector.java diff --git a/core-java-collections/src/main/java/com/baeldung/removal/StreamPartitioningBy.java b/core-java-modules/core-java-collections/src/main/java/com/baeldung/removal/StreamPartitioningBy.java similarity index 100% rename from core-java-collections/src/main/java/com/baeldung/removal/StreamPartitioningBy.java rename to core-java-modules/core-java-collections/src/main/java/com/baeldung/removal/StreamPartitioningBy.java diff --git a/core-java-collections/src/main/java/com/baeldung/synchronizedcollections/application/Application.java b/core-java-modules/core-java-collections/src/main/java/com/baeldung/synchronizedcollections/application/Application.java similarity index 97% rename from core-java-collections/src/main/java/com/baeldung/synchronizedcollections/application/Application.java rename to core-java-modules/core-java-collections/src/main/java/com/baeldung/synchronizedcollections/application/Application.java index 1840c125d0..093308a34a 100644 --- a/core-java-collections/src/main/java/com/baeldung/synchronizedcollections/application/Application.java +++ b/core-java-modules/core-java-collections/src/main/java/com/baeldung/synchronizedcollections/application/Application.java @@ -1,18 +1,18 @@ -package com.baeldung.synchronizedcollections.application; - -import java.util.Arrays; -import java.util.Collections; -import java.util.List; -import java.util.logging.Logger; - -public class Application { - - private static final Logger LOGGER = Logger.getLogger(Application.class.getName()); - - public static void main(String[] args) throws InterruptedException { - List syncCollection = Collections.synchronizedList(Arrays.asList(1, 2, 3, 4, 5, 6)); - synchronized (syncCollection) { - syncCollection.forEach((e) -> {LOGGER.info(e.toString());}); - } - } -} +package com.baeldung.synchronizedcollections.application; + +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.logging.Logger; + +public class Application { + + private static final Logger LOGGER = Logger.getLogger(Application.class.getName()); + + public static void main(String[] args) throws InterruptedException { + List syncCollection = Collections.synchronizedList(Arrays.asList(1, 2, 3, 4, 5, 6)); + synchronized (syncCollection) { + syncCollection.forEach((e) -> {LOGGER.info(e.toString());}); + } + } +} diff --git a/core-java-collections/src/main/java/com/baeldung/thread_safe_lifo/DequeBasedSynchronizedStack.java b/core-java-modules/core-java-collections/src/main/java/com/baeldung/thread_safe_lifo/DequeBasedSynchronizedStack.java similarity index 100% rename from core-java-collections/src/main/java/com/baeldung/thread_safe_lifo/DequeBasedSynchronizedStack.java rename to core-java-modules/core-java-collections/src/main/java/com/baeldung/thread_safe_lifo/DequeBasedSynchronizedStack.java diff --git a/core-java-collections/src/main/resources/logback.xml b/core-java-modules/core-java-collections/src/main/resources/logback.xml similarity index 100% rename from core-java-collections/src/main/resources/logback.xml rename to core-java-modules/core-java-collections/src/main/resources/logback.xml diff --git a/core-java-collections/src/test/java/com/baeldung/arraydeque/ArrayDequeUnitTest.java b/core-java-modules/core-java-collections/src/test/java/com/baeldung/arraydeque/ArrayDequeUnitTest.java similarity index 95% rename from core-java-collections/src/test/java/com/baeldung/arraydeque/ArrayDequeUnitTest.java rename to core-java-modules/core-java-collections/src/test/java/com/baeldung/arraydeque/ArrayDequeUnitTest.java index 71930eda97..5a76eb5402 100644 --- a/core-java-collections/src/test/java/com/baeldung/arraydeque/ArrayDequeUnitTest.java +++ b/core-java-modules/core-java-collections/src/test/java/com/baeldung/arraydeque/ArrayDequeUnitTest.java @@ -1,50 +1,50 @@ -package com.baeldung.arraydeque; - -import java.util.ArrayDeque; -import java.util.Deque; - -import static org.junit.Assert.*; -import org.junit.Test; - -public class ArrayDequeUnitTest { - - @Test - public void whenOffer_addsAtLast() { - final Deque deque = new ArrayDeque<>(); - - deque.offer("first"); - deque.offer("second"); - - assertEquals("second", deque.getLast()); - } - - @Test - public void whenPoll_removesFirst() { - final Deque deque = new ArrayDeque<>(); - - deque.offer("first"); - deque.offer("second"); - - assertEquals("first", deque.poll()); - } - - @Test - public void whenPush_addsAtFirst() { - final Deque deque = new ArrayDeque<>(); - - deque.push("first"); - deque.push("second"); - - assertEquals("second", deque.getFirst()); - } - - @Test - public void whenPop_removesLast() { - final Deque deque = new ArrayDeque<>(); - - deque.push("first"); - deque.push("second"); - - assertEquals("second", deque.pop()); - } -} +package com.baeldung.arraydeque; + +import java.util.ArrayDeque; +import java.util.Deque; + +import static org.junit.Assert.*; +import org.junit.Test; + +public class ArrayDequeUnitTest { + + @Test + public void whenOffer_addsAtLast() { + final Deque deque = new ArrayDeque<>(); + + deque.offer("first"); + deque.offer("second"); + + assertEquals("second", deque.getLast()); + } + + @Test + public void whenPoll_removesFirst() { + final Deque deque = new ArrayDeque<>(); + + deque.offer("first"); + deque.offer("second"); + + assertEquals("first", deque.poll()); + } + + @Test + public void whenPush_addsAtFirst() { + final Deque deque = new ArrayDeque<>(); + + deque.push("first"); + deque.push("second"); + + assertEquals("second", deque.getFirst()); + } + + @Test + public void whenPop_removesLast() { + final Deque deque = new ArrayDeque<>(); + + deque.push("first"); + deque.push("second"); + + assertEquals("second", deque.pop()); + } +} diff --git a/core-java-collections/src/test/java/com/baeldung/charstack/CharStackUnitTest.java b/core-java-modules/core-java-collections/src/test/java/com/baeldung/charstack/CharStackUnitTest.java similarity index 100% rename from core-java-collections/src/test/java/com/baeldung/charstack/CharStackUnitTest.java rename to core-java-modules/core-java-collections/src/test/java/com/baeldung/charstack/CharStackUnitTest.java diff --git a/core-java-collections/src/test/java/com/baeldung/charstack/CharStackUsingJavaUnitTest.java b/core-java-modules/core-java-collections/src/test/java/com/baeldung/charstack/CharStackUsingJavaUnitTest.java similarity index 100% rename from core-java-collections/src/test/java/com/baeldung/charstack/CharStackUsingJavaUnitTest.java rename to core-java-modules/core-java-collections/src/test/java/com/baeldung/charstack/CharStackUsingJavaUnitTest.java diff --git a/core-java-collections/src/test/java/com/baeldung/charstack/CharStackWithArrayUnitTest.java b/core-java-modules/core-java-collections/src/test/java/com/baeldung/charstack/CharStackWithArrayUnitTest.java similarity index 100% rename from core-java-collections/src/test/java/com/baeldung/charstack/CharStackWithArrayUnitTest.java rename to core-java-modules/core-java-collections/src/test/java/com/baeldung/charstack/CharStackWithArrayUnitTest.java diff --git a/core-java-collections/src/test/java/com/baeldung/combiningcollections/CombiningArraysUnitTest.java b/core-java-modules/core-java-collections/src/test/java/com/baeldung/combiningcollections/CombiningArraysUnitTest.java similarity index 100% rename from core-java-collections/src/test/java/com/baeldung/combiningcollections/CombiningArraysUnitTest.java rename to core-java-modules/core-java-collections/src/test/java/com/baeldung/combiningcollections/CombiningArraysUnitTest.java diff --git a/core-java-collections/src/test/java/com/baeldung/combiningcollections/CombiningListsUnitTest.java b/core-java-modules/core-java-collections/src/test/java/com/baeldung/combiningcollections/CombiningListsUnitTest.java similarity index 100% rename from core-java-collections/src/test/java/com/baeldung/combiningcollections/CombiningListsUnitTest.java rename to core-java-modules/core-java-collections/src/test/java/com/baeldung/combiningcollections/CombiningListsUnitTest.java diff --git a/core-java-collections/src/test/java/com/baeldung/combiningcollections/CombiningMapsUnitTest.java b/core-java-modules/core-java-collections/src/test/java/com/baeldung/combiningcollections/CombiningMapsUnitTest.java similarity index 100% rename from core-java-collections/src/test/java/com/baeldung/combiningcollections/CombiningMapsUnitTest.java rename to core-java-modules/core-java-collections/src/test/java/com/baeldung/combiningcollections/CombiningMapsUnitTest.java diff --git a/core-java-collections/src/test/java/com/baeldung/combiningcollections/CombiningSetsUnitTest.java b/core-java-modules/core-java-collections/src/test/java/com/baeldung/combiningcollections/CombiningSetsUnitTest.java similarity index 100% rename from core-java-collections/src/test/java/com/baeldung/combiningcollections/CombiningSetsUnitTest.java rename to core-java-modules/core-java-collections/src/test/java/com/baeldung/combiningcollections/CombiningSetsUnitTest.java diff --git a/core-java-collections/src/test/java/com/baeldung/enummap/DummyEnum.java b/core-java-modules/core-java-collections/src/test/java/com/baeldung/enummap/DummyEnum.java similarity index 100% rename from core-java-collections/src/test/java/com/baeldung/enummap/DummyEnum.java rename to core-java-modules/core-java-collections/src/test/java/com/baeldung/enummap/DummyEnum.java diff --git a/core-java-collections/src/test/java/com/baeldung/enummap/EnumMapBenchmarkLiveTest.java b/core-java-modules/core-java-collections/src/test/java/com/baeldung/enummap/EnumMapBenchmarkLiveTest.java similarity index 100% rename from core-java-collections/src/test/java/com/baeldung/enummap/EnumMapBenchmarkLiveTest.java rename to core-java-modules/core-java-collections/src/test/java/com/baeldung/enummap/EnumMapBenchmarkLiveTest.java diff --git a/core-java-collections/src/test/java/com/baeldung/enummap/EnumMapUnitTest.java b/core-java-modules/core-java-collections/src/test/java/com/baeldung/enummap/EnumMapUnitTest.java similarity index 100% rename from core-java-collections/src/test/java/com/baeldung/enummap/EnumMapUnitTest.java rename to core-java-modules/core-java-collections/src/test/java/com/baeldung/enummap/EnumMapUnitTest.java diff --git a/core-java-collections/src/test/java/com/baeldung/hashmapvshashtable/HashmapVsHashtableDifferenceUnitTest.java b/core-java-modules/core-java-collections/src/test/java/com/baeldung/hashmapvshashtable/HashmapVsHashtableDifferenceUnitTest.java similarity index 100% rename from core-java-collections/src/test/java/com/baeldung/hashmapvshashtable/HashmapVsHashtableDifferenceUnitTest.java rename to core-java-modules/core-java-collections/src/test/java/com/baeldung/hashmapvshashtable/HashmapVsHashtableDifferenceUnitTest.java diff --git a/core-java-collections/src/test/java/com/baeldung/hashtable/HashtableUnitTest.java b/core-java-modules/core-java-collections/src/test/java/com/baeldung/hashtable/HashtableUnitTest.java similarity index 100% rename from core-java-collections/src/test/java/com/baeldung/hashtable/HashtableUnitTest.java rename to core-java-modules/core-java-collections/src/test/java/com/baeldung/hashtable/HashtableUnitTest.java diff --git a/core-java-collections/src/test/java/com/baeldung/iterators/IteratorsUnitTest.java b/core-java-modules/core-java-collections/src/test/java/com/baeldung/iterators/IteratorsUnitTest.java similarity index 100% rename from core-java-collections/src/test/java/com/baeldung/iterators/IteratorsUnitTest.java rename to core-java-modules/core-java-collections/src/test/java/com/baeldung/iterators/IteratorsUnitTest.java diff --git a/core-java-collections/src/test/java/com/baeldung/java/collections/ConcurrentModificationExceptionUnitTest.java b/core-java-modules/core-java-collections/src/test/java/com/baeldung/java/collections/ConcurrentModificationExceptionUnitTest.java similarity index 100% rename from core-java-collections/src/test/java/com/baeldung/java/collections/ConcurrentModificationExceptionUnitTest.java rename to core-java-modules/core-java-collections/src/test/java/com/baeldung/java/collections/ConcurrentModificationExceptionUnitTest.java diff --git a/core-java-collections/src/test/java/com/baeldung/java/filtering/CollectionFiltersUnitTest.java b/core-java-modules/core-java-collections/src/test/java/com/baeldung/java/filtering/CollectionFiltersUnitTest.java similarity index 100% rename from core-java-collections/src/test/java/com/baeldung/java/filtering/CollectionFiltersUnitTest.java rename to core-java-modules/core-java-collections/src/test/java/com/baeldung/java/filtering/CollectionFiltersUnitTest.java diff --git a/core-java-collections/src/test/java/com/baeldung/java/iterable/IterableSizeUnitTest.java b/core-java-modules/core-java-collections/src/test/java/com/baeldung/java/iterable/IterableSizeUnitTest.java similarity index 100% rename from core-java-collections/src/test/java/com/baeldung/java/iterable/IterableSizeUnitTest.java rename to core-java-modules/core-java-collections/src/test/java/com/baeldung/java/iterable/IterableSizeUnitTest.java diff --git a/core-java-collections/src/test/java/com/baeldung/nullsafecollectionstreams/NullSafeCollectionStreamsUsingCommonsEmptyIfNullUnitTest.java b/core-java-modules/core-java-collections/src/test/java/com/baeldung/nullsafecollectionstreams/NullSafeCollectionStreamsUsingCommonsEmptyIfNullUnitTest.java similarity index 100% rename from core-java-collections/src/test/java/com/baeldung/nullsafecollectionstreams/NullSafeCollectionStreamsUsingCommonsEmptyIfNullUnitTest.java rename to core-java-modules/core-java-collections/src/test/java/com/baeldung/nullsafecollectionstreams/NullSafeCollectionStreamsUsingCommonsEmptyIfNullUnitTest.java diff --git a/core-java-collections/src/test/java/com/baeldung/nullsafecollectionstreams/NullSafeCollectionStreamsUsingJava8OptionalContainerUnitTest.java b/core-java-modules/core-java-collections/src/test/java/com/baeldung/nullsafecollectionstreams/NullSafeCollectionStreamsUsingJava8OptionalContainerUnitTest.java similarity index 100% rename from core-java-collections/src/test/java/com/baeldung/nullsafecollectionstreams/NullSafeCollectionStreamsUsingJava8OptionalContainerUnitTest.java rename to core-java-modules/core-java-collections/src/test/java/com/baeldung/nullsafecollectionstreams/NullSafeCollectionStreamsUsingJava8OptionalContainerUnitTest.java diff --git a/core-java-collections/src/test/java/com/baeldung/nullsafecollectionstreams/NullSafeCollectionStreamsUsingNullDereferenceCheckUnitTest.java b/core-java-modules/core-java-collections/src/test/java/com/baeldung/nullsafecollectionstreams/NullSafeCollectionStreamsUsingNullDereferenceCheckUnitTest.java similarity index 100% rename from core-java-collections/src/test/java/com/baeldung/nullsafecollectionstreams/NullSafeCollectionStreamsUsingNullDereferenceCheckUnitTest.java rename to core-java-modules/core-java-collections/src/test/java/com/baeldung/nullsafecollectionstreams/NullSafeCollectionStreamsUsingNullDereferenceCheckUnitTest.java diff --git a/core-java-collections/src/test/java/com/baeldung/queueInterface/CustomBaeldungQueueUnitTest.java b/core-java-modules/core-java-collections/src/test/java/com/baeldung/queueInterface/CustomBaeldungQueueUnitTest.java similarity index 100% rename from core-java-collections/src/test/java/com/baeldung/queueInterface/CustomBaeldungQueueUnitTest.java rename to core-java-modules/core-java-collections/src/test/java/com/baeldung/queueInterface/CustomBaeldungQueueUnitTest.java diff --git a/core-java-collections/src/test/java/com/baeldung/queueInterface/PriorityQueueUnitTest.java b/core-java-modules/core-java-collections/src/test/java/com/baeldung/queueInterface/PriorityQueueUnitTest.java similarity index 100% rename from core-java-collections/src/test/java/com/baeldung/queueInterface/PriorityQueueUnitTest.java rename to core-java-modules/core-java-collections/src/test/java/com/baeldung/queueInterface/PriorityQueueUnitTest.java diff --git a/core-java-collections/src/test/java/com/baeldung/removal/RemovalUnitTest.java b/core-java-modules/core-java-collections/src/test/java/com/baeldung/removal/RemovalUnitTest.java similarity index 100% rename from core-java-collections/src/test/java/com/baeldung/removal/RemovalUnitTest.java rename to core-java-modules/core-java-collections/src/test/java/com/baeldung/removal/RemovalUnitTest.java diff --git a/core-java-collections/src/test/java/com/baeldung/shufflingcollections/ShufflingCollectionsUnitTest.java b/core-java-modules/core-java-collections/src/test/java/com/baeldung/shufflingcollections/ShufflingCollectionsUnitTest.java similarity index 100% rename from core-java-collections/src/test/java/com/baeldung/shufflingcollections/ShufflingCollectionsUnitTest.java rename to core-java-modules/core-java-collections/src/test/java/com/baeldung/shufflingcollections/ShufflingCollectionsUnitTest.java diff --git a/core-java-collections/src/test/java/com/baeldung/stack_tests/MultithreadingCorrectnessStackUnitTest.java b/core-java-modules/core-java-collections/src/test/java/com/baeldung/stack_tests/MultithreadingCorrectnessStackUnitTest.java similarity index 100% rename from core-java-collections/src/test/java/com/baeldung/stack_tests/MultithreadingCorrectnessStackUnitTest.java rename to core-java-modules/core-java-collections/src/test/java/com/baeldung/stack_tests/MultithreadingCorrectnessStackUnitTest.java diff --git a/core-java-collections/src/test/java/com/baeldung/stack_tests/StackUnitTest.java b/core-java-modules/core-java-collections/src/test/java/com/baeldung/stack_tests/StackUnitTest.java similarity index 100% rename from core-java-collections/src/test/java/com/baeldung/stack_tests/StackUnitTest.java rename to core-java-modules/core-java-collections/src/test/java/com/baeldung/stack_tests/StackUnitTest.java diff --git a/core-java-collections/src/test/java/com/baeldung/synchronizedcollections/test/SynchronizedCollectionUnitTest.java b/core-java-modules/core-java-collections/src/test/java/com/baeldung/synchronizedcollections/test/SynchronizedCollectionUnitTest.java similarity index 97% rename from core-java-collections/src/test/java/com/baeldung/synchronizedcollections/test/SynchronizedCollectionUnitTest.java rename to core-java-modules/core-java-collections/src/test/java/com/baeldung/synchronizedcollections/test/SynchronizedCollectionUnitTest.java index 84feeb6eaa..fd84503226 100644 --- a/core-java-collections/src/test/java/com/baeldung/synchronizedcollections/test/SynchronizedCollectionUnitTest.java +++ b/core-java-modules/core-java-collections/src/test/java/com/baeldung/synchronizedcollections/test/SynchronizedCollectionUnitTest.java @@ -1,28 +1,28 @@ -package com.baeldung.synchronizedcollections.test; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import static org.assertj.core.api.Assertions.assertThat; -import org.junit.Test; - -public class SynchronizedCollectionUnitTest { - - @Test - public void givenSynchronizedCollection_whenTwoThreadsAddElements_thenCorrectCollectionSize() throws InterruptedException { - Collection syncCollection = Collections.synchronizedCollection(new ArrayList<>()); - - Runnable listOperations = () -> { - syncCollection.addAll(Arrays.asList(1, 2, 3, 4, 5, 6)); - }; - Thread thread1 = new Thread(listOperations); - Thread thread2 = new Thread(listOperations); - thread1.start(); - thread2.start(); - thread1.join(); - thread2.join(); - - assertThat(syncCollection.size()).isEqualTo(12); - } -} +package com.baeldung.synchronizedcollections.test; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import static org.assertj.core.api.Assertions.assertThat; +import org.junit.Test; + +public class SynchronizedCollectionUnitTest { + + @Test + public void givenSynchronizedCollection_whenTwoThreadsAddElements_thenCorrectCollectionSize() throws InterruptedException { + Collection syncCollection = Collections.synchronizedCollection(new ArrayList<>()); + + Runnable listOperations = () -> { + syncCollection.addAll(Arrays.asList(1, 2, 3, 4, 5, 6)); + }; + Thread thread1 = new Thread(listOperations); + Thread thread2 = new Thread(listOperations); + thread1.start(); + thread2.start(); + thread1.join(); + thread2.join(); + + assertThat(syncCollection.size()).isEqualTo(12); + } +} diff --git a/core-java-collections/src/test/java/com/baeldung/synchronizedcollections/test/SynchronizedListUnitTest.java b/core-java-modules/core-java-collections/src/test/java/com/baeldung/synchronizedcollections/test/SynchronizedListUnitTest.java similarity index 97% rename from core-java-collections/src/test/java/com/baeldung/synchronizedcollections/test/SynchronizedListUnitTest.java rename to core-java-modules/core-java-collections/src/test/java/com/baeldung/synchronizedcollections/test/SynchronizedListUnitTest.java index 68fc3becd4..72354622ae 100644 --- a/core-java-collections/src/test/java/com/baeldung/synchronizedcollections/test/SynchronizedListUnitTest.java +++ b/core-java-modules/core-java-collections/src/test/java/com/baeldung/synchronizedcollections/test/SynchronizedListUnitTest.java @@ -1,51 +1,51 @@ -package com.baeldung.synchronizedcollections.test; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; -import org.junit.Test; -import static org.assertj.core.api.Assertions.*; - -public class SynchronizedListUnitTest { - - @Test - public void givenSynchronizedList_whenTwoThreadsAddElements_thenCorrectListSize() throws InterruptedException { - List syncList = Collections.synchronizedList(new ArrayList<>()); - - Runnable listOperations = () -> { - syncList.addAll(Arrays.asList(1, 2, 3, 4, 5, 6)); - }; - Thread thread1 = new Thread(listOperations); - Thread thread2 = new Thread(listOperations); - thread1.start(); - thread2.start(); - thread1.join(); - thread2.join(); - - assertThat(syncList.size()).isEqualTo(12); - } - - @Test - public void givenStringList_whenTwoThreadsIterateOnSynchronizedList_thenCorrectResult() throws InterruptedException { - List syncCollection = Collections.synchronizedList(Arrays.asList("a", "b", "c")); - List uppercasedCollection = new ArrayList<>(); - - Runnable listOperations = () -> { - synchronized (syncCollection) { - syncCollection.forEach((e) -> { - uppercasedCollection.add(e.toUpperCase()); - }); - } - }; - - Thread thread1 = new Thread(listOperations); - Thread thread2 = new Thread(listOperations); - thread1.start(); - thread2.start(); - thread1.join(); - thread2.join(); - - assertThat(uppercasedCollection.get(0)).isEqualTo("A"); - } -} +package com.baeldung.synchronizedcollections.test; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import org.junit.Test; +import static org.assertj.core.api.Assertions.*; + +public class SynchronizedListUnitTest { + + @Test + public void givenSynchronizedList_whenTwoThreadsAddElements_thenCorrectListSize() throws InterruptedException { + List syncList = Collections.synchronizedList(new ArrayList<>()); + + Runnable listOperations = () -> { + syncList.addAll(Arrays.asList(1, 2, 3, 4, 5, 6)); + }; + Thread thread1 = new Thread(listOperations); + Thread thread2 = new Thread(listOperations); + thread1.start(); + thread2.start(); + thread1.join(); + thread2.join(); + + assertThat(syncList.size()).isEqualTo(12); + } + + @Test + public void givenStringList_whenTwoThreadsIterateOnSynchronizedList_thenCorrectResult() throws InterruptedException { + List syncCollection = Collections.synchronizedList(Arrays.asList("a", "b", "c")); + List uppercasedCollection = new ArrayList<>(); + + Runnable listOperations = () -> { + synchronized (syncCollection) { + syncCollection.forEach((e) -> { + uppercasedCollection.add(e.toUpperCase()); + }); + } + }; + + Thread thread1 = new Thread(listOperations); + Thread thread2 = new Thread(listOperations); + thread1.start(); + thread2.start(); + thread1.join(); + thread2.join(); + + assertThat(uppercasedCollection.get(0)).isEqualTo("A"); + } +} diff --git a/core-java-collections/src/test/java/com/baeldung/synchronizedcollections/test/SynchronizedMapUnitTest.java b/core-java-modules/core-java-collections/src/test/java/com/baeldung/synchronizedcollections/test/SynchronizedMapUnitTest.java similarity index 96% rename from core-java-collections/src/test/java/com/baeldung/synchronizedcollections/test/SynchronizedMapUnitTest.java rename to core-java-modules/core-java-collections/src/test/java/com/baeldung/synchronizedcollections/test/SynchronizedMapUnitTest.java index abfb866e9c..842e253e9e 100644 --- a/core-java-collections/src/test/java/com/baeldung/synchronizedcollections/test/SynchronizedMapUnitTest.java +++ b/core-java-modules/core-java-collections/src/test/java/com/baeldung/synchronizedcollections/test/SynchronizedMapUnitTest.java @@ -1,30 +1,30 @@ -package com.baeldung.synchronizedcollections.test; - -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; -import org.junit.Test; -import static org.assertj.core.api.Assertions.*; - -public class SynchronizedMapUnitTest { - - @Test - public void givenSynchronizedMap_whenTwoThreadsAddElements_thenCorrectMapSize() throws InterruptedException { - Map syncMap = Collections.synchronizedMap(new HashMap<>()); - - Runnable mapOperations = () -> { - syncMap.put(1, "one"); - syncMap.put(2, "two"); - syncMap.put(3, "three"); - - }; - Thread thread1 = new Thread(mapOperations); - Thread thread2 = new Thread(mapOperations); - thread1.start(); - thread2.start(); - thread1.join(); - thread2.join(); - - assertThat(syncMap.size()).isEqualTo(3); - } -} +package com.baeldung.synchronizedcollections.test; + +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; +import org.junit.Test; +import static org.assertj.core.api.Assertions.*; + +public class SynchronizedMapUnitTest { + + @Test + public void givenSynchronizedMap_whenTwoThreadsAddElements_thenCorrectMapSize() throws InterruptedException { + Map syncMap = Collections.synchronizedMap(new HashMap<>()); + + Runnable mapOperations = () -> { + syncMap.put(1, "one"); + syncMap.put(2, "two"); + syncMap.put(3, "three"); + + }; + Thread thread1 = new Thread(mapOperations); + Thread thread2 = new Thread(mapOperations); + thread1.start(); + thread2.start(); + thread1.join(); + thread2.join(); + + assertThat(syncMap.size()).isEqualTo(3); + } +} diff --git a/core-java-collections/src/test/java/com/baeldung/synchronizedcollections/test/SynchronizedSetUnitTest.java b/core-java-modules/core-java-collections/src/test/java/com/baeldung/synchronizedcollections/test/SynchronizedSetUnitTest.java similarity index 97% rename from core-java-collections/src/test/java/com/baeldung/synchronizedcollections/test/SynchronizedSetUnitTest.java rename to core-java-modules/core-java-collections/src/test/java/com/baeldung/synchronizedcollections/test/SynchronizedSetUnitTest.java index 58a33b207d..f88f58a55b 100644 --- a/core-java-collections/src/test/java/com/baeldung/synchronizedcollections/test/SynchronizedSetUnitTest.java +++ b/core-java-modules/core-java-collections/src/test/java/com/baeldung/synchronizedcollections/test/SynchronizedSetUnitTest.java @@ -1,26 +1,26 @@ -package com.baeldung.synchronizedcollections.test; - -import java.util.Arrays; -import java.util.Collections; -import java.util.HashSet; -import java.util.Set; -import org.junit.Test; -import static org.assertj.core.api.Assertions.*; - -public class SynchronizedSetUnitTest { - - @Test - public void givenSynchronizedSet_whenTwoThreadsAddElements_thenCorrectSetSize() throws InterruptedException { - Set syncSet = Collections.synchronizedSet(new HashSet<>()); - - Runnable setOperations = () -> {syncSet.addAll(Arrays.asList(1, 2, 3, 4, 5, 6));}; - Thread thread1 = new Thread(setOperations); - Thread thread2 = new Thread(setOperations); - thread1.start(); - thread2.start(); - thread1.join(); - thread2.join(); - - assertThat(syncSet.size()).isEqualTo(6); - } -} +package com.baeldung.synchronizedcollections.test; + +import java.util.Arrays; +import java.util.Collections; +import java.util.HashSet; +import java.util.Set; +import org.junit.Test; +import static org.assertj.core.api.Assertions.*; + +public class SynchronizedSetUnitTest { + + @Test + public void givenSynchronizedSet_whenTwoThreadsAddElements_thenCorrectSetSize() throws InterruptedException { + Set syncSet = Collections.synchronizedSet(new HashSet<>()); + + Runnable setOperations = () -> {syncSet.addAll(Arrays.asList(1, 2, 3, 4, 5, 6));}; + Thread thread1 = new Thread(setOperations); + Thread thread2 = new Thread(setOperations); + thread1.start(); + thread2.start(); + thread1.join(); + thread2.join(); + + assertThat(syncSet.size()).isEqualTo(6); + } +} diff --git a/core-java-collections/src/test/java/com/baeldung/synchronizedcollections/test/SynchronizedSortedMapUnitTest.java b/core-java-modules/core-java-collections/src/test/java/com/baeldung/synchronizedcollections/test/SynchronizedSortedMapUnitTest.java similarity index 97% rename from core-java-collections/src/test/java/com/baeldung/synchronizedcollections/test/SynchronizedSortedMapUnitTest.java rename to core-java-modules/core-java-collections/src/test/java/com/baeldung/synchronizedcollections/test/SynchronizedSortedMapUnitTest.java index 4b0ed6d8c8..23933b2b4b 100644 --- a/core-java-collections/src/test/java/com/baeldung/synchronizedcollections/test/SynchronizedSortedMapUnitTest.java +++ b/core-java-modules/core-java-collections/src/test/java/com/baeldung/synchronizedcollections/test/SynchronizedSortedMapUnitTest.java @@ -1,29 +1,29 @@ -package com.baeldung.synchronizedcollections.test; - -import java.util.Collections; -import java.util.Map; -import java.util.TreeMap; -import static org.assertj.core.api.Assertions.assertThat; -import org.junit.Test; - -public class SynchronizedSortedMapUnitTest { - - @Test - public void givenSynchronizedSorteMap_whenTwoThreadsAddElements_thenCorrectSortedMapSize() throws InterruptedException { - Map syncSortedMap = Collections.synchronizedSortedMap(new TreeMap<>()); - - Runnable sortedMapOperations = () -> { - syncSortedMap.put(1, "One"); - syncSortedMap.put(2, "Two"); - syncSortedMap.put(3, "Three"); - }; - Thread thread1 = new Thread(sortedMapOperations); - Thread thread2 = new Thread(sortedMapOperations); - thread1.start(); - thread2.start(); - thread1.join(); - thread2.join(); - - assertThat(syncSortedMap.size()).isEqualTo(3); - } -} +package com.baeldung.synchronizedcollections.test; + +import java.util.Collections; +import java.util.Map; +import java.util.TreeMap; +import static org.assertj.core.api.Assertions.assertThat; +import org.junit.Test; + +public class SynchronizedSortedMapUnitTest { + + @Test + public void givenSynchronizedSorteMap_whenTwoThreadsAddElements_thenCorrectSortedMapSize() throws InterruptedException { + Map syncSortedMap = Collections.synchronizedSortedMap(new TreeMap<>()); + + Runnable sortedMapOperations = () -> { + syncSortedMap.put(1, "One"); + syncSortedMap.put(2, "Two"); + syncSortedMap.put(3, "Three"); + }; + Thread thread1 = new Thread(sortedMapOperations); + Thread thread2 = new Thread(sortedMapOperations); + thread1.start(); + thread2.start(); + thread1.join(); + thread2.join(); + + assertThat(syncSortedMap.size()).isEqualTo(3); + } +} diff --git a/core-java-collections/src/test/java/com/baeldung/synchronizedcollections/test/SynchronizedSortedSetUnitTest.java b/core-java-modules/core-java-collections/src/test/java/com/baeldung/synchronizedcollections/test/SynchronizedSortedSetUnitTest.java similarity index 97% rename from core-java-collections/src/test/java/com/baeldung/synchronizedcollections/test/SynchronizedSortedSetUnitTest.java rename to core-java-modules/core-java-collections/src/test/java/com/baeldung/synchronizedcollections/test/SynchronizedSortedSetUnitTest.java index 0e26c6eb1c..3ce1e6ed26 100644 --- a/core-java-collections/src/test/java/com/baeldung/synchronizedcollections/test/SynchronizedSortedSetUnitTest.java +++ b/core-java-modules/core-java-collections/src/test/java/com/baeldung/synchronizedcollections/test/SynchronizedSortedSetUnitTest.java @@ -1,28 +1,28 @@ -package com.baeldung.synchronizedcollections.test; - -import java.util.Arrays; -import java.util.Collections; -import java.util.SortedSet; -import java.util.TreeSet; -import static org.assertj.core.api.Assertions.assertThat; -import org.junit.Test; - -public class SynchronizedSortedSetUnitTest { - - @Test - public void givenSynchronizedSortedSet_whenTwoThreadsAddElements_thenCorrectSortedSetSize() throws InterruptedException { - SortedSet syncSortedSet = Collections.synchronizedSortedSet(new TreeSet<>()); - - Runnable sortedSetOperations = () -> {syncSortedSet.addAll(Arrays.asList(1, 2, 3, 4, 5, 6));}; - sortedSetOperations.run(); - sortedSetOperations.run(); - Thread thread1 = new Thread(sortedSetOperations); - Thread thread2 = new Thread(sortedSetOperations); - thread1.start(); - thread2.start(); - thread1.join(); - thread2.join(); - - assertThat(syncSortedSet.size()).isEqualTo(6); - } -} +package com.baeldung.synchronizedcollections.test; + +import java.util.Arrays; +import java.util.Collections; +import java.util.SortedSet; +import java.util.TreeSet; +import static org.assertj.core.api.Assertions.assertThat; +import org.junit.Test; + +public class SynchronizedSortedSetUnitTest { + + @Test + public void givenSynchronizedSortedSet_whenTwoThreadsAddElements_thenCorrectSortedSetSize() throws InterruptedException { + SortedSet syncSortedSet = Collections.synchronizedSortedSet(new TreeSet<>()); + + Runnable sortedSetOperations = () -> {syncSortedSet.addAll(Arrays.asList(1, 2, 3, 4, 5, 6));}; + sortedSetOperations.run(); + sortedSetOperations.run(); + Thread thread1 = new Thread(sortedSetOperations); + Thread thread2 = new Thread(sortedSetOperations); + thread1.start(); + thread2.start(); + thread1.join(); + thread2.join(); + + assertThat(syncSortedSet.size()).isEqualTo(6); + } +} diff --git a/core-java-collections/src/test/java/org/baeldung/java/collections/CollectionsConcatenateUnitTest.java b/core-java-modules/core-java-collections/src/test/java/org/baeldung/java/collections/CollectionsConcatenateUnitTest.java similarity index 100% rename from core-java-collections/src/test/java/org/baeldung/java/collections/CollectionsConcatenateUnitTest.java rename to core-java-modules/core-java-collections/src/test/java/org/baeldung/java/collections/CollectionsConcatenateUnitTest.java diff --git a/core-java-collections/src/test/java/org/baeldung/java/collections/CollectionsJoinAndSplitJUnitTest.java b/core-java-modules/core-java-collections/src/test/java/org/baeldung/java/collections/CollectionsJoinAndSplitJUnitTest.java similarity index 100% rename from core-java-collections/src/test/java/org/baeldung/java/collections/CollectionsJoinAndSplitJUnitTest.java rename to core-java-modules/core-java-collections/src/test/java/org/baeldung/java/collections/CollectionsJoinAndSplitJUnitTest.java diff --git a/core-java-collections/src/test/java/org/baeldung/java/collections/JoinSplitCollectionsUnitTest.java b/core-java-modules/core-java-collections/src/test/java/org/baeldung/java/collections/JoinSplitCollectionsUnitTest.java similarity index 100% rename from core-java-collections/src/test/java/org/baeldung/java/collections/JoinSplitCollectionsUnitTest.java rename to core-java-modules/core-java-collections/src/test/java/org/baeldung/java/collections/JoinSplitCollectionsUnitTest.java diff --git a/core-java-collections/src/test/java/org/baeldung/java/collections/README.md b/core-java-modules/core-java-collections/src/test/java/org/baeldung/java/collections/README.md similarity index 100% rename from core-java-collections/src/test/java/org/baeldung/java/collections/README.md rename to core-java-modules/core-java-collections/src/test/java/org/baeldung/java/collections/README.md diff --git a/core-java-collections/src/test/java/org/baeldung/java/sorting/Employee.java b/core-java-modules/core-java-collections/src/test/java/org/baeldung/java/sorting/Employee.java similarity index 100% rename from core-java-collections/src/test/java/org/baeldung/java/sorting/Employee.java rename to core-java-modules/core-java-collections/src/test/java/org/baeldung/java/sorting/Employee.java diff --git a/core-java-collections/src/test/java/org/baeldung/java/sorting/JavaSortingUnitTest.java b/core-java-modules/core-java-collections/src/test/java/org/baeldung/java/sorting/JavaSortingUnitTest.java similarity index 100% rename from core-java-collections/src/test/java/org/baeldung/java/sorting/JavaSortingUnitTest.java rename to core-java-modules/core-java-collections/src/test/java/org/baeldung/java/sorting/JavaSortingUnitTest.java diff --git a/core-java-concurrency-advanced/.gitignore b/core-java-modules/core-java-concurrency-advanced/.gitignore similarity index 100% rename from core-java-concurrency-advanced/.gitignore rename to core-java-modules/core-java-concurrency-advanced/.gitignore diff --git a/core-java-concurrency-advanced/README.md b/core-java-modules/core-java-concurrency-advanced/README.md similarity index 100% rename from core-java-concurrency-advanced/README.md rename to core-java-modules/core-java-concurrency-advanced/README.md diff --git a/core-java-concurrency-advanced/pom.xml b/core-java-modules/core-java-concurrency-advanced/pom.xml similarity index 98% rename from core-java-concurrency-advanced/pom.xml rename to core-java-modules/core-java-concurrency-advanced/pom.xml index 23032fb2e1..a3ac7aa88a 100644 --- a/core-java-concurrency-advanced/pom.xml +++ b/core-java-modules/core-java-concurrency-advanced/pom.xml @@ -11,7 +11,7 @@ com.baeldung parent-java 0.0.1-SNAPSHOT - ../parent-java + ../../parent-java diff --git a/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/atomic/SafeCounterWithLock.java b/core-java-modules/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/atomic/SafeCounterWithLock.java similarity index 100% rename from core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/atomic/SafeCounterWithLock.java rename to core-java-modules/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/atomic/SafeCounterWithLock.java diff --git a/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/atomic/SafeCounterWithoutLock.java b/core-java-modules/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/atomic/SafeCounterWithoutLock.java similarity index 100% rename from core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/atomic/SafeCounterWithoutLock.java rename to core-java-modules/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/atomic/SafeCounterWithoutLock.java diff --git a/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/atomic/UnsafeCounter.java b/core-java-modules/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/atomic/UnsafeCounter.java similarity index 100% rename from core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/atomic/UnsafeCounter.java rename to core-java-modules/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/atomic/UnsafeCounter.java diff --git a/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/countdownlatch/BrokenWorker.java b/core-java-modules/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/countdownlatch/BrokenWorker.java similarity index 100% rename from core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/countdownlatch/BrokenWorker.java rename to core-java-modules/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/countdownlatch/BrokenWorker.java diff --git a/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/countdownlatch/CountdownLatchCountExample.java b/core-java-modules/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/countdownlatch/CountdownLatchCountExample.java similarity index 100% rename from core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/countdownlatch/CountdownLatchCountExample.java rename to core-java-modules/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/countdownlatch/CountdownLatchCountExample.java diff --git a/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/countdownlatch/CountdownLatchResetExample.java b/core-java-modules/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/countdownlatch/CountdownLatchResetExample.java similarity index 100% rename from core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/countdownlatch/CountdownLatchResetExample.java rename to core-java-modules/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/countdownlatch/CountdownLatchResetExample.java diff --git a/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/countdownlatch/WaitingWorker.java b/core-java-modules/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/countdownlatch/WaitingWorker.java similarity index 100% rename from core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/countdownlatch/WaitingWorker.java rename to core-java-modules/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/countdownlatch/WaitingWorker.java diff --git a/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/countdownlatch/Worker.java b/core-java-modules/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/countdownlatch/Worker.java similarity index 100% rename from core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/countdownlatch/Worker.java rename to core-java-modules/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/countdownlatch/Worker.java diff --git a/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/cyclicbarrier/CyclicBarrierCompletionMethodExample.java b/core-java-modules/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/cyclicbarrier/CyclicBarrierCompletionMethodExample.java similarity index 100% rename from core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/cyclicbarrier/CyclicBarrierCompletionMethodExample.java rename to core-java-modules/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/cyclicbarrier/CyclicBarrierCompletionMethodExample.java diff --git a/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/cyclicbarrier/CyclicBarrierCountExample.java b/core-java-modules/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/cyclicbarrier/CyclicBarrierCountExample.java similarity index 100% rename from core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/cyclicbarrier/CyclicBarrierCountExample.java rename to core-java-modules/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/cyclicbarrier/CyclicBarrierCountExample.java diff --git a/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/cyclicbarrier/CyclicBarrierDemo.java b/core-java-modules/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/cyclicbarrier/CyclicBarrierDemo.java similarity index 100% rename from core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/cyclicbarrier/CyclicBarrierDemo.java rename to core-java-modules/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/cyclicbarrier/CyclicBarrierDemo.java diff --git a/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/cyclicbarrier/CyclicBarrierResetExample.java b/core-java-modules/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/cyclicbarrier/CyclicBarrierResetExample.java similarity index 100% rename from core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/cyclicbarrier/CyclicBarrierResetExample.java rename to core-java-modules/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/cyclicbarrier/CyclicBarrierResetExample.java diff --git a/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/daemon/MultipleThreadsExample.java b/core-java-modules/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/daemon/MultipleThreadsExample.java similarity index 100% rename from core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/daemon/MultipleThreadsExample.java rename to core-java-modules/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/daemon/MultipleThreadsExample.java diff --git a/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/daemon/NewThread.java b/core-java-modules/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/daemon/NewThread.java similarity index 100% rename from core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/daemon/NewThread.java rename to core-java-modules/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/daemon/NewThread.java diff --git a/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/daemon/SingleThreadExample.java b/core-java-modules/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/daemon/SingleThreadExample.java similarity index 100% rename from core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/daemon/SingleThreadExample.java rename to core-java-modules/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/daemon/SingleThreadExample.java diff --git a/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/diningphilosophers/DiningPhilosophers.java b/core-java-modules/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/diningphilosophers/DiningPhilosophers.java similarity index 100% rename from core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/diningphilosophers/DiningPhilosophers.java rename to core-java-modules/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/diningphilosophers/DiningPhilosophers.java diff --git a/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/diningphilosophers/Philosopher.java b/core-java-modules/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/diningphilosophers/Philosopher.java similarity index 100% rename from core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/diningphilosophers/Philosopher.java rename to core-java-modules/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/diningphilosophers/Philosopher.java diff --git a/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/evenandodd/PrintEvenOddSemaphore.java b/core-java-modules/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/evenandodd/PrintEvenOddSemaphore.java similarity index 100% rename from core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/evenandodd/PrintEvenOddSemaphore.java rename to core-java-modules/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/evenandodd/PrintEvenOddSemaphore.java diff --git a/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/evenandodd/PrintEvenOddWaitNotify.java b/core-java-modules/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/evenandodd/PrintEvenOddWaitNotify.java similarity index 100% rename from core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/evenandodd/PrintEvenOddWaitNotify.java rename to core-java-modules/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/evenandodd/PrintEvenOddWaitNotify.java diff --git a/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/locks/ReentrantLockWithCondition.java b/core-java-modules/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/locks/ReentrantLockWithCondition.java similarity index 100% rename from core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/locks/ReentrantLockWithCondition.java rename to core-java-modules/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/locks/ReentrantLockWithCondition.java diff --git a/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/locks/SharedObjectWithLock.java b/core-java-modules/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/locks/SharedObjectWithLock.java similarity index 100% rename from core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/locks/SharedObjectWithLock.java rename to core-java-modules/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/locks/SharedObjectWithLock.java diff --git a/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/locks/StampedLockDemo.java b/core-java-modules/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/locks/StampedLockDemo.java similarity index 100% rename from core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/locks/StampedLockDemo.java rename to core-java-modules/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/locks/StampedLockDemo.java diff --git a/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/locks/SynchronizedHashMapWithRWLock.java b/core-java-modules/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/locks/SynchronizedHashMapWithRWLock.java similarity index 100% rename from core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/locks/SynchronizedHashMapWithRWLock.java rename to core-java-modules/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/locks/SynchronizedHashMapWithRWLock.java diff --git a/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/parameter/AverageCalculator.java b/core-java-modules/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/parameter/AverageCalculator.java similarity index 100% rename from core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/parameter/AverageCalculator.java rename to core-java-modules/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/parameter/AverageCalculator.java diff --git a/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/parameter/ParameterizedThreadExample.java b/core-java-modules/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/parameter/ParameterizedThreadExample.java similarity index 100% rename from core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/parameter/ParameterizedThreadExample.java rename to core-java-modules/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/parameter/ParameterizedThreadExample.java diff --git a/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/phaser/LongRunningAction.java b/core-java-modules/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/phaser/LongRunningAction.java similarity index 100% rename from core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/phaser/LongRunningAction.java rename to core-java-modules/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/phaser/LongRunningAction.java diff --git a/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/prioritytaskexecution/Job.java b/core-java-modules/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/prioritytaskexecution/Job.java similarity index 100% rename from core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/prioritytaskexecution/Job.java rename to core-java-modules/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/prioritytaskexecution/Job.java diff --git a/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/prioritytaskexecution/JobPriority.java b/core-java-modules/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/prioritytaskexecution/JobPriority.java similarity index 100% rename from core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/prioritytaskexecution/JobPriority.java rename to core-java-modules/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/prioritytaskexecution/JobPriority.java diff --git a/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/prioritytaskexecution/PriorityJobScheduler.java b/core-java-modules/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/prioritytaskexecution/PriorityJobScheduler.java similarity index 100% rename from core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/prioritytaskexecution/PriorityJobScheduler.java rename to core-java-modules/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/prioritytaskexecution/PriorityJobScheduler.java diff --git a/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/semaphores/CounterUsingMutex.java b/core-java-modules/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/semaphores/CounterUsingMutex.java similarity index 100% rename from core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/semaphores/CounterUsingMutex.java rename to core-java-modules/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/semaphores/CounterUsingMutex.java diff --git a/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/semaphores/DelayQueueUsingTimedSemaphore.java b/core-java-modules/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/semaphores/DelayQueueUsingTimedSemaphore.java similarity index 100% rename from core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/semaphores/DelayQueueUsingTimedSemaphore.java rename to core-java-modules/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/semaphores/DelayQueueUsingTimedSemaphore.java diff --git a/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/semaphores/LoginQueueUsingSemaphore.java b/core-java-modules/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/semaphores/LoginQueueUsingSemaphore.java similarity index 100% rename from core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/semaphores/LoginQueueUsingSemaphore.java rename to core-java-modules/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/semaphores/LoginQueueUsingSemaphore.java diff --git a/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/volatilekeyword/SharedObject.java b/core-java-modules/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/volatilekeyword/SharedObject.java similarity index 100% rename from core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/volatilekeyword/SharedObject.java rename to core-java-modules/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/volatilekeyword/SharedObject.java diff --git a/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/yield/ThreadYield.java b/core-java-modules/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/yield/ThreadYield.java similarity index 100% rename from core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/yield/ThreadYield.java rename to core-java-modules/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/yield/ThreadYield.java diff --git a/core-java-concurrency-advanced/src/main/java/com/baeldung/forkjoin/CustomRecursiveAction.java b/core-java-modules/core-java-concurrency-advanced/src/main/java/com/baeldung/forkjoin/CustomRecursiveAction.java similarity index 100% rename from core-java-concurrency-advanced/src/main/java/com/baeldung/forkjoin/CustomRecursiveAction.java rename to core-java-modules/core-java-concurrency-advanced/src/main/java/com/baeldung/forkjoin/CustomRecursiveAction.java diff --git a/core-java-concurrency-advanced/src/main/java/com/baeldung/forkjoin/CustomRecursiveTask.java b/core-java-modules/core-java-concurrency-advanced/src/main/java/com/baeldung/forkjoin/CustomRecursiveTask.java similarity index 100% rename from core-java-concurrency-advanced/src/main/java/com/baeldung/forkjoin/CustomRecursiveTask.java rename to core-java-modules/core-java-concurrency-advanced/src/main/java/com/baeldung/forkjoin/CustomRecursiveTask.java diff --git a/core-java-concurrency-advanced/src/main/java/com/baeldung/forkjoin/util/PoolUtil.java b/core-java-modules/core-java-concurrency-advanced/src/main/java/com/baeldung/forkjoin/util/PoolUtil.java similarity index 100% rename from core-java-concurrency-advanced/src/main/java/com/baeldung/forkjoin/util/PoolUtil.java rename to core-java-modules/core-java-concurrency-advanced/src/main/java/com/baeldung/forkjoin/util/PoolUtil.java diff --git a/core-java-concurrency-advanced/src/main/java/com/baeldung/threadlocal/Context.java b/core-java-modules/core-java-concurrency-advanced/src/main/java/com/baeldung/threadlocal/Context.java similarity index 100% rename from core-java-concurrency-advanced/src/main/java/com/baeldung/threadlocal/Context.java rename to core-java-modules/core-java-concurrency-advanced/src/main/java/com/baeldung/threadlocal/Context.java diff --git a/core-java-concurrency-advanced/src/main/java/com/baeldung/threadlocal/SharedMapWithUserContext.java b/core-java-modules/core-java-concurrency-advanced/src/main/java/com/baeldung/threadlocal/SharedMapWithUserContext.java similarity index 100% rename from core-java-concurrency-advanced/src/main/java/com/baeldung/threadlocal/SharedMapWithUserContext.java rename to core-java-modules/core-java-concurrency-advanced/src/main/java/com/baeldung/threadlocal/SharedMapWithUserContext.java diff --git a/core-java-concurrency-advanced/src/main/java/com/baeldung/threadlocal/ThreadLocalWithUserContext.java b/core-java-modules/core-java-concurrency-advanced/src/main/java/com/baeldung/threadlocal/ThreadLocalWithUserContext.java similarity index 100% rename from core-java-concurrency-advanced/src/main/java/com/baeldung/threadlocal/ThreadLocalWithUserContext.java rename to core-java-modules/core-java-concurrency-advanced/src/main/java/com/baeldung/threadlocal/ThreadLocalWithUserContext.java diff --git a/core-java-concurrency-advanced/src/main/java/com/baeldung/threadlocal/UserRepository.java b/core-java-modules/core-java-concurrency-advanced/src/main/java/com/baeldung/threadlocal/UserRepository.java similarity index 100% rename from core-java-concurrency-advanced/src/main/java/com/baeldung/threadlocal/UserRepository.java rename to core-java-modules/core-java-concurrency-advanced/src/main/java/com/baeldung/threadlocal/UserRepository.java diff --git a/core-java-concurrency-advanced/src/main/java/com/baeldung/threadlocalrandom/ThreadLocalRandomBenchMarkRunner.java b/core-java-modules/core-java-concurrency-advanced/src/main/java/com/baeldung/threadlocalrandom/ThreadLocalRandomBenchMarkRunner.java similarity index 100% rename from core-java-concurrency-advanced/src/main/java/com/baeldung/threadlocalrandom/ThreadLocalRandomBenchMarkRunner.java rename to core-java-modules/core-java-concurrency-advanced/src/main/java/com/baeldung/threadlocalrandom/ThreadLocalRandomBenchMarkRunner.java diff --git a/core-java-concurrency-advanced/src/main/java/com/baeldung/threadlocalrandom/ThreadLocalRandomBenchMarker.java b/core-java-modules/core-java-concurrency-advanced/src/main/java/com/baeldung/threadlocalrandom/ThreadLocalRandomBenchMarker.java similarity index 100% rename from core-java-concurrency-advanced/src/main/java/com/baeldung/threadlocalrandom/ThreadLocalRandomBenchMarker.java rename to core-java-modules/core-java-concurrency-advanced/src/main/java/com/baeldung/threadlocalrandom/ThreadLocalRandomBenchMarker.java diff --git a/core-java-concurrency-advanced/src/main/java/com/baeldung/threadpool/CountingTask.java b/core-java-modules/core-java-concurrency-advanced/src/main/java/com/baeldung/threadpool/CountingTask.java similarity index 100% rename from core-java-concurrency-advanced/src/main/java/com/baeldung/threadpool/CountingTask.java rename to core-java-modules/core-java-concurrency-advanced/src/main/java/com/baeldung/threadpool/CountingTask.java diff --git a/core-java-concurrency-advanced/src/main/java/com/baeldung/threadpool/ExitingExecutorServiceExample.java b/core-java-modules/core-java-concurrency-advanced/src/main/java/com/baeldung/threadpool/ExitingExecutorServiceExample.java similarity index 100% rename from core-java-concurrency-advanced/src/main/java/com/baeldung/threadpool/ExitingExecutorServiceExample.java rename to core-java-modules/core-java-concurrency-advanced/src/main/java/com/baeldung/threadpool/ExitingExecutorServiceExample.java diff --git a/core-java-concurrency-advanced/src/main/java/com/baeldung/threadpool/TreeNode.java b/core-java-modules/core-java-concurrency-advanced/src/main/java/com/baeldung/threadpool/TreeNode.java similarity index 100% rename from core-java-concurrency-advanced/src/main/java/com/baeldung/threadpool/TreeNode.java rename to core-java-modules/core-java-concurrency-advanced/src/main/java/com/baeldung/threadpool/TreeNode.java diff --git a/core-java-concurrency-advanced/src/main/java/log4j.properties b/core-java-modules/core-java-concurrency-advanced/src/main/java/log4j.properties similarity index 100% rename from core-java-concurrency-advanced/src/main/java/log4j.properties rename to core-java-modules/core-java-concurrency-advanced/src/main/java/log4j.properties diff --git a/core-java-concurrency-advanced/src/main/resources/logback.xml b/core-java-modules/core-java-concurrency-advanced/src/main/resources/logback.xml similarity index 100% rename from core-java-concurrency-advanced/src/main/resources/logback.xml rename to core-java-modules/core-java-concurrency-advanced/src/main/resources/logback.xml diff --git a/core-java-concurrency-advanced/src/test/java/com/baeldung/concurrent/accumulator/LongAccumulatorUnitTest.java b/core-java-modules/core-java-concurrency-advanced/src/test/java/com/baeldung/concurrent/accumulator/LongAccumulatorUnitTest.java similarity index 100% rename from core-java-concurrency-advanced/src/test/java/com/baeldung/concurrent/accumulator/LongAccumulatorUnitTest.java rename to core-java-modules/core-java-concurrency-advanced/src/test/java/com/baeldung/concurrent/accumulator/LongAccumulatorUnitTest.java diff --git a/core-java-concurrency-advanced/src/test/java/com/baeldung/concurrent/adder/LongAdderUnitTest.java b/core-java-modules/core-java-concurrency-advanced/src/test/java/com/baeldung/concurrent/adder/LongAdderUnitTest.java similarity index 100% rename from core-java-concurrency-advanced/src/test/java/com/baeldung/concurrent/adder/LongAdderUnitTest.java rename to core-java-modules/core-java-concurrency-advanced/src/test/java/com/baeldung/concurrent/adder/LongAdderUnitTest.java diff --git a/core-java-concurrency-advanced/src/test/java/com/baeldung/concurrent/atomic/ThreadSafeCounterIntegrationTest.java b/core-java-modules/core-java-concurrency-advanced/src/test/java/com/baeldung/concurrent/atomic/ThreadSafeCounterIntegrationTest.java similarity index 100% rename from core-java-concurrency-advanced/src/test/java/com/baeldung/concurrent/atomic/ThreadSafeCounterIntegrationTest.java rename to core-java-modules/core-java-concurrency-advanced/src/test/java/com/baeldung/concurrent/atomic/ThreadSafeCounterIntegrationTest.java diff --git a/core-java-concurrency-advanced/src/test/java/com/baeldung/concurrent/atomic/ThreadUnsafeCounterManualTest.java b/core-java-modules/core-java-concurrency-advanced/src/test/java/com/baeldung/concurrent/atomic/ThreadUnsafeCounterManualTest.java similarity index 100% rename from core-java-concurrency-advanced/src/test/java/com/baeldung/concurrent/atomic/ThreadUnsafeCounterManualTest.java rename to core-java-modules/core-java-concurrency-advanced/src/test/java/com/baeldung/concurrent/atomic/ThreadUnsafeCounterManualTest.java diff --git a/core-java-concurrency-advanced/src/test/java/com/baeldung/concurrent/countdownlatch/CountdownLatchCountExampleUnitTest.java b/core-java-modules/core-java-concurrency-advanced/src/test/java/com/baeldung/concurrent/countdownlatch/CountdownLatchCountExampleUnitTest.java similarity index 100% rename from core-java-concurrency-advanced/src/test/java/com/baeldung/concurrent/countdownlatch/CountdownLatchCountExampleUnitTest.java rename to core-java-modules/core-java-concurrency-advanced/src/test/java/com/baeldung/concurrent/countdownlatch/CountdownLatchCountExampleUnitTest.java diff --git a/core-java-concurrency-advanced/src/test/java/com/baeldung/concurrent/countdownlatch/CountdownLatchExampleIntegrationTest.java b/core-java-modules/core-java-concurrency-advanced/src/test/java/com/baeldung/concurrent/countdownlatch/CountdownLatchExampleIntegrationTest.java similarity index 100% rename from core-java-concurrency-advanced/src/test/java/com/baeldung/concurrent/countdownlatch/CountdownLatchExampleIntegrationTest.java rename to core-java-modules/core-java-concurrency-advanced/src/test/java/com/baeldung/concurrent/countdownlatch/CountdownLatchExampleIntegrationTest.java diff --git a/core-java-concurrency-advanced/src/test/java/com/baeldung/concurrent/countdownlatch/CountdownLatchResetExampleUnitTest.java b/core-java-modules/core-java-concurrency-advanced/src/test/java/com/baeldung/concurrent/countdownlatch/CountdownLatchResetExampleUnitTest.java similarity index 100% rename from core-java-concurrency-advanced/src/test/java/com/baeldung/concurrent/countdownlatch/CountdownLatchResetExampleUnitTest.java rename to core-java-modules/core-java-concurrency-advanced/src/test/java/com/baeldung/concurrent/countdownlatch/CountdownLatchResetExampleUnitTest.java diff --git a/core-java-concurrency-advanced/src/test/java/com/baeldung/concurrent/cyclicbarrier/CyclicBarrierCompletionMethodExampleUnitTest.java b/core-java-modules/core-java-concurrency-advanced/src/test/java/com/baeldung/concurrent/cyclicbarrier/CyclicBarrierCompletionMethodExampleUnitTest.java similarity index 100% rename from core-java-concurrency-advanced/src/test/java/com/baeldung/concurrent/cyclicbarrier/CyclicBarrierCompletionMethodExampleUnitTest.java rename to core-java-modules/core-java-concurrency-advanced/src/test/java/com/baeldung/concurrent/cyclicbarrier/CyclicBarrierCompletionMethodExampleUnitTest.java diff --git a/core-java-concurrency-advanced/src/test/java/com/baeldung/concurrent/cyclicbarrier/CyclicBarrierCountExampleUnitTest.java b/core-java-modules/core-java-concurrency-advanced/src/test/java/com/baeldung/concurrent/cyclicbarrier/CyclicBarrierCountExampleUnitTest.java similarity index 100% rename from core-java-concurrency-advanced/src/test/java/com/baeldung/concurrent/cyclicbarrier/CyclicBarrierCountExampleUnitTest.java rename to core-java-modules/core-java-concurrency-advanced/src/test/java/com/baeldung/concurrent/cyclicbarrier/CyclicBarrierCountExampleUnitTest.java diff --git a/core-java-concurrency-advanced/src/test/java/com/baeldung/concurrent/cyclicbarrier/CyclicBarrierResetExampleUnitTest.java b/core-java-modules/core-java-concurrency-advanced/src/test/java/com/baeldung/concurrent/cyclicbarrier/CyclicBarrierResetExampleUnitTest.java similarity index 100% rename from core-java-concurrency-advanced/src/test/java/com/baeldung/concurrent/cyclicbarrier/CyclicBarrierResetExampleUnitTest.java rename to core-java-modules/core-java-concurrency-advanced/src/test/java/com/baeldung/concurrent/cyclicbarrier/CyclicBarrierResetExampleUnitTest.java diff --git a/core-java-concurrency-advanced/src/test/java/com/baeldung/concurrent/daemon/DaemonThreadUnitTest.java b/core-java-modules/core-java-concurrency-advanced/src/test/java/com/baeldung/concurrent/daemon/DaemonThreadUnitTest.java similarity index 100% rename from core-java-concurrency-advanced/src/test/java/com/baeldung/concurrent/daemon/DaemonThreadUnitTest.java rename to core-java-modules/core-java-concurrency-advanced/src/test/java/com/baeldung/concurrent/daemon/DaemonThreadUnitTest.java diff --git a/core-java-concurrency-advanced/src/test/java/com/baeldung/concurrent/locks/SharedObjectWithLockManualTest.java b/core-java-modules/core-java-concurrency-advanced/src/test/java/com/baeldung/concurrent/locks/SharedObjectWithLockManualTest.java similarity index 100% rename from core-java-concurrency-advanced/src/test/java/com/baeldung/concurrent/locks/SharedObjectWithLockManualTest.java rename to core-java-modules/core-java-concurrency-advanced/src/test/java/com/baeldung/concurrent/locks/SharedObjectWithLockManualTest.java diff --git a/core-java-concurrency-advanced/src/test/java/com/baeldung/concurrent/locks/SynchronizedHashMapWithRWLockManualTest.java b/core-java-modules/core-java-concurrency-advanced/src/test/java/com/baeldung/concurrent/locks/SynchronizedHashMapWithRWLockManualTest.java similarity index 100% rename from core-java-concurrency-advanced/src/test/java/com/baeldung/concurrent/locks/SynchronizedHashMapWithRWLockManualTest.java rename to core-java-modules/core-java-concurrency-advanced/src/test/java/com/baeldung/concurrent/locks/SynchronizedHashMapWithRWLockManualTest.java diff --git a/core-java-concurrency-advanced/src/test/java/com/baeldung/concurrent/phaser/PhaserUnitTest.java b/core-java-modules/core-java-concurrency-advanced/src/test/java/com/baeldung/concurrent/phaser/PhaserUnitTest.java similarity index 100% rename from core-java-concurrency-advanced/src/test/java/com/baeldung/concurrent/phaser/PhaserUnitTest.java rename to core-java-modules/core-java-concurrency-advanced/src/test/java/com/baeldung/concurrent/phaser/PhaserUnitTest.java diff --git a/core-java-concurrency-advanced/src/test/java/com/baeldung/concurrent/prioritytaskexecution/PriorityJobSchedulerUnitTest.java b/core-java-modules/core-java-concurrency-advanced/src/test/java/com/baeldung/concurrent/prioritytaskexecution/PriorityJobSchedulerUnitTest.java similarity index 100% rename from core-java-concurrency-advanced/src/test/java/com/baeldung/concurrent/prioritytaskexecution/PriorityJobSchedulerUnitTest.java rename to core-java-modules/core-java-concurrency-advanced/src/test/java/com/baeldung/concurrent/prioritytaskexecution/PriorityJobSchedulerUnitTest.java diff --git a/core-java-concurrency-advanced/src/test/java/com/baeldung/concurrent/semaphores/SemaphoresManualTest.java b/core-java-modules/core-java-concurrency-advanced/src/test/java/com/baeldung/concurrent/semaphores/SemaphoresManualTest.java similarity index 100% rename from core-java-concurrency-advanced/src/test/java/com/baeldung/concurrent/semaphores/SemaphoresManualTest.java rename to core-java-modules/core-java-concurrency-advanced/src/test/java/com/baeldung/concurrent/semaphores/SemaphoresManualTest.java diff --git a/core-java-concurrency-advanced/src/test/java/com/baeldung/concurrent/volatilekeyword/SharedObjectManualTest.java b/core-java-modules/core-java-concurrency-advanced/src/test/java/com/baeldung/concurrent/volatilekeyword/SharedObjectManualTest.java similarity index 100% rename from core-java-concurrency-advanced/src/test/java/com/baeldung/concurrent/volatilekeyword/SharedObjectManualTest.java rename to core-java-modules/core-java-concurrency-advanced/src/test/java/com/baeldung/concurrent/volatilekeyword/SharedObjectManualTest.java diff --git a/core-java-concurrency-advanced/src/test/java/com/baeldung/java8/Java8ForkJoinIntegrationTest.java b/core-java-modules/core-java-concurrency-advanced/src/test/java/com/baeldung/java8/Java8ForkJoinIntegrationTest.java similarity index 100% rename from core-java-concurrency-advanced/src/test/java/com/baeldung/java8/Java8ForkJoinIntegrationTest.java rename to core-java-modules/core-java-concurrency-advanced/src/test/java/com/baeldung/java8/Java8ForkJoinIntegrationTest.java diff --git a/core-java-concurrency-advanced/src/test/java/com/baeldung/parameters/ParameterizedThreadUnitTest.java b/core-java-modules/core-java-concurrency-advanced/src/test/java/com/baeldung/parameters/ParameterizedThreadUnitTest.java similarity index 100% rename from core-java-concurrency-advanced/src/test/java/com/baeldung/parameters/ParameterizedThreadUnitTest.java rename to core-java-modules/core-java-concurrency-advanced/src/test/java/com/baeldung/parameters/ParameterizedThreadUnitTest.java diff --git a/core-java-concurrency-advanced/src/test/java/com/baeldung/thread/join/ThreadJoinUnitTest.java b/core-java-modules/core-java-concurrency-advanced/src/test/java/com/baeldung/thread/join/ThreadJoinUnitTest.java similarity index 100% rename from core-java-concurrency-advanced/src/test/java/com/baeldung/thread/join/ThreadJoinUnitTest.java rename to core-java-modules/core-java-concurrency-advanced/src/test/java/com/baeldung/thread/join/ThreadJoinUnitTest.java diff --git a/core-java-concurrency-advanced/src/test/java/com/baeldung/threadlocal/ThreadLocalIntegrationTest.java b/core-java-modules/core-java-concurrency-advanced/src/test/java/com/baeldung/threadlocal/ThreadLocalIntegrationTest.java similarity index 100% rename from core-java-concurrency-advanced/src/test/java/com/baeldung/threadlocal/ThreadLocalIntegrationTest.java rename to core-java-modules/core-java-concurrency-advanced/src/test/java/com/baeldung/threadlocal/ThreadLocalIntegrationTest.java diff --git a/core-java-concurrency-advanced/src/test/java/com/baeldung/threadlocalrandom/ThreadLocalRandomIntegrationTest.java b/core-java-modules/core-java-concurrency-advanced/src/test/java/com/baeldung/threadlocalrandom/ThreadLocalRandomIntegrationTest.java similarity index 100% rename from core-java-concurrency-advanced/src/test/java/com/baeldung/threadlocalrandom/ThreadLocalRandomIntegrationTest.java rename to core-java-modules/core-java-concurrency-advanced/src/test/java/com/baeldung/threadlocalrandom/ThreadLocalRandomIntegrationTest.java diff --git a/core-java-concurrency-advanced/src/test/java/com/baeldung/threadpool/CoreThreadPoolIntegrationTest.java b/core-java-modules/core-java-concurrency-advanced/src/test/java/com/baeldung/threadpool/CoreThreadPoolIntegrationTest.java similarity index 100% rename from core-java-concurrency-advanced/src/test/java/com/baeldung/threadpool/CoreThreadPoolIntegrationTest.java rename to core-java-modules/core-java-concurrency-advanced/src/test/java/com/baeldung/threadpool/CoreThreadPoolIntegrationTest.java diff --git a/core-java-concurrency-advanced/src/test/java/com/baeldung/threadpool/GuavaThreadPoolIntegrationTest.java b/core-java-modules/core-java-concurrency-advanced/src/test/java/com/baeldung/threadpool/GuavaThreadPoolIntegrationTest.java similarity index 100% rename from core-java-concurrency-advanced/src/test/java/com/baeldung/threadpool/GuavaThreadPoolIntegrationTest.java rename to core-java-modules/core-java-concurrency-advanced/src/test/java/com/baeldung/threadpool/GuavaThreadPoolIntegrationTest.java diff --git a/core-java-concurrency-advanced/src/test/resources/.gitignore b/core-java-modules/core-java-concurrency-advanced/src/test/resources/.gitignore similarity index 100% rename from core-java-concurrency-advanced/src/test/resources/.gitignore rename to core-java-modules/core-java-concurrency-advanced/src/test/resources/.gitignore diff --git a/core-java-concurrency-basic/.gitignore b/core-java-modules/core-java-concurrency-basic/.gitignore similarity index 100% rename from core-java-concurrency-basic/.gitignore rename to core-java-modules/core-java-concurrency-basic/.gitignore diff --git a/core-java-concurrency-basic/README.md b/core-java-modules/core-java-concurrency-basic/README.md similarity index 100% rename from core-java-concurrency-basic/README.md rename to core-java-modules/core-java-concurrency-basic/README.md diff --git a/core-java-concurrency-basic/pom.xml b/core-java-modules/core-java-concurrency-basic/pom.xml similarity index 97% rename from core-java-concurrency-basic/pom.xml rename to core-java-modules/core-java-concurrency-basic/pom.xml index 35c360769b..aea4bef6a7 100644 --- a/core-java-concurrency-basic/pom.xml +++ b/core-java-modules/core-java-concurrency-basic/pom.xml @@ -11,7 +11,7 @@ com.baeldung parent-java 0.0.1-SNAPSHOT - ../parent-java + ../../parent-java diff --git a/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/Scheduledexecutorservice/ScheduledExecutorServiceDemo.java b/core-java-modules/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/Scheduledexecutorservice/ScheduledExecutorServiceDemo.java similarity index 100% rename from core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/Scheduledexecutorservice/ScheduledExecutorServiceDemo.java rename to core-java-modules/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/Scheduledexecutorservice/ScheduledExecutorServiceDemo.java diff --git a/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/callable/FactorialTask.java b/core-java-modules/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/callable/FactorialTask.java similarity index 100% rename from core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/callable/FactorialTask.java rename to core-java-modules/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/callable/FactorialTask.java diff --git a/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/cyclicbarrier/CyclicBarrierExample.java b/core-java-modules/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/cyclicbarrier/CyclicBarrierExample.java similarity index 100% rename from core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/cyclicbarrier/CyclicBarrierExample.java rename to core-java-modules/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/cyclicbarrier/CyclicBarrierExample.java diff --git a/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/cyclicbarrier/Task.java b/core-java-modules/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/cyclicbarrier/Task.java similarity index 100% rename from core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/cyclicbarrier/Task.java rename to core-java-modules/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/cyclicbarrier/Task.java diff --git a/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/executor/ExecutorDemo.java b/core-java-modules/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/executor/ExecutorDemo.java similarity index 100% rename from core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/executor/ExecutorDemo.java rename to core-java-modules/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/executor/ExecutorDemo.java diff --git a/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/executor/Invoker.java b/core-java-modules/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/executor/Invoker.java similarity index 100% rename from core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/executor/Invoker.java rename to core-java-modules/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/executor/Invoker.java diff --git a/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/executorservice/DelayedCallable.java b/core-java-modules/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/executorservice/DelayedCallable.java similarity index 100% rename from core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/executorservice/DelayedCallable.java rename to core-java-modules/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/executorservice/DelayedCallable.java diff --git a/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/executorservice/ExecutorServiceDemo.java b/core-java-modules/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/executorservice/ExecutorServiceDemo.java similarity index 100% rename from core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/executorservice/ExecutorServiceDemo.java rename to core-java-modules/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/executorservice/ExecutorServiceDemo.java diff --git a/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/executorservice/Task.java b/core-java-modules/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/executorservice/Task.java similarity index 100% rename from core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/executorservice/Task.java rename to core-java-modules/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/executorservice/Task.java diff --git a/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/future/FactorialSquareCalculator.java b/core-java-modules/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/future/FactorialSquareCalculator.java similarity index 100% rename from core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/future/FactorialSquareCalculator.java rename to core-java-modules/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/future/FactorialSquareCalculator.java diff --git a/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/future/FutureDemo.java b/core-java-modules/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/future/FutureDemo.java similarity index 100% rename from core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/future/FutureDemo.java rename to core-java-modules/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/future/FutureDemo.java diff --git a/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/future/SquareCalculator.java b/core-java-modules/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/future/SquareCalculator.java similarity index 100% rename from core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/future/SquareCalculator.java rename to core-java-modules/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/future/SquareCalculator.java diff --git a/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/runnable/EventLoggingTask.java b/core-java-modules/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/runnable/EventLoggingTask.java similarity index 100% rename from core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/runnable/EventLoggingTask.java rename to core-java-modules/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/runnable/EventLoggingTask.java diff --git a/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/runnable/TaskRunner.java b/core-java-modules/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/runnable/TaskRunner.java similarity index 100% rename from core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/runnable/TaskRunner.java rename to core-java-modules/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/runnable/TaskRunner.java diff --git a/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/semaphore/SemaPhoreDemo.java b/core-java-modules/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/semaphore/SemaPhoreDemo.java similarity index 100% rename from core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/semaphore/SemaPhoreDemo.java rename to core-java-modules/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/semaphore/SemaPhoreDemo.java diff --git a/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/sleepwait/ThreadA.java b/core-java-modules/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/sleepwait/ThreadA.java similarity index 100% rename from core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/sleepwait/ThreadA.java rename to core-java-modules/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/sleepwait/ThreadA.java diff --git a/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/sleepwait/ThreadB.java b/core-java-modules/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/sleepwait/ThreadB.java similarity index 100% rename from core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/sleepwait/ThreadB.java rename to core-java-modules/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/sleepwait/ThreadB.java diff --git a/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/sleepwait/WaitSleepExample.java b/core-java-modules/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/sleepwait/WaitSleepExample.java similarity index 100% rename from core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/sleepwait/WaitSleepExample.java rename to core-java-modules/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/sleepwait/WaitSleepExample.java diff --git a/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/stopping/ControlSubThread.java b/core-java-modules/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/stopping/ControlSubThread.java similarity index 100% rename from core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/stopping/ControlSubThread.java rename to core-java-modules/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/stopping/ControlSubThread.java diff --git a/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/synchronize/BaeldungSynchronizedBlocks.java b/core-java-modules/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/synchronize/BaeldungSynchronizedBlocks.java similarity index 100% rename from core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/synchronize/BaeldungSynchronizedBlocks.java rename to core-java-modules/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/synchronize/BaeldungSynchronizedBlocks.java diff --git a/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/synchronize/BaeldungSynchronizedMethods.java b/core-java-modules/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/synchronize/BaeldungSynchronizedMethods.java similarity index 100% rename from core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/synchronize/BaeldungSynchronizedMethods.java rename to core-java-modules/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/synchronize/BaeldungSynchronizedMethods.java diff --git a/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadfactory/BaeldungThreadFactory.java b/core-java-modules/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadfactory/BaeldungThreadFactory.java similarity index 100% rename from core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadfactory/BaeldungThreadFactory.java rename to core-java-modules/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadfactory/BaeldungThreadFactory.java diff --git a/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadfactory/Demo.java b/core-java-modules/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadfactory/Demo.java similarity index 100% rename from core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadfactory/Demo.java rename to core-java-modules/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadfactory/Demo.java diff --git a/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadfactory/Task.java b/core-java-modules/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadfactory/Task.java similarity index 100% rename from core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadfactory/Task.java rename to core-java-modules/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadfactory/Task.java diff --git a/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadlifecycle/BlockedState.java b/core-java-modules/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadlifecycle/BlockedState.java similarity index 100% rename from core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadlifecycle/BlockedState.java rename to core-java-modules/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadlifecycle/BlockedState.java diff --git a/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadlifecycle/NewState.java b/core-java-modules/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadlifecycle/NewState.java similarity index 100% rename from core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadlifecycle/NewState.java rename to core-java-modules/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadlifecycle/NewState.java diff --git a/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadlifecycle/RunnableState.java b/core-java-modules/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadlifecycle/RunnableState.java similarity index 100% rename from core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadlifecycle/RunnableState.java rename to core-java-modules/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadlifecycle/RunnableState.java diff --git a/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadlifecycle/TerminatedState.java b/core-java-modules/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadlifecycle/TerminatedState.java similarity index 100% rename from core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadlifecycle/TerminatedState.java rename to core-java-modules/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadlifecycle/TerminatedState.java diff --git a/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadlifecycle/TimedWaitingState.java b/core-java-modules/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadlifecycle/TimedWaitingState.java similarity index 100% rename from core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadlifecycle/TimedWaitingState.java rename to core-java-modules/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadlifecycle/TimedWaitingState.java diff --git a/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadlifecycle/WaitingState.java b/core-java-modules/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadlifecycle/WaitingState.java similarity index 100% rename from core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadlifecycle/WaitingState.java rename to core-java-modules/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadlifecycle/WaitingState.java diff --git a/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/application/Application.java b/core-java-modules/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/application/Application.java similarity index 98% rename from core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/application/Application.java rename to core-java-modules/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/application/Application.java index 0c5caba8a0..5fcb28cd2a 100644 --- a/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/application/Application.java +++ b/core-java-modules/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/application/Application.java @@ -1,86 +1,86 @@ -package com.baeldung.concurrent.threadsafety.application; - -import com.baeldung.concurrent.threadsafety.callables.AtomicCounterCallable; -import com.baeldung.concurrent.threadsafety.mathutils.MathUtils; -import com.baeldung.concurrent.threadsafety.callables.CounterCallable; -import com.baeldung.concurrent.threadsafety.callables.ExtrinsicLockCounterCallable; -import com.baeldung.concurrent.threadsafety.callables.MessageServiceCallable; -import com.baeldung.concurrent.threadsafety.callables.ReentranReadWriteLockCounterCallable; -import com.baeldung.concurrent.threadsafety.callables.ReentrantLockCounterCallable; -import com.baeldung.concurrent.threadsafety.services.AtomicCounter; -import com.baeldung.concurrent.threadsafety.services.Counter; -import com.baeldung.concurrent.threadsafety.services.ExtrinsicLockCounter; -import com.baeldung.concurrent.threadsafety.services.MessageService; -import com.baeldung.concurrent.threadsafety.services.ReentrantLockCounter; -import com.baeldung.concurrent.threadsafety.services.ReentrantReadWriteLockCounter; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.Future; - -public class Application { - - public static void main(String[] args) throws InterruptedException, ExecutionException { - - new Thread(() -> { - System.out.println(MathUtils.factorial(10)); - }).start(); - new Thread(() -> { - System.out.println(MathUtils.factorial(5)); - }).start(); - - ExecutorService executorService = Executors.newFixedThreadPool(10); - MessageService messageService = new MessageService("Welcome to Baeldung!"); - Future future1 = (Future) executorService.submit(new MessageServiceCallable(messageService)); - Future future2 = (Future) executorService.submit(new MessageServiceCallable(messageService)); - System.out.println(future1.get()); - System.out.println(future2.get()); - - Counter counter = new Counter(); - Future future3 = (Future) executorService.submit(new CounterCallable(counter)); - Future future4 = (Future) executorService.submit(new CounterCallable(counter)); - System.out.println(future3.get()); - System.out.println(future4.get()); - - ExtrinsicLockCounter extrinsicLockCounter = new ExtrinsicLockCounter(); - Future future5 = (Future) executorService.submit(new ExtrinsicLockCounterCallable(extrinsicLockCounter)); - Future future6 = (Future) executorService.submit(new ExtrinsicLockCounterCallable(extrinsicLockCounter)); - System.out.println(future5.get()); - System.out.println(future6.get()); - - ReentrantLockCounter reentrantLockCounter = new ReentrantLockCounter(); - Future future7 = (Future) executorService.submit(new ReentrantLockCounterCallable(reentrantLockCounter)); - Future future8 = (Future) executorService.submit(new ReentrantLockCounterCallable(reentrantLockCounter)); - System.out.println(future7.get()); - System.out.println(future8.get()); - - ReentrantReadWriteLockCounter reentrantReadWriteLockCounter = new ReentrantReadWriteLockCounter(); - Future future9 = (Future) executorService.submit(new ReentranReadWriteLockCounterCallable(reentrantReadWriteLockCounter)); - Future future10 = (Future) executorService.submit(new ReentranReadWriteLockCounterCallable(reentrantReadWriteLockCounter)); - System.out.println(future9.get()); - System.out.println(future10.get()); - - AtomicCounter atomicCounter = new AtomicCounter(); - Future future11 = (Future) executorService.submit(new AtomicCounterCallable(atomicCounter)); - Future future12 = (Future) executorService.submit(new AtomicCounterCallable(atomicCounter)); - System.out.println(future11.get()); - System.out.println(future12.get()); - - Collection syncCollection = Collections.synchronizedCollection(new ArrayList<>()); - Thread thread11 = new Thread(() -> syncCollection.addAll(Arrays.asList(1, 2, 3, 4, 5, 6))); - Thread thread12 = new Thread(() -> syncCollection.addAll(Arrays.asList(1, 2, 3, 4, 5, 6))); - thread11.start(); - thread12.start(); - - Map concurrentMap = new ConcurrentHashMap<>(); - concurrentMap.put("1", "one"); - concurrentMap.put("2", "two"); - concurrentMap.put("3", "three"); - } -} +package com.baeldung.concurrent.threadsafety.application; + +import com.baeldung.concurrent.threadsafety.callables.AtomicCounterCallable; +import com.baeldung.concurrent.threadsafety.mathutils.MathUtils; +import com.baeldung.concurrent.threadsafety.callables.CounterCallable; +import com.baeldung.concurrent.threadsafety.callables.ExtrinsicLockCounterCallable; +import com.baeldung.concurrent.threadsafety.callables.MessageServiceCallable; +import com.baeldung.concurrent.threadsafety.callables.ReentranReadWriteLockCounterCallable; +import com.baeldung.concurrent.threadsafety.callables.ReentrantLockCounterCallable; +import com.baeldung.concurrent.threadsafety.services.AtomicCounter; +import com.baeldung.concurrent.threadsafety.services.Counter; +import com.baeldung.concurrent.threadsafety.services.ExtrinsicLockCounter; +import com.baeldung.concurrent.threadsafety.services.MessageService; +import com.baeldung.concurrent.threadsafety.services.ReentrantLockCounter; +import com.baeldung.concurrent.threadsafety.services.ReentrantReadWriteLockCounter; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.Future; + +public class Application { + + public static void main(String[] args) throws InterruptedException, ExecutionException { + + new Thread(() -> { + System.out.println(MathUtils.factorial(10)); + }).start(); + new Thread(() -> { + System.out.println(MathUtils.factorial(5)); + }).start(); + + ExecutorService executorService = Executors.newFixedThreadPool(10); + MessageService messageService = new MessageService("Welcome to Baeldung!"); + Future future1 = (Future) executorService.submit(new MessageServiceCallable(messageService)); + Future future2 = (Future) executorService.submit(new MessageServiceCallable(messageService)); + System.out.println(future1.get()); + System.out.println(future2.get()); + + Counter counter = new Counter(); + Future future3 = (Future) executorService.submit(new CounterCallable(counter)); + Future future4 = (Future) executorService.submit(new CounterCallable(counter)); + System.out.println(future3.get()); + System.out.println(future4.get()); + + ExtrinsicLockCounter extrinsicLockCounter = new ExtrinsicLockCounter(); + Future future5 = (Future) executorService.submit(new ExtrinsicLockCounterCallable(extrinsicLockCounter)); + Future future6 = (Future) executorService.submit(new ExtrinsicLockCounterCallable(extrinsicLockCounter)); + System.out.println(future5.get()); + System.out.println(future6.get()); + + ReentrantLockCounter reentrantLockCounter = new ReentrantLockCounter(); + Future future7 = (Future) executorService.submit(new ReentrantLockCounterCallable(reentrantLockCounter)); + Future future8 = (Future) executorService.submit(new ReentrantLockCounterCallable(reentrantLockCounter)); + System.out.println(future7.get()); + System.out.println(future8.get()); + + ReentrantReadWriteLockCounter reentrantReadWriteLockCounter = new ReentrantReadWriteLockCounter(); + Future future9 = (Future) executorService.submit(new ReentranReadWriteLockCounterCallable(reentrantReadWriteLockCounter)); + Future future10 = (Future) executorService.submit(new ReentranReadWriteLockCounterCallable(reentrantReadWriteLockCounter)); + System.out.println(future9.get()); + System.out.println(future10.get()); + + AtomicCounter atomicCounter = new AtomicCounter(); + Future future11 = (Future) executorService.submit(new AtomicCounterCallable(atomicCounter)); + Future future12 = (Future) executorService.submit(new AtomicCounterCallable(atomicCounter)); + System.out.println(future11.get()); + System.out.println(future12.get()); + + Collection syncCollection = Collections.synchronizedCollection(new ArrayList<>()); + Thread thread11 = new Thread(() -> syncCollection.addAll(Arrays.asList(1, 2, 3, 4, 5, 6))); + Thread thread12 = new Thread(() -> syncCollection.addAll(Arrays.asList(1, 2, 3, 4, 5, 6))); + thread11.start(); + thread12.start(); + + Map concurrentMap = new ConcurrentHashMap<>(); + concurrentMap.put("1", "one"); + concurrentMap.put("2", "two"); + concurrentMap.put("3", "three"); + } +} diff --git a/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/callables/AtomicCounterCallable.java b/core-java-modules/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/callables/AtomicCounterCallable.java similarity index 96% rename from core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/callables/AtomicCounterCallable.java rename to core-java-modules/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/callables/AtomicCounterCallable.java index d711299b5c..27f7bf598e 100644 --- a/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/callables/AtomicCounterCallable.java +++ b/core-java-modules/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/callables/AtomicCounterCallable.java @@ -1,19 +1,19 @@ -package com.baeldung.concurrent.threadsafety.callables; - -import com.baeldung.concurrent.threadsafety.services.AtomicCounter; -import java.util.concurrent.Callable; - -public class AtomicCounterCallable implements Callable { - - private final AtomicCounter counter; - - public AtomicCounterCallable(AtomicCounter counter) { - this.counter = counter; - } - - @Override - public Integer call() throws Exception { - counter.incrementCounter(); - return counter.getCounter(); - } -} +package com.baeldung.concurrent.threadsafety.callables; + +import com.baeldung.concurrent.threadsafety.services.AtomicCounter; +import java.util.concurrent.Callable; + +public class AtomicCounterCallable implements Callable { + + private final AtomicCounter counter; + + public AtomicCounterCallable(AtomicCounter counter) { + this.counter = counter; + } + + @Override + public Integer call() throws Exception { + counter.incrementCounter(); + return counter.getCounter(); + } +} diff --git a/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/callables/CounterCallable.java b/core-java-modules/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/callables/CounterCallable.java similarity index 96% rename from core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/callables/CounterCallable.java rename to core-java-modules/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/callables/CounterCallable.java index cdcd84a17b..feca4d7db5 100644 --- a/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/callables/CounterCallable.java +++ b/core-java-modules/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/callables/CounterCallable.java @@ -1,19 +1,19 @@ -package com.baeldung.concurrent.threadsafety.callables; - -import com.baeldung.concurrent.threadsafety.services.Counter; -import java.util.concurrent.Callable; - -public class CounterCallable implements Callable { - - private final Counter counter; - - public CounterCallable(Counter counter) { - this.counter = counter; - } - - @Override - public Integer call() throws Exception { - counter.incrementCounter(); - return counter.getCounter(); - } -} +package com.baeldung.concurrent.threadsafety.callables; + +import com.baeldung.concurrent.threadsafety.services.Counter; +import java.util.concurrent.Callable; + +public class CounterCallable implements Callable { + + private final Counter counter; + + public CounterCallable(Counter counter) { + this.counter = counter; + } + + @Override + public Integer call() throws Exception { + counter.incrementCounter(); + return counter.getCounter(); + } +} diff --git a/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/callables/ExtrinsicLockCounterCallable.java b/core-java-modules/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/callables/ExtrinsicLockCounterCallable.java similarity index 96% rename from core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/callables/ExtrinsicLockCounterCallable.java rename to core-java-modules/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/callables/ExtrinsicLockCounterCallable.java index 29533e7630..370e5d1f00 100644 --- a/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/callables/ExtrinsicLockCounterCallable.java +++ b/core-java-modules/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/callables/ExtrinsicLockCounterCallable.java @@ -1,19 +1,19 @@ -package com.baeldung.concurrent.threadsafety.callables; - -import com.baeldung.concurrent.threadsafety.services.ExtrinsicLockCounter; -import java.util.concurrent.Callable; - -public class ExtrinsicLockCounterCallable implements Callable { - - private final ExtrinsicLockCounter counter; - - public ExtrinsicLockCounterCallable(ExtrinsicLockCounter counter) { - this.counter = counter; - } - - @Override - public Integer call() throws Exception { - counter.incrementCounter(); - return counter.getCounter(); - } -} +package com.baeldung.concurrent.threadsafety.callables; + +import com.baeldung.concurrent.threadsafety.services.ExtrinsicLockCounter; +import java.util.concurrent.Callable; + +public class ExtrinsicLockCounterCallable implements Callable { + + private final ExtrinsicLockCounter counter; + + public ExtrinsicLockCounterCallable(ExtrinsicLockCounter counter) { + this.counter = counter; + } + + @Override + public Integer call() throws Exception { + counter.incrementCounter(); + return counter.getCounter(); + } +} diff --git a/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/callables/MessageServiceCallable.java b/core-java-modules/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/callables/MessageServiceCallable.java similarity index 96% rename from core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/callables/MessageServiceCallable.java rename to core-java-modules/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/callables/MessageServiceCallable.java index 84e8c7bb51..5fff2de0c8 100644 --- a/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/callables/MessageServiceCallable.java +++ b/core-java-modules/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/callables/MessageServiceCallable.java @@ -1,19 +1,19 @@ -package com.baeldung.concurrent.threadsafety.callables; - -import com.baeldung.concurrent.threadsafety.services.MessageService; -import java.util.concurrent.Callable; - -public class MessageServiceCallable implements Callable { - - private final MessageService messageService; - - public MessageServiceCallable(MessageService messageService) { - this.messageService = messageService; - - } - - @Override - public String call() { - return messageService.getMesssage(); - } -} +package com.baeldung.concurrent.threadsafety.callables; + +import com.baeldung.concurrent.threadsafety.services.MessageService; +import java.util.concurrent.Callable; + +public class MessageServiceCallable implements Callable { + + private final MessageService messageService; + + public MessageServiceCallable(MessageService messageService) { + this.messageService = messageService; + + } + + @Override + public String call() { + return messageService.getMesssage(); + } +} diff --git a/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/callables/ReentranReadWriteLockCounterCallable.java b/core-java-modules/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/callables/ReentranReadWriteLockCounterCallable.java similarity index 96% rename from core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/callables/ReentranReadWriteLockCounterCallable.java rename to core-java-modules/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/callables/ReentranReadWriteLockCounterCallable.java index e806460d50..f0948daa09 100644 --- a/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/callables/ReentranReadWriteLockCounterCallable.java +++ b/core-java-modules/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/callables/ReentranReadWriteLockCounterCallable.java @@ -1,20 +1,20 @@ -package com.baeldung.concurrent.threadsafety.callables; - -import com.baeldung.concurrent.threadsafety.services.ReentrantReadWriteLockCounter; -import java.util.concurrent.Callable; - -public class ReentranReadWriteLockCounterCallable implements Callable { - - private final ReentrantReadWriteLockCounter counter; - - public ReentranReadWriteLockCounterCallable(ReentrantReadWriteLockCounter counter) { - this.counter = counter; - } - - @Override - public Integer call() throws Exception { - counter.incrementCounter(); - return counter.getCounter(); - } - -} +package com.baeldung.concurrent.threadsafety.callables; + +import com.baeldung.concurrent.threadsafety.services.ReentrantReadWriteLockCounter; +import java.util.concurrent.Callable; + +public class ReentranReadWriteLockCounterCallable implements Callable { + + private final ReentrantReadWriteLockCounter counter; + + public ReentranReadWriteLockCounterCallable(ReentrantReadWriteLockCounter counter) { + this.counter = counter; + } + + @Override + public Integer call() throws Exception { + counter.incrementCounter(); + return counter.getCounter(); + } + +} diff --git a/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/callables/ReentrantLockCounterCallable.java b/core-java-modules/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/callables/ReentrantLockCounterCallable.java similarity index 96% rename from core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/callables/ReentrantLockCounterCallable.java rename to core-java-modules/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/callables/ReentrantLockCounterCallable.java index 3511a98c60..572d6ad22f 100644 --- a/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/callables/ReentrantLockCounterCallable.java +++ b/core-java-modules/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/callables/ReentrantLockCounterCallable.java @@ -1,19 +1,19 @@ -package com.baeldung.concurrent.threadsafety.callables; - -import com.baeldung.concurrent.threadsafety.services.ReentrantLockCounter; -import java.util.concurrent.Callable; - -public class ReentrantLockCounterCallable implements Callable { - - private final ReentrantLockCounter counter; - - public ReentrantLockCounterCallable(ReentrantLockCounter counter) { - this.counter = counter; - } - - @Override - public Integer call() throws Exception { - counter.incrementCounter(); - return counter.getCounter(); - } -} +package com.baeldung.concurrent.threadsafety.callables; + +import com.baeldung.concurrent.threadsafety.services.ReentrantLockCounter; +import java.util.concurrent.Callable; + +public class ReentrantLockCounterCallable implements Callable { + + private final ReentrantLockCounter counter; + + public ReentrantLockCounterCallable(ReentrantLockCounter counter) { + this.counter = counter; + } + + @Override + public Integer call() throws Exception { + counter.incrementCounter(); + return counter.getCounter(); + } +} diff --git a/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/mathutils/MathUtils.java b/core-java-modules/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/mathutils/MathUtils.java similarity index 96% rename from core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/mathutils/MathUtils.java rename to core-java-modules/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/mathutils/MathUtils.java index f560cd4281..fa84c9c04d 100644 --- a/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/mathutils/MathUtils.java +++ b/core-java-modules/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/mathutils/MathUtils.java @@ -1,14 +1,14 @@ -package com.baeldung.concurrent.threadsafety.mathutils; - -import java.math.BigInteger; - -public class MathUtils { - - public static BigInteger factorial(int number) { - BigInteger f = new BigInteger("1"); - for (int i = 2; i <= number; i++) { - f = f.multiply(BigInteger.valueOf(i)); - } - return f; - } -} +package com.baeldung.concurrent.threadsafety.mathutils; + +import java.math.BigInteger; + +public class MathUtils { + + public static BigInteger factorial(int number) { + BigInteger f = new BigInteger("1"); + for (int i = 2; i <= number; i++) { + f = f.multiply(BigInteger.valueOf(i)); + } + return f; + } +} diff --git a/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/services/AtomicCounter.java b/core-java-modules/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/services/AtomicCounter.java similarity index 95% rename from core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/services/AtomicCounter.java rename to core-java-modules/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/services/AtomicCounter.java index 32a373495c..0e95859265 100644 --- a/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/services/AtomicCounter.java +++ b/core-java-modules/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/services/AtomicCounter.java @@ -1,18 +1,18 @@ -package com.baeldung.concurrent.threadsafety.services; - -import java.util.concurrent.atomic.AtomicInteger; - -public class AtomicCounter { - - private final AtomicInteger counter = new AtomicInteger(); - - public AtomicCounter() {} - - public void incrementCounter() { - counter.incrementAndGet(); - } - - public synchronized int getCounter() { - return counter.get(); - } -} +package com.baeldung.concurrent.threadsafety.services; + +import java.util.concurrent.atomic.AtomicInteger; + +public class AtomicCounter { + + private final AtomicInteger counter = new AtomicInteger(); + + public AtomicCounter() {} + + public void incrementCounter() { + counter.incrementAndGet(); + } + + public synchronized int getCounter() { + return counter.get(); + } +} diff --git a/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/services/Counter.java b/core-java-modules/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/services/Counter.java similarity index 94% rename from core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/services/Counter.java rename to core-java-modules/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/services/Counter.java index f7dbc05639..52122ae049 100644 --- a/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/services/Counter.java +++ b/core-java-modules/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/services/Counter.java @@ -1,18 +1,18 @@ -package com.baeldung.concurrent.threadsafety.services; - -public class Counter { - - private volatile int counter; - - public Counter() { - this.counter = 0; - } - - public synchronized void incrementCounter() { - counter += 1; - } - - public int getCounter() { - return counter; - } -} +package com.baeldung.concurrent.threadsafety.services; + +public class Counter { + + private volatile int counter; + + public Counter() { + this.counter = 0; + } + + public synchronized void incrementCounter() { + counter += 1; + } + + public int getCounter() { + return counter; + } +} diff --git a/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/services/ExtrinsicLockCounter.java b/core-java-modules/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/services/ExtrinsicLockCounter.java similarity index 95% rename from core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/services/ExtrinsicLockCounter.java rename to core-java-modules/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/services/ExtrinsicLockCounter.java index 8ab431fbc3..0a6ff3f60e 100644 --- a/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/services/ExtrinsicLockCounter.java +++ b/core-java-modules/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/services/ExtrinsicLockCounter.java @@ -1,23 +1,23 @@ -package com.baeldung.concurrent.threadsafety.services; - -public class ExtrinsicLockCounter { - - private int counter; - private final Object lock = new Object(); - - public ExtrinsicLockCounter() { - this.counter = 0; - } - - public void incrementCounter() { - synchronized (lock) { - counter += 1; - } - } - - public int getCounter() { - synchronized (lock) { - return counter; - } - } -} +package com.baeldung.concurrent.threadsafety.services; + +public class ExtrinsicLockCounter { + + private int counter; + private final Object lock = new Object(); + + public ExtrinsicLockCounter() { + this.counter = 0; + } + + public void incrementCounter() { + synchronized (lock) { + counter += 1; + } + } + + public int getCounter() { + synchronized (lock) { + return counter; + } + } +} diff --git a/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/services/MessageService.java b/core-java-modules/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/services/MessageService.java similarity index 95% rename from core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/services/MessageService.java rename to core-java-modules/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/services/MessageService.java index 33981381ea..a2b5174a9b 100644 --- a/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/services/MessageService.java +++ b/core-java-modules/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/services/MessageService.java @@ -1,14 +1,14 @@ -package com.baeldung.concurrent.threadsafety.services; - -public class MessageService { - - private final String message; - - public MessageService(String message) { - this.message = message; - } - - public String getMesssage() { - return message; - } -} +package com.baeldung.concurrent.threadsafety.services; + +public class MessageService { + + private final String message; + + public MessageService(String message) { + this.message = message; + } + + public String getMesssage() { + return message; + } +} diff --git a/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/services/ReentrantLockCounter.java b/core-java-modules/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/services/ReentrantLockCounter.java similarity index 95% rename from core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/services/ReentrantLockCounter.java rename to core-java-modules/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/services/ReentrantLockCounter.java index 717f0717af..346cb14c35 100644 --- a/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/services/ReentrantLockCounter.java +++ b/core-java-modules/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/services/ReentrantLockCounter.java @@ -1,26 +1,26 @@ -package com.baeldung.concurrent.threadsafety.services; - -import java.util.concurrent.locks.ReentrantLock; - -public class ReentrantLockCounter { - - private int counter; - private final ReentrantLock reLock = new ReentrantLock(true); - - public ReentrantLockCounter() { - this.counter = 0; - } - - public void incrementCounter() { - reLock.lock(); - try { - counter += 1; - } finally { - reLock.unlock(); - } - } - - public int getCounter() { - return counter; - } -} +package com.baeldung.concurrent.threadsafety.services; + +import java.util.concurrent.locks.ReentrantLock; + +public class ReentrantLockCounter { + + private int counter; + private final ReentrantLock reLock = new ReentrantLock(true); + + public ReentrantLockCounter() { + this.counter = 0; + } + + public void incrementCounter() { + reLock.lock(); + try { + counter += 1; + } finally { + reLock.unlock(); + } + } + + public int getCounter() { + return counter; + } +} diff --git a/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/services/ReentrantReadWriteLockCounter.java b/core-java-modules/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/services/ReentrantReadWriteLockCounter.java similarity index 96% rename from core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/services/ReentrantReadWriteLockCounter.java rename to core-java-modules/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/services/ReentrantReadWriteLockCounter.java index f740c938b1..5e251441b5 100644 --- a/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/services/ReentrantReadWriteLockCounter.java +++ b/core-java-modules/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/services/ReentrantReadWriteLockCounter.java @@ -1,34 +1,34 @@ -package com.baeldung.concurrent.threadsafety.services; - -import java.util.concurrent.locks.Lock; -import java.util.concurrent.locks.ReentrantReadWriteLock; - -public class ReentrantReadWriteLockCounter { - - private int counter; - private final ReentrantReadWriteLock rwLock = new ReentrantReadWriteLock(); - private final Lock readLock = rwLock.readLock(); - private final Lock writeLock = rwLock.writeLock(); - - public ReentrantReadWriteLockCounter() { - this.counter = 0; - } - - public void incrementCounter() { - writeLock.lock(); - try { - counter += 1; - } finally { - writeLock.unlock(); - } - } - - public int getCounter() { - readLock.lock(); - try { - return counter; - } finally { - readLock.unlock(); - } - } -} +package com.baeldung.concurrent.threadsafety.services; + +import java.util.concurrent.locks.Lock; +import java.util.concurrent.locks.ReentrantReadWriteLock; + +public class ReentrantReadWriteLockCounter { + + private int counter; + private final ReentrantReadWriteLock rwLock = new ReentrantReadWriteLock(); + private final Lock readLock = rwLock.readLock(); + private final Lock writeLock = rwLock.writeLock(); + + public ReentrantReadWriteLockCounter() { + this.counter = 0; + } + + public void incrementCounter() { + writeLock.lock(); + try { + counter += 1; + } finally { + writeLock.unlock(); + } + } + + public int getCounter() { + readLock.lock(); + try { + return counter; + } finally { + readLock.unlock(); + } + } +} diff --git a/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/services/StateHolder.java b/core-java-modules/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/services/StateHolder.java similarity index 94% rename from core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/services/StateHolder.java rename to core-java-modules/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/services/StateHolder.java index 5bbff9f39c..7e87214590 100644 --- a/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/services/StateHolder.java +++ b/core-java-modules/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/services/StateHolder.java @@ -1,14 +1,14 @@ -package com.baeldung.concurrent.threadsafety.services; - -public class StateHolder { - - private final String state; - - public StateHolder(String state) { - this.state = state; - } - - public String getState() { - return state; - } -} +package com.baeldung.concurrent.threadsafety.services; + +public class StateHolder { + + private final String state; + + public StateHolder(String state) { + this.state = state; + } + + public String getState() { + return state; + } +} diff --git a/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/waitandnotify/Data.java b/core-java-modules/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/waitandnotify/Data.java similarity index 100% rename from core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/waitandnotify/Data.java rename to core-java-modules/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/waitandnotify/Data.java diff --git a/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/waitandnotify/NetworkDriver.java b/core-java-modules/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/waitandnotify/NetworkDriver.java similarity index 100% rename from core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/waitandnotify/NetworkDriver.java rename to core-java-modules/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/waitandnotify/NetworkDriver.java diff --git a/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/waitandnotify/Receiver.java b/core-java-modules/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/waitandnotify/Receiver.java similarity index 100% rename from core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/waitandnotify/Receiver.java rename to core-java-modules/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/waitandnotify/Receiver.java diff --git a/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/waitandnotify/Sender.java b/core-java-modules/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/waitandnotify/Sender.java similarity index 100% rename from core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/waitandnotify/Sender.java rename to core-java-modules/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/waitandnotify/Sender.java diff --git a/core-java-concurrency-basic/src/main/resources/logback.xml b/core-java-modules/core-java-concurrency-basic/src/main/resources/logback.xml similarity index 100% rename from core-java-concurrency-basic/src/main/resources/logback.xml rename to core-java-modules/core-java-concurrency-basic/src/main/resources/logback.xml diff --git a/core-java-concurrency-basic/src/test/com/baeldung/concurrent/threadsafety/tests/CounterTest.java b/core-java-modules/core-java-concurrency-basic/src/test/com/baeldung/concurrent/threadsafety/tests/CounterTest.java similarity index 97% rename from core-java-concurrency-basic/src/test/com/baeldung/concurrent/threadsafety/tests/CounterTest.java rename to core-java-modules/core-java-concurrency-basic/src/test/com/baeldung/concurrent/threadsafety/tests/CounterTest.java index 3abbb1bdad..176151083c 100644 --- a/core-java-concurrency-basic/src/test/com/baeldung/concurrent/threadsafety/tests/CounterTest.java +++ b/core-java-modules/core-java-concurrency-basic/src/test/com/baeldung/concurrent/threadsafety/tests/CounterTest.java @@ -1,23 +1,23 @@ -package com.baeldung.concurrent.threadsafety.tests; - -import org.junit.Test; -import static org.assertj.core.api.Assertions.assertThat; -import com.baeldung.concurrent.threadsafety.callables.CounterCallable; -import com.baeldung.concurrent.threadsafety.services.Counter; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.Future; - -public class CounterTest { - - @Test - public void whenCalledIncrementCounter_thenCorrect() throws Exception { - ExecutorService executorService = Executors.newFixedThreadPool(2); - Counter counter = new Counter(); - Future future1 = (Future) executorService.submit(new CounterCallable(counter)); - Future future2 = (Future) executorService.submit(new CounterCallable(counter)); - - assertThat(future1.get()).isEqualTo(1); - assertThat(future2.get()).isEqualTo(2); - } -} +package com.baeldung.concurrent.threadsafety.tests; + +import org.junit.Test; +import static org.assertj.core.api.Assertions.assertThat; +import com.baeldung.concurrent.threadsafety.callables.CounterCallable; +import com.baeldung.concurrent.threadsafety.services.Counter; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.Future; + +public class CounterTest { + + @Test + public void whenCalledIncrementCounter_thenCorrect() throws Exception { + ExecutorService executorService = Executors.newFixedThreadPool(2); + Counter counter = new Counter(); + Future future1 = (Future) executorService.submit(new CounterCallable(counter)); + Future future2 = (Future) executorService.submit(new CounterCallable(counter)); + + assertThat(future1.get()).isEqualTo(1); + assertThat(future2.get()).isEqualTo(2); + } +} diff --git a/core-java-concurrency-basic/src/test/com/baeldung/concurrent/threadsafety/tests/ExtrinsicLockCounterTest.java b/core-java-modules/core-java-concurrency-basic/src/test/com/baeldung/concurrent/threadsafety/tests/ExtrinsicLockCounterTest.java similarity index 97% rename from core-java-concurrency-basic/src/test/com/baeldung/concurrent/threadsafety/tests/ExtrinsicLockCounterTest.java rename to core-java-modules/core-java-concurrency-basic/src/test/com/baeldung/concurrent/threadsafety/tests/ExtrinsicLockCounterTest.java index dba90f5b74..e34eb250bf 100644 --- a/core-java-concurrency-basic/src/test/com/baeldung/concurrent/threadsafety/tests/ExtrinsicLockCounterTest.java +++ b/core-java-modules/core-java-concurrency-basic/src/test/com/baeldung/concurrent/threadsafety/tests/ExtrinsicLockCounterTest.java @@ -1,23 +1,23 @@ -package com.baeldung.concurrent.threadsafety.tests; - -import org.junit.Test; -import static org.assertj.core.api.Assertions.assertThat; -import com.baeldung.concurrent.threadsafety.callables.ExtrinsicLockCounterCallable; -import com.baeldung.concurrent.threadsafety.services.ExtrinsicLockCounter; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.Future; - -public class ExtrinsicLockCounterTest { - - @Test - public void whenCalledIncrementCounter_thenCorrect() throws Exception { - ExecutorService executorService = Executors.newFixedThreadPool(2); - ExtrinsicLockCounter counter = new ExtrinsicLockCounter(); - Future future1 = (Future) executorService.submit(new ExtrinsicLockCounterCallable(counter)); - Future future2 = (Future) executorService.submit(new ExtrinsicLockCounterCallable(counter)); - - assertThat(future1.get()).isEqualTo(1); - assertThat(future2.get()).isEqualTo(2); - } -} +package com.baeldung.concurrent.threadsafety.tests; + +import org.junit.Test; +import static org.assertj.core.api.Assertions.assertThat; +import com.baeldung.concurrent.threadsafety.callables.ExtrinsicLockCounterCallable; +import com.baeldung.concurrent.threadsafety.services.ExtrinsicLockCounter; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.Future; + +public class ExtrinsicLockCounterTest { + + @Test + public void whenCalledIncrementCounter_thenCorrect() throws Exception { + ExecutorService executorService = Executors.newFixedThreadPool(2); + ExtrinsicLockCounter counter = new ExtrinsicLockCounter(); + Future future1 = (Future) executorService.submit(new ExtrinsicLockCounterCallable(counter)); + Future future2 = (Future) executorService.submit(new ExtrinsicLockCounterCallable(counter)); + + assertThat(future1.get()).isEqualTo(1); + assertThat(future2.get()).isEqualTo(2); + } +} diff --git a/core-java-concurrency-basic/src/test/com/baeldung/concurrent/threadsafety/tests/MathUtilsTest.java b/core-java-modules/core-java-concurrency-basic/src/test/com/baeldung/concurrent/threadsafety/tests/MathUtilsTest.java similarity index 96% rename from core-java-concurrency-basic/src/test/com/baeldung/concurrent/threadsafety/tests/MathUtilsTest.java rename to core-java-modules/core-java-concurrency-basic/src/test/com/baeldung/concurrent/threadsafety/tests/MathUtilsTest.java index 8f3f574b03..2708152906 100644 --- a/core-java-concurrency-basic/src/test/com/baeldung/concurrent/threadsafety/tests/MathUtilsTest.java +++ b/core-java-modules/core-java-concurrency-basic/src/test/com/baeldung/concurrent/threadsafety/tests/MathUtilsTest.java @@ -1,13 +1,13 @@ -package com.baeldung.concurrent.threadsafety.tests; - -import com.baeldung.concurrent.threadsafety.mathutils.MathUtils; -import org.junit.Test; -import static org.assertj.core.api.Assertions.assertThat; - -public class MathUtilsTest { - - @Test - public void whenCalledFactorialMethod_thenCorrect() { - assertThat(MathUtils.factorial(2)).isEqualTo(2); - } -} +package com.baeldung.concurrent.threadsafety.tests; + +import com.baeldung.concurrent.threadsafety.mathutils.MathUtils; +import org.junit.Test; +import static org.assertj.core.api.Assertions.assertThat; + +public class MathUtilsTest { + + @Test + public void whenCalledFactorialMethod_thenCorrect() { + assertThat(MathUtils.factorial(2)).isEqualTo(2); + } +} diff --git a/core-java-concurrency-basic/src/test/com/baeldung/concurrent/threadsafety/tests/MessageServiceTest.java b/core-java-modules/core-java-concurrency-basic/src/test/com/baeldung/concurrent/threadsafety/tests/MessageServiceTest.java similarity index 97% rename from core-java-concurrency-basic/src/test/com/baeldung/concurrent/threadsafety/tests/MessageServiceTest.java rename to core-java-modules/core-java-concurrency-basic/src/test/com/baeldung/concurrent/threadsafety/tests/MessageServiceTest.java index 8f1f1a8754..e62206c09a 100644 --- a/core-java-concurrency-basic/src/test/com/baeldung/concurrent/threadsafety/tests/MessageServiceTest.java +++ b/core-java-modules/core-java-concurrency-basic/src/test/com/baeldung/concurrent/threadsafety/tests/MessageServiceTest.java @@ -1,23 +1,23 @@ -package com.baeldung.concurrent.threadsafety.tests; - -import org.junit.Test; -import static org.assertj.core.api.Assertions.assertThat; -import com.baeldung.concurrent.threadsafety.callables.MessageServiceCallable; -import com.baeldung.concurrent.threadsafety.services.MessageService; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.Future; - -public class MessageServiceTest { - - @Test - public void whenCalledgetMessage_thenCorrect() throws Exception { - ExecutorService executorService = Executors.newFixedThreadPool(2); - MessageService messageService = new MessageService("Welcome to Baeldung!"); - Future future1 = (Future) executorService.submit(new MessageServiceCallable(messageService)); - Future future2 = (Future) executorService.submit(new MessageServiceCallable(messageService)); - - assertThat(future1.get()).isEqualTo("Welcome to Baeldung!"); - assertThat(future2.get()).isEqualTo("Welcome to Baeldung!"); - } -} +package com.baeldung.concurrent.threadsafety.tests; + +import org.junit.Test; +import static org.assertj.core.api.Assertions.assertThat; +import com.baeldung.concurrent.threadsafety.callables.MessageServiceCallable; +import com.baeldung.concurrent.threadsafety.services.MessageService; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.Future; + +public class MessageServiceTest { + + @Test + public void whenCalledgetMessage_thenCorrect() throws Exception { + ExecutorService executorService = Executors.newFixedThreadPool(2); + MessageService messageService = new MessageService("Welcome to Baeldung!"); + Future future1 = (Future) executorService.submit(new MessageServiceCallable(messageService)); + Future future2 = (Future) executorService.submit(new MessageServiceCallable(messageService)); + + assertThat(future1.get()).isEqualTo("Welcome to Baeldung!"); + assertThat(future2.get()).isEqualTo("Welcome to Baeldung!"); + } +} diff --git a/core-java-concurrency-basic/src/test/com/baeldung/concurrent/threadsafety/tests/ReentrantLockCounterTest.java b/core-java-modules/core-java-concurrency-basic/src/test/com/baeldung/concurrent/threadsafety/tests/ReentrantLockCounterTest.java similarity index 97% rename from core-java-concurrency-basic/src/test/com/baeldung/concurrent/threadsafety/tests/ReentrantLockCounterTest.java rename to core-java-modules/core-java-concurrency-basic/src/test/com/baeldung/concurrent/threadsafety/tests/ReentrantLockCounterTest.java index 05c721ab26..20fa2c74da 100644 --- a/core-java-concurrency-basic/src/test/com/baeldung/concurrent/threadsafety/tests/ReentrantLockCounterTest.java +++ b/core-java-modules/core-java-concurrency-basic/src/test/com/baeldung/concurrent/threadsafety/tests/ReentrantLockCounterTest.java @@ -1,23 +1,23 @@ -package com.baeldung.concurrent.threadsafety.tests; - -import com.baeldung.concurrent.threadsafety.callables.ReentrantLockCounterCallable; -import com.baeldung.concurrent.threadsafety.services.ReentrantLockCounter; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.Future; -import static org.assertj.core.api.Assertions.assertThat; -import org.junit.Test; - -public class ReentrantLockCounterTest { - - @Test - public void whenCalledIncrementCounter_thenCorrect() throws Exception { - ExecutorService executorService = Executors.newFixedThreadPool(2); - ReentrantLockCounter counter = new ReentrantLockCounter(); - Future future1 = (Future) executorService.submit(new ReentrantLockCounterCallable(counter)); - Future future2 = (Future) executorService.submit(new ReentrantLockCounterCallable(counter)); - - assertThat(future1.get()).isEqualTo(1); - assertThat(future2.get()).isEqualTo(2); - } -} +package com.baeldung.concurrent.threadsafety.tests; + +import com.baeldung.concurrent.threadsafety.callables.ReentrantLockCounterCallable; +import com.baeldung.concurrent.threadsafety.services.ReentrantLockCounter; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.Future; +import static org.assertj.core.api.Assertions.assertThat; +import org.junit.Test; + +public class ReentrantLockCounterTest { + + @Test + public void whenCalledIncrementCounter_thenCorrect() throws Exception { + ExecutorService executorService = Executors.newFixedThreadPool(2); + ReentrantLockCounter counter = new ReentrantLockCounter(); + Future future1 = (Future) executorService.submit(new ReentrantLockCounterCallable(counter)); + Future future2 = (Future) executorService.submit(new ReentrantLockCounterCallable(counter)); + + assertThat(future1.get()).isEqualTo(1); + assertThat(future2.get()).isEqualTo(2); + } +} diff --git a/core-java-concurrency-basic/src/test/com/baeldung/concurrent/threadsafety/tests/ReentrantReadWriteLockCounterTest.java b/core-java-modules/core-java-concurrency-basic/src/test/com/baeldung/concurrent/threadsafety/tests/ReentrantReadWriteLockCounterTest.java similarity index 97% rename from core-java-concurrency-basic/src/test/com/baeldung/concurrent/threadsafety/tests/ReentrantReadWriteLockCounterTest.java rename to core-java-modules/core-java-concurrency-basic/src/test/com/baeldung/concurrent/threadsafety/tests/ReentrantReadWriteLockCounterTest.java index c56137ce04..6113473cac 100644 --- a/core-java-concurrency-basic/src/test/com/baeldung/concurrent/threadsafety/tests/ReentrantReadWriteLockCounterTest.java +++ b/core-java-modules/core-java-concurrency-basic/src/test/com/baeldung/concurrent/threadsafety/tests/ReentrantReadWriteLockCounterTest.java @@ -1,24 +1,24 @@ -package com.baeldung.concurrent.threadsafety.tests; - -import com.baeldung.concurrent.threadsafety.callables.ReentranReadWriteLockCounterCallable; -import com.baeldung.concurrent.threadsafety.services.ReentrantReadWriteLockCounter; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.Future; -import static org.assertj.core.api.Assertions.assertThat; -import org.junit.Test; - -public class ReentrantReadWriteLockCounterTest { - - @Test - public void whenCalledIncrementCounter_thenCorrect() throws Exception { - ExecutorService executorService = Executors.newFixedThreadPool(2); - ReentrantReadWriteLockCounter counter = new ReentrantReadWriteLockCounter(); - Future future1 = (Future) executorService.submit(new ReentranReadWriteLockCounterCallable(counter)); - Future future2 = (Future) executorService.submit(new ReentranReadWriteLockCounterCallable(counter)); - - assertThat(future1.get()).isEqualTo(1); - assertThat(future2.get()).isEqualTo(2); - } - -} +package com.baeldung.concurrent.threadsafety.tests; + +import com.baeldung.concurrent.threadsafety.callables.ReentranReadWriteLockCounterCallable; +import com.baeldung.concurrent.threadsafety.services.ReentrantReadWriteLockCounter; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.Future; +import static org.assertj.core.api.Assertions.assertThat; +import org.junit.Test; + +public class ReentrantReadWriteLockCounterTest { + + @Test + public void whenCalledIncrementCounter_thenCorrect() throws Exception { + ExecutorService executorService = Executors.newFixedThreadPool(2); + ReentrantReadWriteLockCounter counter = new ReentrantReadWriteLockCounter(); + Future future1 = (Future) executorService.submit(new ReentranReadWriteLockCounterCallable(counter)); + Future future2 = (Future) executorService.submit(new ReentranReadWriteLockCounterCallable(counter)); + + assertThat(future1.get()).isEqualTo(1); + assertThat(future2.get()).isEqualTo(2); + } + +} diff --git a/core-java-concurrency-basic/src/test/java/com/baeldung/completablefuture/CompletableFutureLongRunningUnitTest.java b/core-java-modules/core-java-concurrency-basic/src/test/java/com/baeldung/completablefuture/CompletableFutureLongRunningUnitTest.java similarity index 100% rename from core-java-concurrency-basic/src/test/java/com/baeldung/completablefuture/CompletableFutureLongRunningUnitTest.java rename to core-java-modules/core-java-concurrency-basic/src/test/java/com/baeldung/completablefuture/CompletableFutureLongRunningUnitTest.java diff --git a/core-java-concurrency-basic/src/test/java/com/baeldung/concurrent/callable/FactorialTaskManualTest.java b/core-java-modules/core-java-concurrency-basic/src/test/java/com/baeldung/concurrent/callable/FactorialTaskManualTest.java similarity index 100% rename from core-java-concurrency-basic/src/test/java/com/baeldung/concurrent/callable/FactorialTaskManualTest.java rename to core-java-modules/core-java-concurrency-basic/src/test/java/com/baeldung/concurrent/callable/FactorialTaskManualTest.java diff --git a/core-java-concurrency-basic/src/test/java/com/baeldung/concurrent/executorservice/WaitingForThreadsToFinishManualTest.java b/core-java-modules/core-java-concurrency-basic/src/test/java/com/baeldung/concurrent/executorservice/WaitingForThreadsToFinishManualTest.java similarity index 100% rename from core-java-concurrency-basic/src/test/java/com/baeldung/concurrent/executorservice/WaitingForThreadsToFinishManualTest.java rename to core-java-modules/core-java-concurrency-basic/src/test/java/com/baeldung/concurrent/executorservice/WaitingForThreadsToFinishManualTest.java diff --git a/core-java-concurrency-basic/src/test/java/com/baeldung/concurrent/future/FactorialSquareCalculatorUnitTest.java b/core-java-modules/core-java-concurrency-basic/src/test/java/com/baeldung/concurrent/future/FactorialSquareCalculatorUnitTest.java similarity index 100% rename from core-java-concurrency-basic/src/test/java/com/baeldung/concurrent/future/FactorialSquareCalculatorUnitTest.java rename to core-java-modules/core-java-concurrency-basic/src/test/java/com/baeldung/concurrent/future/FactorialSquareCalculatorUnitTest.java diff --git a/core-java-concurrency-basic/src/test/java/com/baeldung/concurrent/future/SquareCalculatorIntegrationTest.java b/core-java-modules/core-java-concurrency-basic/src/test/java/com/baeldung/concurrent/future/SquareCalculatorIntegrationTest.java similarity index 100% rename from core-java-concurrency-basic/src/test/java/com/baeldung/concurrent/future/SquareCalculatorIntegrationTest.java rename to core-java-modules/core-java-concurrency-basic/src/test/java/com/baeldung/concurrent/future/SquareCalculatorIntegrationTest.java diff --git a/core-java-concurrency-basic/src/test/java/com/baeldung/concurrent/runnable/RunnableVsThreadLiveTest.java b/core-java-modules/core-java-concurrency-basic/src/test/java/com/baeldung/concurrent/runnable/RunnableVsThreadLiveTest.java similarity index 100% rename from core-java-concurrency-basic/src/test/java/com/baeldung/concurrent/runnable/RunnableVsThreadLiveTest.java rename to core-java-modules/core-java-concurrency-basic/src/test/java/com/baeldung/concurrent/runnable/RunnableVsThreadLiveTest.java diff --git a/core-java-concurrency-basic/src/test/java/com/baeldung/concurrent/stopping/StopThreadManualTest.java b/core-java-modules/core-java-concurrency-basic/src/test/java/com/baeldung/concurrent/stopping/StopThreadManualTest.java similarity index 100% rename from core-java-concurrency-basic/src/test/java/com/baeldung/concurrent/stopping/StopThreadManualTest.java rename to core-java-modules/core-java-concurrency-basic/src/test/java/com/baeldung/concurrent/stopping/StopThreadManualTest.java diff --git a/core-java-concurrency-basic/src/test/java/com/baeldung/concurrent/synchronize/BaeldungSychronizedBlockUnitTest.java b/core-java-modules/core-java-concurrency-basic/src/test/java/com/baeldung/concurrent/synchronize/BaeldungSychronizedBlockUnitTest.java similarity index 100% rename from core-java-concurrency-basic/src/test/java/com/baeldung/concurrent/synchronize/BaeldungSychronizedBlockUnitTest.java rename to core-java-modules/core-java-concurrency-basic/src/test/java/com/baeldung/concurrent/synchronize/BaeldungSychronizedBlockUnitTest.java diff --git a/core-java-concurrency-basic/src/test/java/com/baeldung/concurrent/synchronize/BaeldungSynchronizeMethodsUnitTest.java b/core-java-modules/core-java-concurrency-basic/src/test/java/com/baeldung/concurrent/synchronize/BaeldungSynchronizeMethodsUnitTest.java similarity index 100% rename from core-java-concurrency-basic/src/test/java/com/baeldung/concurrent/synchronize/BaeldungSynchronizeMethodsUnitTest.java rename to core-java-modules/core-java-concurrency-basic/src/test/java/com/baeldung/concurrent/synchronize/BaeldungSynchronizeMethodsUnitTest.java diff --git a/core-java-concurrency-basic/src/test/java/com/baeldung/concurrent/waitandnotify/NetworkIntegrationTest.java b/core-java-modules/core-java-concurrency-basic/src/test/java/com/baeldung/concurrent/waitandnotify/NetworkIntegrationTest.java similarity index 100% rename from core-java-concurrency-basic/src/test/java/com/baeldung/concurrent/waitandnotify/NetworkIntegrationTest.java rename to core-java-modules/core-java-concurrency-basic/src/test/java/com/baeldung/concurrent/waitandnotify/NetworkIntegrationTest.java diff --git a/core-java-concurrency-basic/src/test/java/com/baeldung/java8/Java8ExecutorServiceIntegrationTest.java b/core-java-modules/core-java-concurrency-basic/src/test/java/com/baeldung/java8/Java8ExecutorServiceIntegrationTest.java similarity index 100% rename from core-java-concurrency-basic/src/test/java/com/baeldung/java8/Java8ExecutorServiceIntegrationTest.java rename to core-java-modules/core-java-concurrency-basic/src/test/java/com/baeldung/java8/Java8ExecutorServiceIntegrationTest.java diff --git a/core-java-concurrency-basic/src/test/resources/.gitignore b/core-java-modules/core-java-concurrency-basic/src/test/resources/.gitignore similarity index 100% rename from core-java-concurrency-basic/src/test/resources/.gitignore rename to core-java-modules/core-java-concurrency-basic/src/test/resources/.gitignore diff --git a/core-java-concurrency-collections/.gitignore b/core-java-modules/core-java-concurrency-collections/.gitignore similarity index 100% rename from core-java-concurrency-collections/.gitignore rename to core-java-modules/core-java-concurrency-collections/.gitignore diff --git a/core-java-concurrency-collections/README.md b/core-java-modules/core-java-concurrency-collections/README.md similarity index 100% rename from core-java-concurrency-collections/README.md rename to core-java-modules/core-java-concurrency-collections/README.md diff --git a/core-java-concurrency-collections/pom.xml b/core-java-modules/core-java-concurrency-collections/pom.xml similarity index 98% rename from core-java-concurrency-collections/pom.xml rename to core-java-modules/core-java-concurrency-collections/pom.xml index e192bbe46f..27aae4ea6c 100644 --- a/core-java-concurrency-collections/pom.xml +++ b/core-java-modules/core-java-concurrency-collections/pom.xml @@ -11,7 +11,7 @@ com.baeldung parent-java 0.0.1-SNAPSHOT - ../parent-java + ../../parent-java diff --git a/core-java-concurrency-collections/src/main/java/com/baeldung/concurrent/blockingqueue/BlockingQueueUsage.java b/core-java-modules/core-java-concurrency-collections/src/main/java/com/baeldung/concurrent/blockingqueue/BlockingQueueUsage.java similarity index 100% rename from core-java-concurrency-collections/src/main/java/com/baeldung/concurrent/blockingqueue/BlockingQueueUsage.java rename to core-java-modules/core-java-concurrency-collections/src/main/java/com/baeldung/concurrent/blockingqueue/BlockingQueueUsage.java diff --git a/core-java-concurrency-collections/src/main/java/com/baeldung/concurrent/blockingqueue/NumbersConsumer.java b/core-java-modules/core-java-concurrency-collections/src/main/java/com/baeldung/concurrent/blockingqueue/NumbersConsumer.java similarity index 100% rename from core-java-concurrency-collections/src/main/java/com/baeldung/concurrent/blockingqueue/NumbersConsumer.java rename to core-java-modules/core-java-concurrency-collections/src/main/java/com/baeldung/concurrent/blockingqueue/NumbersConsumer.java diff --git a/core-java-concurrency-collections/src/main/java/com/baeldung/concurrent/blockingqueue/NumbersProducer.java b/core-java-modules/core-java-concurrency-collections/src/main/java/com/baeldung/concurrent/blockingqueue/NumbersProducer.java similarity index 100% rename from core-java-concurrency-collections/src/main/java/com/baeldung/concurrent/blockingqueue/NumbersProducer.java rename to core-java-modules/core-java-concurrency-collections/src/main/java/com/baeldung/concurrent/blockingqueue/NumbersProducer.java diff --git a/core-java-concurrency-collections/src/main/java/com/baeldung/concurrent/delayqueue/DelayObject.java b/core-java-modules/core-java-concurrency-collections/src/main/java/com/baeldung/concurrent/delayqueue/DelayObject.java similarity index 100% rename from core-java-concurrency-collections/src/main/java/com/baeldung/concurrent/delayqueue/DelayObject.java rename to core-java-modules/core-java-concurrency-collections/src/main/java/com/baeldung/concurrent/delayqueue/DelayObject.java diff --git a/core-java-concurrency-collections/src/main/java/com/baeldung/concurrent/delayqueue/DelayQueueConsumer.java b/core-java-modules/core-java-concurrency-collections/src/main/java/com/baeldung/concurrent/delayqueue/DelayQueueConsumer.java similarity index 100% rename from core-java-concurrency-collections/src/main/java/com/baeldung/concurrent/delayqueue/DelayQueueConsumer.java rename to core-java-modules/core-java-concurrency-collections/src/main/java/com/baeldung/concurrent/delayqueue/DelayQueueConsumer.java diff --git a/core-java-concurrency-collections/src/main/java/com/baeldung/concurrent/delayqueue/DelayQueueProducer.java b/core-java-modules/core-java-concurrency-collections/src/main/java/com/baeldung/concurrent/delayqueue/DelayQueueProducer.java similarity index 100% rename from core-java-concurrency-collections/src/main/java/com/baeldung/concurrent/delayqueue/DelayQueueProducer.java rename to core-java-modules/core-java-concurrency-collections/src/main/java/com/baeldung/concurrent/delayqueue/DelayQueueProducer.java diff --git a/core-java-concurrency-collections/src/main/java/com/baeldung/concurrent/skiplist/Event.java b/core-java-modules/core-java-concurrency-collections/src/main/java/com/baeldung/concurrent/skiplist/Event.java similarity index 100% rename from core-java-concurrency-collections/src/main/java/com/baeldung/concurrent/skiplist/Event.java rename to core-java-modules/core-java-concurrency-collections/src/main/java/com/baeldung/concurrent/skiplist/Event.java diff --git a/core-java-concurrency-collections/src/main/java/com/baeldung/concurrent/skiplist/EventWindowSort.java b/core-java-modules/core-java-concurrency-collections/src/main/java/com/baeldung/concurrent/skiplist/EventWindowSort.java similarity index 100% rename from core-java-concurrency-collections/src/main/java/com/baeldung/concurrent/skiplist/EventWindowSort.java rename to core-java-modules/core-java-concurrency-collections/src/main/java/com/baeldung/concurrent/skiplist/EventWindowSort.java diff --git a/core-java-concurrency-collections/src/main/java/com/baeldung/transferqueue/Consumer.java b/core-java-modules/core-java-concurrency-collections/src/main/java/com/baeldung/transferqueue/Consumer.java similarity index 100% rename from core-java-concurrency-collections/src/main/java/com/baeldung/transferqueue/Consumer.java rename to core-java-modules/core-java-concurrency-collections/src/main/java/com/baeldung/transferqueue/Consumer.java diff --git a/core-java-concurrency-collections/src/main/java/com/baeldung/transferqueue/Producer.java b/core-java-modules/core-java-concurrency-collections/src/main/java/com/baeldung/transferqueue/Producer.java similarity index 100% rename from core-java-concurrency-collections/src/main/java/com/baeldung/transferqueue/Producer.java rename to core-java-modules/core-java-concurrency-collections/src/main/java/com/baeldung/transferqueue/Producer.java diff --git a/core-java-concurrency-collections/src/main/resources/logback.xml b/core-java-modules/core-java-concurrency-collections/src/main/resources/logback.xml similarity index 100% rename from core-java-concurrency-collections/src/main/resources/logback.xml rename to core-java-modules/core-java-concurrency-collections/src/main/resources/logback.xml diff --git a/core-java-concurrency-collections/src/test/java/com/baeldung/concurrent/copyonwrite/CopyOnWriteArrayListUnitTest.java b/core-java-modules/core-java-concurrency-collections/src/test/java/com/baeldung/concurrent/copyonwrite/CopyOnWriteArrayListUnitTest.java similarity index 100% rename from core-java-concurrency-collections/src/test/java/com/baeldung/concurrent/copyonwrite/CopyOnWriteArrayListUnitTest.java rename to core-java-modules/core-java-concurrency-collections/src/test/java/com/baeldung/concurrent/copyonwrite/CopyOnWriteArrayListUnitTest.java diff --git a/core-java-concurrency-collections/src/test/java/com/baeldung/concurrent/delayqueue/DelayQueueIntegrationTest.java b/core-java-modules/core-java-concurrency-collections/src/test/java/com/baeldung/concurrent/delayqueue/DelayQueueIntegrationTest.java similarity index 100% rename from core-java-concurrency-collections/src/test/java/com/baeldung/concurrent/delayqueue/DelayQueueIntegrationTest.java rename to core-java-modules/core-java-concurrency-collections/src/test/java/com/baeldung/concurrent/delayqueue/DelayQueueIntegrationTest.java diff --git a/core-java-concurrency-collections/src/test/java/com/baeldung/concurrent/priorityblockingqueue/PriorityBlockingQueueIntegrationTest.java b/core-java-modules/core-java-concurrency-collections/src/test/java/com/baeldung/concurrent/priorityblockingqueue/PriorityBlockingQueueIntegrationTest.java similarity index 100% rename from core-java-concurrency-collections/src/test/java/com/baeldung/concurrent/priorityblockingqueue/PriorityBlockingQueueIntegrationTest.java rename to core-java-modules/core-java-concurrency-collections/src/test/java/com/baeldung/concurrent/priorityblockingqueue/PriorityBlockingQueueIntegrationTest.java diff --git a/core-java-concurrency-collections/src/test/java/com/baeldung/concurrent/skiplist/ConcurrentSkipListSetIntegrationTest.java b/core-java-modules/core-java-concurrency-collections/src/test/java/com/baeldung/concurrent/skiplist/ConcurrentSkipListSetIntegrationTest.java similarity index 100% rename from core-java-concurrency-collections/src/test/java/com/baeldung/concurrent/skiplist/ConcurrentSkipListSetIntegrationTest.java rename to core-java-modules/core-java-concurrency-collections/src/test/java/com/baeldung/concurrent/skiplist/ConcurrentSkipListSetIntegrationTest.java diff --git a/core-java-concurrency-collections/src/test/java/com/baeldung/java/concurrentmap/ConcurrentMapAggregateStatusManualTest.java b/core-java-modules/core-java-concurrency-collections/src/test/java/com/baeldung/java/concurrentmap/ConcurrentMapAggregateStatusManualTest.java similarity index 100% rename from core-java-concurrency-collections/src/test/java/com/baeldung/java/concurrentmap/ConcurrentMapAggregateStatusManualTest.java rename to core-java-modules/core-java-concurrency-collections/src/test/java/com/baeldung/java/concurrentmap/ConcurrentMapAggregateStatusManualTest.java diff --git a/core-java-concurrency-collections/src/test/java/com/baeldung/java/concurrentmap/ConcurrentMapNullKeyValueManualTest.java b/core-java-modules/core-java-concurrency-collections/src/test/java/com/baeldung/java/concurrentmap/ConcurrentMapNullKeyValueManualTest.java similarity index 100% rename from core-java-concurrency-collections/src/test/java/com/baeldung/java/concurrentmap/ConcurrentMapNullKeyValueManualTest.java rename to core-java-modules/core-java-concurrency-collections/src/test/java/com/baeldung/java/concurrentmap/ConcurrentMapNullKeyValueManualTest.java diff --git a/core-java-concurrency-collections/src/test/java/com/baeldung/java/concurrentmap/ConcurrentMapPerformanceManualTest.java b/core-java-modules/core-java-concurrency-collections/src/test/java/com/baeldung/java/concurrentmap/ConcurrentMapPerformanceManualTest.java similarity index 100% rename from core-java-concurrency-collections/src/test/java/com/baeldung/java/concurrentmap/ConcurrentMapPerformanceManualTest.java rename to core-java-modules/core-java-concurrency-collections/src/test/java/com/baeldung/java/concurrentmap/ConcurrentMapPerformanceManualTest.java diff --git a/core-java-concurrency-collections/src/test/java/com/baeldung/java/concurrentmap/ConcurrentNavigableMapManualTest.java b/core-java-modules/core-java-concurrency-collections/src/test/java/com/baeldung/java/concurrentmap/ConcurrentNavigableMapManualTest.java similarity index 100% rename from core-java-concurrency-collections/src/test/java/com/baeldung/java/concurrentmap/ConcurrentNavigableMapManualTest.java rename to core-java-modules/core-java-concurrency-collections/src/test/java/com/baeldung/java/concurrentmap/ConcurrentNavigableMapManualTest.java diff --git a/core-java-concurrency-collections/src/test/java/com/baeldung/java/concurrentmap/ConcurretMapMemoryConsistencyManualTest.java b/core-java-modules/core-java-concurrency-collections/src/test/java/com/baeldung/java/concurrentmap/ConcurretMapMemoryConsistencyManualTest.java similarity index 100% rename from core-java-concurrency-collections/src/test/java/com/baeldung/java/concurrentmap/ConcurretMapMemoryConsistencyManualTest.java rename to core-java-modules/core-java-concurrency-collections/src/test/java/com/baeldung/java/concurrentmap/ConcurretMapMemoryConsistencyManualTest.java diff --git a/core-java-concurrency-collections/src/test/java/com/baeldung/java/concurrentmodification/ConcurrentModificationUnitTest.java b/core-java-modules/core-java-concurrency-collections/src/test/java/com/baeldung/java/concurrentmodification/ConcurrentModificationUnitTest.java similarity index 100% rename from core-java-concurrency-collections/src/test/java/com/baeldung/java/concurrentmodification/ConcurrentModificationUnitTest.java rename to core-java-modules/core-java-concurrency-collections/src/test/java/com/baeldung/java/concurrentmodification/ConcurrentModificationUnitTest.java diff --git a/core-java-concurrency-collections/src/test/java/com/baeldung/synchronousqueue/SynchronousQueueIntegrationTest.java b/core-java-modules/core-java-concurrency-collections/src/test/java/com/baeldung/synchronousqueue/SynchronousQueueIntegrationTest.java similarity index 100% rename from core-java-concurrency-collections/src/test/java/com/baeldung/synchronousqueue/SynchronousQueueIntegrationTest.java rename to core-java-modules/core-java-concurrency-collections/src/test/java/com/baeldung/synchronousqueue/SynchronousQueueIntegrationTest.java diff --git a/core-java-concurrency-collections/src/test/java/com/baeldung/transferqueue/TransferQueueIntegrationTest.java b/core-java-modules/core-java-concurrency-collections/src/test/java/com/baeldung/transferqueue/TransferQueueIntegrationTest.java similarity index 100% rename from core-java-concurrency-collections/src/test/java/com/baeldung/transferqueue/TransferQueueIntegrationTest.java rename to core-java-modules/core-java-concurrency-collections/src/test/java/com/baeldung/transferqueue/TransferQueueIntegrationTest.java diff --git a/core-java-concurrency-collections/src/test/java/org/baeldung/java/streams/ThreadPoolInParallelStreamIntegrationTest.java b/core-java-modules/core-java-concurrency-collections/src/test/java/org/baeldung/java/streams/ThreadPoolInParallelStreamIntegrationTest.java similarity index 100% rename from core-java-concurrency-collections/src/test/java/org/baeldung/java/streams/ThreadPoolInParallelStreamIntegrationTest.java rename to core-java-modules/core-java-concurrency-collections/src/test/java/org/baeldung/java/streams/ThreadPoolInParallelStreamIntegrationTest.java diff --git a/core-java-concurrency-collections/src/test/resources/.gitignore b/core-java-modules/core-java-concurrency-collections/src/test/resources/.gitignore similarity index 100% rename from core-java-concurrency-collections/src/test/resources/.gitignore rename to core-java-modules/core-java-concurrency-collections/src/test/resources/.gitignore diff --git a/core-java-modules/core-java-exceptions/pom.xml b/core-java-modules/core-java-exceptions/pom.xml new file mode 100644 index 0000000000..51c4e51341 --- /dev/null +++ b/core-java-modules/core-java-exceptions/pom.xml @@ -0,0 +1,26 @@ + + 4.0.0 + com.baeldung.exception.numberformat + core-java-exceptions + 0.0.1-SNAPSHOT + core-java-exceptions + + + com.baeldung + parent-java + 0.0.1-SNAPSHOT + ../../parent-java + + + + + junit + junit + 4.12 + test + + + + diff --git a/core-java-modules/core-java-exceptions/src/test/java/com/baeldung/exception/numberformat/NumberFormatExceptionUnitTest.java b/core-java-modules/core-java-exceptions/src/test/java/com/baeldung/exception/numberformat/NumberFormatExceptionUnitTest.java new file mode 100644 index 0000000000..a1e8c7c30f --- /dev/null +++ b/core-java-modules/core-java-exceptions/src/test/java/com/baeldung/exception/numberformat/NumberFormatExceptionUnitTest.java @@ -0,0 +1,154 @@ +package com.baeldung.exception.numberformat; + +import static org.junit.Assert.assertEquals; + +import java.math.BigDecimal; +import java.math.BigInteger; +import java.text.NumberFormat; +import java.text.ParseException; +import java.util.Locale; +import java.util.logging.Logger; + +import org.junit.Test; + +/** + * A set of examples tested to show cases where NumberFormatException is thrown and not thrown. + */ +public class NumberFormatExceptionUnitTest { + + Logger LOG = Logger.getLogger(NumberFormatExceptionUnitTest.class.getName()); + + /* ---INTEGER FAIL CASES--- */ + @Test(expected = NumberFormatException.class) + public void givenByteConstructor_whenAlphabetAsInput_thenFail() { + Byte byteInt = new Byte("one"); + } + + @Test(expected = NumberFormatException.class) + public void givenShortConstructor_whenSpaceInInput_thenFail() { + Short shortInt = new Short("2 "); + } + + @Test(expected = NumberFormatException.class) + public void givenParseIntMethod_whenSpaceInInput_thenFail() { + Integer aIntPrim = Integer.parseInt("6000 "); + } + + @Test(expected = NumberFormatException.class) + public void givenParseIntMethod_whenUnderscoreInInput_thenFail() { + int bIntPrim = Integer.parseInt("6_000"); + } + + @Test(expected = NumberFormatException.class) + public void givenIntegerValueOfMethod_whenCommaInInput_thenFail() { + Integer cIntPrim = Integer.valueOf("6,000"); + } + + @Test(expected = NumberFormatException.class) + public void givenBigIntegerConstructor_whenDecimalInInput_thenFail() { + BigInteger bigInteger = new BigInteger("4.0"); + } + + @Test(expected = NumberFormatException.class) + public void givenDecodeMethod_whenAlphabetInInput_thenFail() { + Long decodeInteger = Long.decode("64403L"); + } + + /* ---INTEGER PASS CASES--- */ + @Test + public void givenInvalidNumberInputs_whenOptimized_thenPass() { + Byte byteInt = new Byte("1"); + assertEquals(1, byteInt.intValue()); + + Short shortInt = new Short("2 ".trim()); + assertEquals(2, shortInt.intValue()); + + Integer aIntObj = Integer.valueOf("6"); + assertEquals(6, aIntObj.intValue()); + + BigInteger bigInteger = new BigInteger("4"); + assertEquals(4, bigInteger.intValue()); + + int aIntPrim = Integer.parseInt("6000 ".trim()); + assertEquals(6000, aIntPrim); + + int bIntPrim = Integer.parseInt("6_000".replaceAll("_", "")); + assertEquals(6000, bIntPrim); + + int cIntPrim = Integer.parseInt("-6000"); + assertEquals(-6000, cIntPrim); + + Long decodeInteger = Long.decode("644032334"); + assertEquals(644032334L, decodeInteger.longValue()); + } + + /* ---DOUBLE FAIL CASES--- */ + @Test(expected = NumberFormatException.class) + public void givenFloatConstructor_whenAlphabetInInput_thenFail() { + Float floatDecimalObj = new Float("one.1"); + } + + @Test(expected = NumberFormatException.class) + public void givenDoubleConstructor_whenAlphabetInInput_thenFail() { + Double doubleDecimalObj = new Double("two.2"); + } + + @Test(expected = NumberFormatException.class) + public void givenBigDecimalConstructor_whenSpecialCharsInInput_thenFail() { + BigDecimal bigDecimalObj = new BigDecimal("3_0.3"); + } + + @Test(expected = NumberFormatException.class) + public void givenParseDoubleMethod_whenCommaInInput_thenFail() { + double aDoublePrim = Double.parseDouble("4000,1"); + } + + /* ---DOUBLE PASS CASES--- */ + @Test + public void givenDoubleConstructor_whenDecimalInInput_thenPass() { + Double doubleDecimalObj = new Double("2.2"); + assertEquals(2.2, doubleDecimalObj.doubleValue(), 0); + } + + @Test + public void givenDoubleValueOfMethod_whenMinusInInput_thenPass() { + Double aDoubleObj = Double.valueOf("-6000"); + assertEquals(-6000, aDoubleObj.doubleValue(), 0); + } + + @Test + public void givenUsDecimalNumber_whenParsedWithNumberFormat_thenPass() throws ParseException { + Number parsedNumber = parseNumberWithLocale("4000.1", Locale.US); + assertEquals(4000.1, parsedNumber); + assertEquals(4000.1, parsedNumber.doubleValue(), 0); + assertEquals(4000, parsedNumber.intValue()); + } + + /** + * In most European countries (for example, France), comma is used as decimal in place of period. + * @throws ParseException if the input string contains special characters other than comma or decimal. + * In this test case, anything after decimal (period) is dropped when a European locale is set. + */ + @Test + public void givenEuDecimalNumberHasComma_whenParsedWithNumberFormat_thenPass() throws ParseException { + Number parsedNumber = parseNumberWithLocale("4000,1", Locale.FRANCE); + LOG.info("Number parsed is: " + parsedNumber); + assertEquals(4000.1, parsedNumber); + assertEquals(4000.1, parsedNumber.doubleValue(), 0); + assertEquals(4000, parsedNumber.intValue()); + } + + /** + * Converts a string into a number retaining all decimals, and symbols valid in a locale. + * @param number the input string for a number. + * @param locale the locale to consider while parsing a number. + * @return the generic number object which can represent multiple number types. + * @throws ParseException when input contains invalid characters. + */ + private Number parseNumberWithLocale(String number, Locale locale) throws ParseException { + locale = locale == null ? Locale.getDefault() : locale; + NumberFormat numberFormat = NumberFormat.getInstance(locale); + return numberFormat.parse(number); + } + +} diff --git a/core-java-io/.gitignore b/core-java-modules/core-java-io/.gitignore similarity index 100% rename from core-java-io/.gitignore rename to core-java-modules/core-java-io/.gitignore diff --git a/core-java-io/README.md b/core-java-modules/core-java-io/README.md similarity index 100% rename from core-java-io/README.md rename to core-java-modules/core-java-io/README.md diff --git a/core-java-modules/core-java-io/hard_link.txt b/core-java-modules/core-java-io/hard_link.txt new file mode 100644 index 0000000000..931a810b8d --- /dev/null +++ b/core-java-modules/core-java-io/hard_link.txt @@ -0,0 +1,10000 @@ +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 +75 +76 +77 +78 +79 +80 +81 +82 +83 +84 +85 +86 +87 +88 +89 +90 +91 +92 +93 +94 +95 +96 +97 +98 +99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 +129 +130 +131 +132 +133 +134 +135 +136 +137 +138 +139 +140 +141 +142 +143 +144 +145 +146 +147 +148 +149 +150 +151 +152 +153 +154 +155 +156 +157 +158 +159 +160 +161 +162 +163 +164 +165 +166 +167 +168 +169 +170 +171 +172 +173 +174 +175 +176 +177 +178 +179 +180 +181 +182 +183 +184 +185 +186 +187 +188 +189 +190 +191 +192 +193 +194 +195 +196 +197 +198 +199 +200 +201 +202 +203 +204 +205 +206 +207 +208 +209 +210 +211 +212 +213 +214 +215 +216 +217 +218 +219 +220 +221 +222 +223 +224 +225 +226 +227 +228 +229 +230 +231 +232 +233 +234 +235 +236 +237 +238 +239 +240 +241 +242 +243 +244 +245 +246 +247 +248 +249 +250 +251 +252 +253 +254 +255 +256 +257 +258 +259 +260 +261 +262 +263 +264 +265 +266 +267 +268 +269 +270 +271 +272 +273 +274 +275 +276 +277 +278 +279 +280 +281 +282 +283 +284 +285 +286 +287 +288 +289 +290 +291 +292 +293 +294 +295 +296 +297 +298 +299 +300 +301 +302 +303 +304 +305 +306 +307 +308 +309 +310 +311 +312 +313 +314 +315 +316 +317 +318 +319 +320 +321 +322 +323 +324 +325 +326 +327 +328 +329 +330 +331 +332 +333 +334 +335 +336 +337 +338 +339 +340 +341 +342 +343 +344 +345 +346 +347 +348 +349 +350 +351 +352 +353 +354 +355 +356 +357 +358 +359 +360 +361 +362 +363 +364 +365 +366 +367 +368 +369 +370 +371 +372 +373 +374 +375 +376 +377 +378 +379 +380 +381 +382 +383 +384 +385 +386 +387 +388 +389 +390 +391 +392 +393 +394 +395 +396 +397 +398 +399 +400 +401 +402 +403 +404 +405 +406 +407 +408 +409 +410 +411 +412 +413 +414 +415 +416 +417 +418 +419 +420 +421 +422 +423 +424 +425 +426 +427 +428 +429 +430 +431 +432 +433 +434 +435 +436 +437 +438 +439 +440 +441 +442 +443 +444 +445 +446 +447 +448 +449 +450 +451 +452 +453 +454 +455 +456 +457 +458 +459 +460 +461 +462 +463 +464 +465 +466 +467 +468 +469 +470 +471 +472 +473 +474 +475 +476 +477 +478 +479 +480 +481 +482 +483 +484 +485 +486 +487 +488 +489 +490 +491 +492 +493 +494 +495 +496 +497 +498 +499 +500 +501 +502 +503 +504 +505 +506 +507 +508 +509 +510 +511 +512 +513 +514 +515 +516 +517 +518 +519 +520 +521 +522 +523 +524 +525 +526 +527 +528 +529 +530 +531 +532 +533 +534 +535 +536 +537 +538 +539 +540 +541 +542 +543 +544 +545 +546 +547 +548 +549 +550 +551 +552 +553 +554 +555 +556 +557 +558 +559 +560 +561 +562 +563 +564 +565 +566 +567 +568 +569 +570 +571 +572 +573 +574 +575 +576 +577 +578 +579 +580 +581 +582 +583 +584 +585 +586 +587 +588 +589 +590 +591 +592 +593 +594 +595 +596 +597 +598 +599 +600 +601 +602 +603 +604 +605 +606 +607 +608 +609 +610 +611 +612 +613 +614 +615 +616 +617 +618 +619 +620 +621 +622 +623 +624 +625 +626 +627 +628 +629 +630 +631 +632 +633 +634 +635 +636 +637 +638 +639 +640 +641 +642 +643 +644 +645 +646 +647 +648 +649 +650 +651 +652 +653 +654 +655 +656 +657 +658 +659 +660 +661 +662 +663 +664 +665 +666 +667 +668 +669 +670 +671 +672 +673 +674 +675 +676 +677 +678 +679 +680 +681 +682 +683 +684 +685 +686 +687 +688 +689 +690 +691 +692 +693 +694 +695 +696 +697 +698 +699 +700 +701 +702 +703 +704 +705 +706 +707 +708 +709 +710 +711 +712 +713 +714 +715 +716 +717 +718 +719 +720 +721 +722 +723 +724 +725 +726 +727 +728 +729 +730 +731 +732 +733 +734 +735 +736 +737 +738 +739 +740 +741 +742 +743 +744 +745 +746 +747 +748 +749 +750 +751 +752 +753 +754 +755 +756 +757 +758 +759 +760 +761 +762 +763 +764 +765 +766 +767 +768 +769 +770 +771 +772 +773 +774 +775 +776 +777 +778 +779 +780 +781 +782 +783 +784 +785 +786 +787 +788 +789 +790 +791 +792 +793 +794 +795 +796 +797 +798 +799 +800 +801 +802 +803 +804 +805 +806 +807 +808 +809 +810 +811 +812 +813 +814 +815 +816 +817 +818 +819 +820 +821 +822 +823 +824 +825 +826 +827 +828 +829 +830 +831 +832 +833 +834 +835 +836 +837 +838 +839 +840 +841 +842 +843 +844 +845 +846 +847 +848 +849 +850 +851 +852 +853 +854 +855 +856 +857 +858 +859 +860 +861 +862 +863 +864 +865 +866 +867 +868 +869 +870 +871 +872 +873 +874 +875 +876 +877 +878 +879 +880 +881 +882 +883 +884 +885 +886 +887 +888 +889 +890 +891 +892 +893 +894 +895 +896 +897 +898 +899 +900 +901 +902 +903 +904 +905 +906 +907 +908 +909 +910 +911 +912 +913 +914 +915 +916 +917 +918 +919 +920 +921 +922 +923 +924 +925 +926 +927 +928 +929 +930 +931 +932 +933 +934 +935 +936 +937 +938 +939 +940 +941 +942 +943 +944 +945 +946 +947 +948 +949 +950 +951 +952 +953 +954 +955 +956 +957 +958 +959 +960 +961 +962 +963 +964 +965 +966 +967 +968 +969 +970 +971 +972 +973 +974 +975 +976 +977 +978 +979 +980 +981 +982 +983 +984 +985 +986 +987 +988 +989 +990 +991 +992 +993 +994 +995 +996 +997 +998 +999 +1000 +1001 +1002 +1003 +1004 +1005 +1006 +1007 +1008 +1009 +1010 +1011 +1012 +1013 +1014 +1015 +1016 +1017 +1018 +1019 +1020 +1021 +1022 +1023 +1024 +1025 +1026 +1027 +1028 +1029 +1030 +1031 +1032 +1033 +1034 +1035 +1036 +1037 +1038 +1039 +1040 +1041 +1042 +1043 +1044 +1045 +1046 +1047 +1048 +1049 +1050 +1051 +1052 +1053 +1054 +1055 +1056 +1057 +1058 +1059 +1060 +1061 +1062 +1063 +1064 +1065 +1066 +1067 +1068 +1069 +1070 +1071 +1072 +1073 +1074 +1075 +1076 +1077 +1078 +1079 +1080 +1081 +1082 +1083 +1084 +1085 +1086 +1087 +1088 +1089 +1090 +1091 +1092 +1093 +1094 +1095 +1096 +1097 +1098 +1099 +1100 +1101 +1102 +1103 +1104 +1105 +1106 +1107 +1108 +1109 +1110 +1111 +1112 +1113 +1114 +1115 +1116 +1117 +1118 +1119 +1120 +1121 +1122 +1123 +1124 +1125 +1126 +1127 +1128 +1129 +1130 +1131 +1132 +1133 +1134 +1135 +1136 +1137 +1138 +1139 +1140 +1141 +1142 +1143 +1144 +1145 +1146 +1147 +1148 +1149 +1150 +1151 +1152 +1153 +1154 +1155 +1156 +1157 +1158 +1159 +1160 +1161 +1162 +1163 +1164 +1165 +1166 +1167 +1168 +1169 +1170 +1171 +1172 +1173 +1174 +1175 +1176 +1177 +1178 +1179 +1180 +1181 +1182 +1183 +1184 +1185 +1186 +1187 +1188 +1189 +1190 +1191 +1192 +1193 +1194 +1195 +1196 +1197 +1198 +1199 +1200 +1201 +1202 +1203 +1204 +1205 +1206 +1207 +1208 +1209 +1210 +1211 +1212 +1213 +1214 +1215 +1216 +1217 +1218 +1219 +1220 +1221 +1222 +1223 +1224 +1225 +1226 +1227 +1228 +1229 +1230 +1231 +1232 +1233 +1234 +1235 +1236 +1237 +1238 +1239 +1240 +1241 +1242 +1243 +1244 +1245 +1246 +1247 +1248 +1249 +1250 +1251 +1252 +1253 +1254 +1255 +1256 +1257 +1258 +1259 +1260 +1261 +1262 +1263 +1264 +1265 +1266 +1267 +1268 +1269 +1270 +1271 +1272 +1273 +1274 +1275 +1276 +1277 +1278 +1279 +1280 +1281 +1282 +1283 +1284 +1285 +1286 +1287 +1288 +1289 +1290 +1291 +1292 +1293 +1294 +1295 +1296 +1297 +1298 +1299 +1300 +1301 +1302 +1303 +1304 +1305 +1306 +1307 +1308 +1309 +1310 +1311 +1312 +1313 +1314 +1315 +1316 +1317 +1318 +1319 +1320 +1321 +1322 +1323 +1324 +1325 +1326 +1327 +1328 +1329 +1330 +1331 +1332 +1333 +1334 +1335 +1336 +1337 +1338 +1339 +1340 +1341 +1342 +1343 +1344 +1345 +1346 +1347 +1348 +1349 +1350 +1351 +1352 +1353 +1354 +1355 +1356 +1357 +1358 +1359 +1360 +1361 +1362 +1363 +1364 +1365 +1366 +1367 +1368 +1369 +1370 +1371 +1372 +1373 +1374 +1375 +1376 +1377 +1378 +1379 +1380 +1381 +1382 +1383 +1384 +1385 +1386 +1387 +1388 +1389 +1390 +1391 +1392 +1393 +1394 +1395 +1396 +1397 +1398 +1399 +1400 +1401 +1402 +1403 +1404 +1405 +1406 +1407 +1408 +1409 +1410 +1411 +1412 +1413 +1414 +1415 +1416 +1417 +1418 +1419 +1420 +1421 +1422 +1423 +1424 +1425 +1426 +1427 +1428 +1429 +1430 +1431 +1432 +1433 +1434 +1435 +1436 +1437 +1438 +1439 +1440 +1441 +1442 +1443 +1444 +1445 +1446 +1447 +1448 +1449 +1450 +1451 +1452 +1453 +1454 +1455 +1456 +1457 +1458 +1459 +1460 +1461 +1462 +1463 +1464 +1465 +1466 +1467 +1468 +1469 +1470 +1471 +1472 +1473 +1474 +1475 +1476 +1477 +1478 +1479 +1480 +1481 +1482 +1483 +1484 +1485 +1486 +1487 +1488 +1489 +1490 +1491 +1492 +1493 +1494 +1495 +1496 +1497 +1498 +1499 +1500 +1501 +1502 +1503 +1504 +1505 +1506 +1507 +1508 +1509 +1510 +1511 +1512 +1513 +1514 +1515 +1516 +1517 +1518 +1519 +1520 +1521 +1522 +1523 +1524 +1525 +1526 +1527 +1528 +1529 +1530 +1531 +1532 +1533 +1534 +1535 +1536 +1537 +1538 +1539 +1540 +1541 +1542 +1543 +1544 +1545 +1546 +1547 +1548 +1549 +1550 +1551 +1552 +1553 +1554 +1555 +1556 +1557 +1558 +1559 +1560 +1561 +1562 +1563 +1564 +1565 +1566 +1567 +1568 +1569 +1570 +1571 +1572 +1573 +1574 +1575 +1576 +1577 +1578 +1579 +1580 +1581 +1582 +1583 +1584 +1585 +1586 +1587 +1588 +1589 +1590 +1591 +1592 +1593 +1594 +1595 +1596 +1597 +1598 +1599 +1600 +1601 +1602 +1603 +1604 +1605 +1606 +1607 +1608 +1609 +1610 +1611 +1612 +1613 +1614 +1615 +1616 +1617 +1618 +1619 +1620 +1621 +1622 +1623 +1624 +1625 +1626 +1627 +1628 +1629 +1630 +1631 +1632 +1633 +1634 +1635 +1636 +1637 +1638 +1639 +1640 +1641 +1642 +1643 +1644 +1645 +1646 +1647 +1648 +1649 +1650 +1651 +1652 +1653 +1654 +1655 +1656 +1657 +1658 +1659 +1660 +1661 +1662 +1663 +1664 +1665 +1666 +1667 +1668 +1669 +1670 +1671 +1672 +1673 +1674 +1675 +1676 +1677 +1678 +1679 +1680 +1681 +1682 +1683 +1684 +1685 +1686 +1687 +1688 +1689 +1690 +1691 +1692 +1693 +1694 +1695 +1696 +1697 +1698 +1699 +1700 +1701 +1702 +1703 +1704 +1705 +1706 +1707 +1708 +1709 +1710 +1711 +1712 +1713 +1714 +1715 +1716 +1717 +1718 +1719 +1720 +1721 +1722 +1723 +1724 +1725 +1726 +1727 +1728 +1729 +1730 +1731 +1732 +1733 +1734 +1735 +1736 +1737 +1738 +1739 +1740 +1741 +1742 +1743 +1744 +1745 +1746 +1747 +1748 +1749 +1750 +1751 +1752 +1753 +1754 +1755 +1756 +1757 +1758 +1759 +1760 +1761 +1762 +1763 +1764 +1765 +1766 +1767 +1768 +1769 +1770 +1771 +1772 +1773 +1774 +1775 +1776 +1777 +1778 +1779 +1780 +1781 +1782 +1783 +1784 +1785 +1786 +1787 +1788 +1789 +1790 +1791 +1792 +1793 +1794 +1795 +1796 +1797 +1798 +1799 +1800 +1801 +1802 +1803 +1804 +1805 +1806 +1807 +1808 +1809 +1810 +1811 +1812 +1813 +1814 +1815 +1816 +1817 +1818 +1819 +1820 +1821 +1822 +1823 +1824 +1825 +1826 +1827 +1828 +1829 +1830 +1831 +1832 +1833 +1834 +1835 +1836 +1837 +1838 +1839 +1840 +1841 +1842 +1843 +1844 +1845 +1846 +1847 +1848 +1849 +1850 +1851 +1852 +1853 +1854 +1855 +1856 +1857 +1858 +1859 +1860 +1861 +1862 +1863 +1864 +1865 +1866 +1867 +1868 +1869 +1870 +1871 +1872 +1873 +1874 +1875 +1876 +1877 +1878 +1879 +1880 +1881 +1882 +1883 +1884 +1885 +1886 +1887 +1888 +1889 +1890 +1891 +1892 +1893 +1894 +1895 +1896 +1897 +1898 +1899 +1900 +1901 +1902 +1903 +1904 +1905 +1906 +1907 +1908 +1909 +1910 +1911 +1912 +1913 +1914 +1915 +1916 +1917 +1918 +1919 +1920 +1921 +1922 +1923 +1924 +1925 +1926 +1927 +1928 +1929 +1930 +1931 +1932 +1933 +1934 +1935 +1936 +1937 +1938 +1939 +1940 +1941 +1942 +1943 +1944 +1945 +1946 +1947 +1948 +1949 +1950 +1951 +1952 +1953 +1954 +1955 +1956 +1957 +1958 +1959 +1960 +1961 +1962 +1963 +1964 +1965 +1966 +1967 +1968 +1969 +1970 +1971 +1972 +1973 +1974 +1975 +1976 +1977 +1978 +1979 +1980 +1981 +1982 +1983 +1984 +1985 +1986 +1987 +1988 +1989 +1990 +1991 +1992 +1993 +1994 +1995 +1996 +1997 +1998 +1999 +2000 +2001 +2002 +2003 +2004 +2005 +2006 +2007 +2008 +2009 +2010 +2011 +2012 +2013 +2014 +2015 +2016 +2017 +2018 +2019 +2020 +2021 +2022 +2023 +2024 +2025 +2026 +2027 +2028 +2029 +2030 +2031 +2032 +2033 +2034 +2035 +2036 +2037 +2038 +2039 +2040 +2041 +2042 +2043 +2044 +2045 +2046 +2047 +2048 +2049 +2050 +2051 +2052 +2053 +2054 +2055 +2056 +2057 +2058 +2059 +2060 +2061 +2062 +2063 +2064 +2065 +2066 +2067 +2068 +2069 +2070 +2071 +2072 +2073 +2074 +2075 +2076 +2077 +2078 +2079 +2080 +2081 +2082 +2083 +2084 +2085 +2086 +2087 +2088 +2089 +2090 +2091 +2092 +2093 +2094 +2095 +2096 +2097 +2098 +2099 +2100 +2101 +2102 +2103 +2104 +2105 +2106 +2107 +2108 +2109 +2110 +2111 +2112 +2113 +2114 +2115 +2116 +2117 +2118 +2119 +2120 +2121 +2122 +2123 +2124 +2125 +2126 +2127 +2128 +2129 +2130 +2131 +2132 +2133 +2134 +2135 +2136 +2137 +2138 +2139 +2140 +2141 +2142 +2143 +2144 +2145 +2146 +2147 +2148 +2149 +2150 +2151 +2152 +2153 +2154 +2155 +2156 +2157 +2158 +2159 +2160 +2161 +2162 +2163 +2164 +2165 +2166 +2167 +2168 +2169 +2170 +2171 +2172 +2173 +2174 +2175 +2176 +2177 +2178 +2179 +2180 +2181 +2182 +2183 +2184 +2185 +2186 +2187 +2188 +2189 +2190 +2191 +2192 +2193 +2194 +2195 +2196 +2197 +2198 +2199 +2200 +2201 +2202 +2203 +2204 +2205 +2206 +2207 +2208 +2209 +2210 +2211 +2212 +2213 +2214 +2215 +2216 +2217 +2218 +2219 +2220 +2221 +2222 +2223 +2224 +2225 +2226 +2227 +2228 +2229 +2230 +2231 +2232 +2233 +2234 +2235 +2236 +2237 +2238 +2239 +2240 +2241 +2242 +2243 +2244 +2245 +2246 +2247 +2248 +2249 +2250 +2251 +2252 +2253 +2254 +2255 +2256 +2257 +2258 +2259 +2260 +2261 +2262 +2263 +2264 +2265 +2266 +2267 +2268 +2269 +2270 +2271 +2272 +2273 +2274 +2275 +2276 +2277 +2278 +2279 +2280 +2281 +2282 +2283 +2284 +2285 +2286 +2287 +2288 +2289 +2290 +2291 +2292 +2293 +2294 +2295 +2296 +2297 +2298 +2299 +2300 +2301 +2302 +2303 +2304 +2305 +2306 +2307 +2308 +2309 +2310 +2311 +2312 +2313 +2314 +2315 +2316 +2317 +2318 +2319 +2320 +2321 +2322 +2323 +2324 +2325 +2326 +2327 +2328 +2329 +2330 +2331 +2332 +2333 +2334 +2335 +2336 +2337 +2338 +2339 +2340 +2341 +2342 +2343 +2344 +2345 +2346 +2347 +2348 +2349 +2350 +2351 +2352 +2353 +2354 +2355 +2356 +2357 +2358 +2359 +2360 +2361 +2362 +2363 +2364 +2365 +2366 +2367 +2368 +2369 +2370 +2371 +2372 +2373 +2374 +2375 +2376 +2377 +2378 +2379 +2380 +2381 +2382 +2383 +2384 +2385 +2386 +2387 +2388 +2389 +2390 +2391 +2392 +2393 +2394 +2395 +2396 +2397 +2398 +2399 +2400 +2401 +2402 +2403 +2404 +2405 +2406 +2407 +2408 +2409 +2410 +2411 +2412 +2413 +2414 +2415 +2416 +2417 +2418 +2419 +2420 +2421 +2422 +2423 +2424 +2425 +2426 +2427 +2428 +2429 +2430 +2431 +2432 +2433 +2434 +2435 +2436 +2437 +2438 +2439 +2440 +2441 +2442 +2443 +2444 +2445 +2446 +2447 +2448 +2449 +2450 +2451 +2452 +2453 +2454 +2455 +2456 +2457 +2458 +2459 +2460 +2461 +2462 +2463 +2464 +2465 +2466 +2467 +2468 +2469 +2470 +2471 +2472 +2473 +2474 +2475 +2476 +2477 +2478 +2479 +2480 +2481 +2482 +2483 +2484 +2485 +2486 +2487 +2488 +2489 +2490 +2491 +2492 +2493 +2494 +2495 +2496 +2497 +2498 +2499 +2500 +2501 +2502 +2503 +2504 +2505 +2506 +2507 +2508 +2509 +2510 +2511 +2512 +2513 +2514 +2515 +2516 +2517 +2518 +2519 +2520 +2521 +2522 +2523 +2524 +2525 +2526 +2527 +2528 +2529 +2530 +2531 +2532 +2533 +2534 +2535 +2536 +2537 +2538 +2539 +2540 +2541 +2542 +2543 +2544 +2545 +2546 +2547 +2548 +2549 +2550 +2551 +2552 +2553 +2554 +2555 +2556 +2557 +2558 +2559 +2560 +2561 +2562 +2563 +2564 +2565 +2566 +2567 +2568 +2569 +2570 +2571 +2572 +2573 +2574 +2575 +2576 +2577 +2578 +2579 +2580 +2581 +2582 +2583 +2584 +2585 +2586 +2587 +2588 +2589 +2590 +2591 +2592 +2593 +2594 +2595 +2596 +2597 +2598 +2599 +2600 +2601 +2602 +2603 +2604 +2605 +2606 +2607 +2608 +2609 +2610 +2611 +2612 +2613 +2614 +2615 +2616 +2617 +2618 +2619 +2620 +2621 +2622 +2623 +2624 +2625 +2626 +2627 +2628 +2629 +2630 +2631 +2632 +2633 +2634 +2635 +2636 +2637 +2638 +2639 +2640 +2641 +2642 +2643 +2644 +2645 +2646 +2647 +2648 +2649 +2650 +2651 +2652 +2653 +2654 +2655 +2656 +2657 +2658 +2659 +2660 +2661 +2662 +2663 +2664 +2665 +2666 +2667 +2668 +2669 +2670 +2671 +2672 +2673 +2674 +2675 +2676 +2677 +2678 +2679 +2680 +2681 +2682 +2683 +2684 +2685 +2686 +2687 +2688 +2689 +2690 +2691 +2692 +2693 +2694 +2695 +2696 +2697 +2698 +2699 +2700 +2701 +2702 +2703 +2704 +2705 +2706 +2707 +2708 +2709 +2710 +2711 +2712 +2713 +2714 +2715 +2716 +2717 +2718 +2719 +2720 +2721 +2722 +2723 +2724 +2725 +2726 +2727 +2728 +2729 +2730 +2731 +2732 +2733 +2734 +2735 +2736 +2737 +2738 +2739 +2740 +2741 +2742 +2743 +2744 +2745 +2746 +2747 +2748 +2749 +2750 +2751 +2752 +2753 +2754 +2755 +2756 +2757 +2758 +2759 +2760 +2761 +2762 +2763 +2764 +2765 +2766 +2767 +2768 +2769 +2770 +2771 +2772 +2773 +2774 +2775 +2776 +2777 +2778 +2779 +2780 +2781 +2782 +2783 +2784 +2785 +2786 +2787 +2788 +2789 +2790 +2791 +2792 +2793 +2794 +2795 +2796 +2797 +2798 +2799 +2800 +2801 +2802 +2803 +2804 +2805 +2806 +2807 +2808 +2809 +2810 +2811 +2812 +2813 +2814 +2815 +2816 +2817 +2818 +2819 +2820 +2821 +2822 +2823 +2824 +2825 +2826 +2827 +2828 +2829 +2830 +2831 +2832 +2833 +2834 +2835 +2836 +2837 +2838 +2839 +2840 +2841 +2842 +2843 +2844 +2845 +2846 +2847 +2848 +2849 +2850 +2851 +2852 +2853 +2854 +2855 +2856 +2857 +2858 +2859 +2860 +2861 +2862 +2863 +2864 +2865 +2866 +2867 +2868 +2869 +2870 +2871 +2872 +2873 +2874 +2875 +2876 +2877 +2878 +2879 +2880 +2881 +2882 +2883 +2884 +2885 +2886 +2887 +2888 +2889 +2890 +2891 +2892 +2893 +2894 +2895 +2896 +2897 +2898 +2899 +2900 +2901 +2902 +2903 +2904 +2905 +2906 +2907 +2908 +2909 +2910 +2911 +2912 +2913 +2914 +2915 +2916 +2917 +2918 +2919 +2920 +2921 +2922 +2923 +2924 +2925 +2926 +2927 +2928 +2929 +2930 +2931 +2932 +2933 +2934 +2935 +2936 +2937 +2938 +2939 +2940 +2941 +2942 +2943 +2944 +2945 +2946 +2947 +2948 +2949 +2950 +2951 +2952 +2953 +2954 +2955 +2956 +2957 +2958 +2959 +2960 +2961 +2962 +2963 +2964 +2965 +2966 +2967 +2968 +2969 +2970 +2971 +2972 +2973 +2974 +2975 +2976 +2977 +2978 +2979 +2980 +2981 +2982 +2983 +2984 +2985 +2986 +2987 +2988 +2989 +2990 +2991 +2992 +2993 +2994 +2995 +2996 +2997 +2998 +2999 +3000 +3001 +3002 +3003 +3004 +3005 +3006 +3007 +3008 +3009 +3010 +3011 +3012 +3013 +3014 +3015 +3016 +3017 +3018 +3019 +3020 +3021 +3022 +3023 +3024 +3025 +3026 +3027 +3028 +3029 +3030 +3031 +3032 +3033 +3034 +3035 +3036 +3037 +3038 +3039 +3040 +3041 +3042 +3043 +3044 +3045 +3046 +3047 +3048 +3049 +3050 +3051 +3052 +3053 +3054 +3055 +3056 +3057 +3058 +3059 +3060 +3061 +3062 +3063 +3064 +3065 +3066 +3067 +3068 +3069 +3070 +3071 +3072 +3073 +3074 +3075 +3076 +3077 +3078 +3079 +3080 +3081 +3082 +3083 +3084 +3085 +3086 +3087 +3088 +3089 +3090 +3091 +3092 +3093 +3094 +3095 +3096 +3097 +3098 +3099 +3100 +3101 +3102 +3103 +3104 +3105 +3106 +3107 +3108 +3109 +3110 +3111 +3112 +3113 +3114 +3115 +3116 +3117 +3118 +3119 +3120 +3121 +3122 +3123 +3124 +3125 +3126 +3127 +3128 +3129 +3130 +3131 +3132 +3133 +3134 +3135 +3136 +3137 +3138 +3139 +3140 +3141 +3142 +3143 +3144 +3145 +3146 +3147 +3148 +3149 +3150 +3151 +3152 +3153 +3154 +3155 +3156 +3157 +3158 +3159 +3160 +3161 +3162 +3163 +3164 +3165 +3166 +3167 +3168 +3169 +3170 +3171 +3172 +3173 +3174 +3175 +3176 +3177 +3178 +3179 +3180 +3181 +3182 +3183 +3184 +3185 +3186 +3187 +3188 +3189 +3190 +3191 +3192 +3193 +3194 +3195 +3196 +3197 +3198 +3199 +3200 +3201 +3202 +3203 +3204 +3205 +3206 +3207 +3208 +3209 +3210 +3211 +3212 +3213 +3214 +3215 +3216 +3217 +3218 +3219 +3220 +3221 +3222 +3223 +3224 +3225 +3226 +3227 +3228 +3229 +3230 +3231 +3232 +3233 +3234 +3235 +3236 +3237 +3238 +3239 +3240 +3241 +3242 +3243 +3244 +3245 +3246 +3247 +3248 +3249 +3250 +3251 +3252 +3253 +3254 +3255 +3256 +3257 +3258 +3259 +3260 +3261 +3262 +3263 +3264 +3265 +3266 +3267 +3268 +3269 +3270 +3271 +3272 +3273 +3274 +3275 +3276 +3277 +3278 +3279 +3280 +3281 +3282 +3283 +3284 +3285 +3286 +3287 +3288 +3289 +3290 +3291 +3292 +3293 +3294 +3295 +3296 +3297 +3298 +3299 +3300 +3301 +3302 +3303 +3304 +3305 +3306 +3307 +3308 +3309 +3310 +3311 +3312 +3313 +3314 +3315 +3316 +3317 +3318 +3319 +3320 +3321 +3322 +3323 +3324 +3325 +3326 +3327 +3328 +3329 +3330 +3331 +3332 +3333 +3334 +3335 +3336 +3337 +3338 +3339 +3340 +3341 +3342 +3343 +3344 +3345 +3346 +3347 +3348 +3349 +3350 +3351 +3352 +3353 +3354 +3355 +3356 +3357 +3358 +3359 +3360 +3361 +3362 +3363 +3364 +3365 +3366 +3367 +3368 +3369 +3370 +3371 +3372 +3373 +3374 +3375 +3376 +3377 +3378 +3379 +3380 +3381 +3382 +3383 +3384 +3385 +3386 +3387 +3388 +3389 +3390 +3391 +3392 +3393 +3394 +3395 +3396 +3397 +3398 +3399 +3400 +3401 +3402 +3403 +3404 +3405 +3406 +3407 +3408 +3409 +3410 +3411 +3412 +3413 +3414 +3415 +3416 +3417 +3418 +3419 +3420 +3421 +3422 +3423 +3424 +3425 +3426 +3427 +3428 +3429 +3430 +3431 +3432 +3433 +3434 +3435 +3436 +3437 +3438 +3439 +3440 +3441 +3442 +3443 +3444 +3445 +3446 +3447 +3448 +3449 +3450 +3451 +3452 +3453 +3454 +3455 +3456 +3457 +3458 +3459 +3460 +3461 +3462 +3463 +3464 +3465 +3466 +3467 +3468 +3469 +3470 +3471 +3472 +3473 +3474 +3475 +3476 +3477 +3478 +3479 +3480 +3481 +3482 +3483 +3484 +3485 +3486 +3487 +3488 +3489 +3490 +3491 +3492 +3493 +3494 +3495 +3496 +3497 +3498 +3499 +3500 +3501 +3502 +3503 +3504 +3505 +3506 +3507 +3508 +3509 +3510 +3511 +3512 +3513 +3514 +3515 +3516 +3517 +3518 +3519 +3520 +3521 +3522 +3523 +3524 +3525 +3526 +3527 +3528 +3529 +3530 +3531 +3532 +3533 +3534 +3535 +3536 +3537 +3538 +3539 +3540 +3541 +3542 +3543 +3544 +3545 +3546 +3547 +3548 +3549 +3550 +3551 +3552 +3553 +3554 +3555 +3556 +3557 +3558 +3559 +3560 +3561 +3562 +3563 +3564 +3565 +3566 +3567 +3568 +3569 +3570 +3571 +3572 +3573 +3574 +3575 +3576 +3577 +3578 +3579 +3580 +3581 +3582 +3583 +3584 +3585 +3586 +3587 +3588 +3589 +3590 +3591 +3592 +3593 +3594 +3595 +3596 +3597 +3598 +3599 +3600 +3601 +3602 +3603 +3604 +3605 +3606 +3607 +3608 +3609 +3610 +3611 +3612 +3613 +3614 +3615 +3616 +3617 +3618 +3619 +3620 +3621 +3622 +3623 +3624 +3625 +3626 +3627 +3628 +3629 +3630 +3631 +3632 +3633 +3634 +3635 +3636 +3637 +3638 +3639 +3640 +3641 +3642 +3643 +3644 +3645 +3646 +3647 +3648 +3649 +3650 +3651 +3652 +3653 +3654 +3655 +3656 +3657 +3658 +3659 +3660 +3661 +3662 +3663 +3664 +3665 +3666 +3667 +3668 +3669 +3670 +3671 +3672 +3673 +3674 +3675 +3676 +3677 +3678 +3679 +3680 +3681 +3682 +3683 +3684 +3685 +3686 +3687 +3688 +3689 +3690 +3691 +3692 +3693 +3694 +3695 +3696 +3697 +3698 +3699 +3700 +3701 +3702 +3703 +3704 +3705 +3706 +3707 +3708 +3709 +3710 +3711 +3712 +3713 +3714 +3715 +3716 +3717 +3718 +3719 +3720 +3721 +3722 +3723 +3724 +3725 +3726 +3727 +3728 +3729 +3730 +3731 +3732 +3733 +3734 +3735 +3736 +3737 +3738 +3739 +3740 +3741 +3742 +3743 +3744 +3745 +3746 +3747 +3748 +3749 +3750 +3751 +3752 +3753 +3754 +3755 +3756 +3757 +3758 +3759 +3760 +3761 +3762 +3763 +3764 +3765 +3766 +3767 +3768 +3769 +3770 +3771 +3772 +3773 +3774 +3775 +3776 +3777 +3778 +3779 +3780 +3781 +3782 +3783 +3784 +3785 +3786 +3787 +3788 +3789 +3790 +3791 +3792 +3793 +3794 +3795 +3796 +3797 +3798 +3799 +3800 +3801 +3802 +3803 +3804 +3805 +3806 +3807 +3808 +3809 +3810 +3811 +3812 +3813 +3814 +3815 +3816 +3817 +3818 +3819 +3820 +3821 +3822 +3823 +3824 +3825 +3826 +3827 +3828 +3829 +3830 +3831 +3832 +3833 +3834 +3835 +3836 +3837 +3838 +3839 +3840 +3841 +3842 +3843 +3844 +3845 +3846 +3847 +3848 +3849 +3850 +3851 +3852 +3853 +3854 +3855 +3856 +3857 +3858 +3859 +3860 +3861 +3862 +3863 +3864 +3865 +3866 +3867 +3868 +3869 +3870 +3871 +3872 +3873 +3874 +3875 +3876 +3877 +3878 +3879 +3880 +3881 +3882 +3883 +3884 +3885 +3886 +3887 +3888 +3889 +3890 +3891 +3892 +3893 +3894 +3895 +3896 +3897 +3898 +3899 +3900 +3901 +3902 +3903 +3904 +3905 +3906 +3907 +3908 +3909 +3910 +3911 +3912 +3913 +3914 +3915 +3916 +3917 +3918 +3919 +3920 +3921 +3922 +3923 +3924 +3925 +3926 +3927 +3928 +3929 +3930 +3931 +3932 +3933 +3934 +3935 +3936 +3937 +3938 +3939 +3940 +3941 +3942 +3943 +3944 +3945 +3946 +3947 +3948 +3949 +3950 +3951 +3952 +3953 +3954 +3955 +3956 +3957 +3958 +3959 +3960 +3961 +3962 +3963 +3964 +3965 +3966 +3967 +3968 +3969 +3970 +3971 +3972 +3973 +3974 +3975 +3976 +3977 +3978 +3979 +3980 +3981 +3982 +3983 +3984 +3985 +3986 +3987 +3988 +3989 +3990 +3991 +3992 +3993 +3994 +3995 +3996 +3997 +3998 +3999 +4000 +4001 +4002 +4003 +4004 +4005 +4006 +4007 +4008 +4009 +4010 +4011 +4012 +4013 +4014 +4015 +4016 +4017 +4018 +4019 +4020 +4021 +4022 +4023 +4024 +4025 +4026 +4027 +4028 +4029 +4030 +4031 +4032 +4033 +4034 +4035 +4036 +4037 +4038 +4039 +4040 +4041 +4042 +4043 +4044 +4045 +4046 +4047 +4048 +4049 +4050 +4051 +4052 +4053 +4054 +4055 +4056 +4057 +4058 +4059 +4060 +4061 +4062 +4063 +4064 +4065 +4066 +4067 +4068 +4069 +4070 +4071 +4072 +4073 +4074 +4075 +4076 +4077 +4078 +4079 +4080 +4081 +4082 +4083 +4084 +4085 +4086 +4087 +4088 +4089 +4090 +4091 +4092 +4093 +4094 +4095 +4096 +4097 +4098 +4099 +4100 +4101 +4102 +4103 +4104 +4105 +4106 +4107 +4108 +4109 +4110 +4111 +4112 +4113 +4114 +4115 +4116 +4117 +4118 +4119 +4120 +4121 +4122 +4123 +4124 +4125 +4126 +4127 +4128 +4129 +4130 +4131 +4132 +4133 +4134 +4135 +4136 +4137 +4138 +4139 +4140 +4141 +4142 +4143 +4144 +4145 +4146 +4147 +4148 +4149 +4150 +4151 +4152 +4153 +4154 +4155 +4156 +4157 +4158 +4159 +4160 +4161 +4162 +4163 +4164 +4165 +4166 +4167 +4168 +4169 +4170 +4171 +4172 +4173 +4174 +4175 +4176 +4177 +4178 +4179 +4180 +4181 +4182 +4183 +4184 +4185 +4186 +4187 +4188 +4189 +4190 +4191 +4192 +4193 +4194 +4195 +4196 +4197 +4198 +4199 +4200 +4201 +4202 +4203 +4204 +4205 +4206 +4207 +4208 +4209 +4210 +4211 +4212 +4213 +4214 +4215 +4216 +4217 +4218 +4219 +4220 +4221 +4222 +4223 +4224 +4225 +4226 +4227 +4228 +4229 +4230 +4231 +4232 +4233 +4234 +4235 +4236 +4237 +4238 +4239 +4240 +4241 +4242 +4243 +4244 +4245 +4246 +4247 +4248 +4249 +4250 +4251 +4252 +4253 +4254 +4255 +4256 +4257 +4258 +4259 +4260 +4261 +4262 +4263 +4264 +4265 +4266 +4267 +4268 +4269 +4270 +4271 +4272 +4273 +4274 +4275 +4276 +4277 +4278 +4279 +4280 +4281 +4282 +4283 +4284 +4285 +4286 +4287 +4288 +4289 +4290 +4291 +4292 +4293 +4294 +4295 +4296 +4297 +4298 +4299 +4300 +4301 +4302 +4303 +4304 +4305 +4306 +4307 +4308 +4309 +4310 +4311 +4312 +4313 +4314 +4315 +4316 +4317 +4318 +4319 +4320 +4321 +4322 +4323 +4324 +4325 +4326 +4327 +4328 +4329 +4330 +4331 +4332 +4333 +4334 +4335 +4336 +4337 +4338 +4339 +4340 +4341 +4342 +4343 +4344 +4345 +4346 +4347 +4348 +4349 +4350 +4351 +4352 +4353 +4354 +4355 +4356 +4357 +4358 +4359 +4360 +4361 +4362 +4363 +4364 +4365 +4366 +4367 +4368 +4369 +4370 +4371 +4372 +4373 +4374 +4375 +4376 +4377 +4378 +4379 +4380 +4381 +4382 +4383 +4384 +4385 +4386 +4387 +4388 +4389 +4390 +4391 +4392 +4393 +4394 +4395 +4396 +4397 +4398 +4399 +4400 +4401 +4402 +4403 +4404 +4405 +4406 +4407 +4408 +4409 +4410 +4411 +4412 +4413 +4414 +4415 +4416 +4417 +4418 +4419 +4420 +4421 +4422 +4423 +4424 +4425 +4426 +4427 +4428 +4429 +4430 +4431 +4432 +4433 +4434 +4435 +4436 +4437 +4438 +4439 +4440 +4441 +4442 +4443 +4444 +4445 +4446 +4447 +4448 +4449 +4450 +4451 +4452 +4453 +4454 +4455 +4456 +4457 +4458 +4459 +4460 +4461 +4462 +4463 +4464 +4465 +4466 +4467 +4468 +4469 +4470 +4471 +4472 +4473 +4474 +4475 +4476 +4477 +4478 +4479 +4480 +4481 +4482 +4483 +4484 +4485 +4486 +4487 +4488 +4489 +4490 +4491 +4492 +4493 +4494 +4495 +4496 +4497 +4498 +4499 +4500 +4501 +4502 +4503 +4504 +4505 +4506 +4507 +4508 +4509 +4510 +4511 +4512 +4513 +4514 +4515 +4516 +4517 +4518 +4519 +4520 +4521 +4522 +4523 +4524 +4525 +4526 +4527 +4528 +4529 +4530 +4531 +4532 +4533 +4534 +4535 +4536 +4537 +4538 +4539 +4540 +4541 +4542 +4543 +4544 +4545 +4546 +4547 +4548 +4549 +4550 +4551 +4552 +4553 +4554 +4555 +4556 +4557 +4558 +4559 +4560 +4561 +4562 +4563 +4564 +4565 +4566 +4567 +4568 +4569 +4570 +4571 +4572 +4573 +4574 +4575 +4576 +4577 +4578 +4579 +4580 +4581 +4582 +4583 +4584 +4585 +4586 +4587 +4588 +4589 +4590 +4591 +4592 +4593 +4594 +4595 +4596 +4597 +4598 +4599 +4600 +4601 +4602 +4603 +4604 +4605 +4606 +4607 +4608 +4609 +4610 +4611 +4612 +4613 +4614 +4615 +4616 +4617 +4618 +4619 +4620 +4621 +4622 +4623 +4624 +4625 +4626 +4627 +4628 +4629 +4630 +4631 +4632 +4633 +4634 +4635 +4636 +4637 +4638 +4639 +4640 +4641 +4642 +4643 +4644 +4645 +4646 +4647 +4648 +4649 +4650 +4651 +4652 +4653 +4654 +4655 +4656 +4657 +4658 +4659 +4660 +4661 +4662 +4663 +4664 +4665 +4666 +4667 +4668 +4669 +4670 +4671 +4672 +4673 +4674 +4675 +4676 +4677 +4678 +4679 +4680 +4681 +4682 +4683 +4684 +4685 +4686 +4687 +4688 +4689 +4690 +4691 +4692 +4693 +4694 +4695 +4696 +4697 +4698 +4699 +4700 +4701 +4702 +4703 +4704 +4705 +4706 +4707 +4708 +4709 +4710 +4711 +4712 +4713 +4714 +4715 +4716 +4717 +4718 +4719 +4720 +4721 +4722 +4723 +4724 +4725 +4726 +4727 +4728 +4729 +4730 +4731 +4732 +4733 +4734 +4735 +4736 +4737 +4738 +4739 +4740 +4741 +4742 +4743 +4744 +4745 +4746 +4747 +4748 +4749 +4750 +4751 +4752 +4753 +4754 +4755 +4756 +4757 +4758 +4759 +4760 +4761 +4762 +4763 +4764 +4765 +4766 +4767 +4768 +4769 +4770 +4771 +4772 +4773 +4774 +4775 +4776 +4777 +4778 +4779 +4780 +4781 +4782 +4783 +4784 +4785 +4786 +4787 +4788 +4789 +4790 +4791 +4792 +4793 +4794 +4795 +4796 +4797 +4798 +4799 +4800 +4801 +4802 +4803 +4804 +4805 +4806 +4807 +4808 +4809 +4810 +4811 +4812 +4813 +4814 +4815 +4816 +4817 +4818 +4819 +4820 +4821 +4822 +4823 +4824 +4825 +4826 +4827 +4828 +4829 +4830 +4831 +4832 +4833 +4834 +4835 +4836 +4837 +4838 +4839 +4840 +4841 +4842 +4843 +4844 +4845 +4846 +4847 +4848 +4849 +4850 +4851 +4852 +4853 +4854 +4855 +4856 +4857 +4858 +4859 +4860 +4861 +4862 +4863 +4864 +4865 +4866 +4867 +4868 +4869 +4870 +4871 +4872 +4873 +4874 +4875 +4876 +4877 +4878 +4879 +4880 +4881 +4882 +4883 +4884 +4885 +4886 +4887 +4888 +4889 +4890 +4891 +4892 +4893 +4894 +4895 +4896 +4897 +4898 +4899 +4900 +4901 +4902 +4903 +4904 +4905 +4906 +4907 +4908 +4909 +4910 +4911 +4912 +4913 +4914 +4915 +4916 +4917 +4918 +4919 +4920 +4921 +4922 +4923 +4924 +4925 +4926 +4927 +4928 +4929 +4930 +4931 +4932 +4933 +4934 +4935 +4936 +4937 +4938 +4939 +4940 +4941 +4942 +4943 +4944 +4945 +4946 +4947 +4948 +4949 +4950 +4951 +4952 +4953 +4954 +4955 +4956 +4957 +4958 +4959 +4960 +4961 +4962 +4963 +4964 +4965 +4966 +4967 +4968 +4969 +4970 +4971 +4972 +4973 +4974 +4975 +4976 +4977 +4978 +4979 +4980 +4981 +4982 +4983 +4984 +4985 +4986 +4987 +4988 +4989 +4990 +4991 +4992 +4993 +4994 +4995 +4996 +4997 +4998 +4999 +5000 +5001 +5002 +5003 +5004 +5005 +5006 +5007 +5008 +5009 +5010 +5011 +5012 +5013 +5014 +5015 +5016 +5017 +5018 +5019 +5020 +5021 +5022 +5023 +5024 +5025 +5026 +5027 +5028 +5029 +5030 +5031 +5032 +5033 +5034 +5035 +5036 +5037 +5038 +5039 +5040 +5041 +5042 +5043 +5044 +5045 +5046 +5047 +5048 +5049 +5050 +5051 +5052 +5053 +5054 +5055 +5056 +5057 +5058 +5059 +5060 +5061 +5062 +5063 +5064 +5065 +5066 +5067 +5068 +5069 +5070 +5071 +5072 +5073 +5074 +5075 +5076 +5077 +5078 +5079 +5080 +5081 +5082 +5083 +5084 +5085 +5086 +5087 +5088 +5089 +5090 +5091 +5092 +5093 +5094 +5095 +5096 +5097 +5098 +5099 +5100 +5101 +5102 +5103 +5104 +5105 +5106 +5107 +5108 +5109 +5110 +5111 +5112 +5113 +5114 +5115 +5116 +5117 +5118 +5119 +5120 +5121 +5122 +5123 +5124 +5125 +5126 +5127 +5128 +5129 +5130 +5131 +5132 +5133 +5134 +5135 +5136 +5137 +5138 +5139 +5140 +5141 +5142 +5143 +5144 +5145 +5146 +5147 +5148 +5149 +5150 +5151 +5152 +5153 +5154 +5155 +5156 +5157 +5158 +5159 +5160 +5161 +5162 +5163 +5164 +5165 +5166 +5167 +5168 +5169 +5170 +5171 +5172 +5173 +5174 +5175 +5176 +5177 +5178 +5179 +5180 +5181 +5182 +5183 +5184 +5185 +5186 +5187 +5188 +5189 +5190 +5191 +5192 +5193 +5194 +5195 +5196 +5197 +5198 +5199 +5200 +5201 +5202 +5203 +5204 +5205 +5206 +5207 +5208 +5209 +5210 +5211 +5212 +5213 +5214 +5215 +5216 +5217 +5218 +5219 +5220 +5221 +5222 +5223 +5224 +5225 +5226 +5227 +5228 +5229 +5230 +5231 +5232 +5233 +5234 +5235 +5236 +5237 +5238 +5239 +5240 +5241 +5242 +5243 +5244 +5245 +5246 +5247 +5248 +5249 +5250 +5251 +5252 +5253 +5254 +5255 +5256 +5257 +5258 +5259 +5260 +5261 +5262 +5263 +5264 +5265 +5266 +5267 +5268 +5269 +5270 +5271 +5272 +5273 +5274 +5275 +5276 +5277 +5278 +5279 +5280 +5281 +5282 +5283 +5284 +5285 +5286 +5287 +5288 +5289 +5290 +5291 +5292 +5293 +5294 +5295 +5296 +5297 +5298 +5299 +5300 +5301 +5302 +5303 +5304 +5305 +5306 +5307 +5308 +5309 +5310 +5311 +5312 +5313 +5314 +5315 +5316 +5317 +5318 +5319 +5320 +5321 +5322 +5323 +5324 +5325 +5326 +5327 +5328 +5329 +5330 +5331 +5332 +5333 +5334 +5335 +5336 +5337 +5338 +5339 +5340 +5341 +5342 +5343 +5344 +5345 +5346 +5347 +5348 +5349 +5350 +5351 +5352 +5353 +5354 +5355 +5356 +5357 +5358 +5359 +5360 +5361 +5362 +5363 +5364 +5365 +5366 +5367 +5368 +5369 +5370 +5371 +5372 +5373 +5374 +5375 +5376 +5377 +5378 +5379 +5380 +5381 +5382 +5383 +5384 +5385 +5386 +5387 +5388 +5389 +5390 +5391 +5392 +5393 +5394 +5395 +5396 +5397 +5398 +5399 +5400 +5401 +5402 +5403 +5404 +5405 +5406 +5407 +5408 +5409 +5410 +5411 +5412 +5413 +5414 +5415 +5416 +5417 +5418 +5419 +5420 +5421 +5422 +5423 +5424 +5425 +5426 +5427 +5428 +5429 +5430 +5431 +5432 +5433 +5434 +5435 +5436 +5437 +5438 +5439 +5440 +5441 +5442 +5443 +5444 +5445 +5446 +5447 +5448 +5449 +5450 +5451 +5452 +5453 +5454 +5455 +5456 +5457 +5458 +5459 +5460 +5461 +5462 +5463 +5464 +5465 +5466 +5467 +5468 +5469 +5470 +5471 +5472 +5473 +5474 +5475 +5476 +5477 +5478 +5479 +5480 +5481 +5482 +5483 +5484 +5485 +5486 +5487 +5488 +5489 +5490 +5491 +5492 +5493 +5494 +5495 +5496 +5497 +5498 +5499 +5500 +5501 +5502 +5503 +5504 +5505 +5506 +5507 +5508 +5509 +5510 +5511 +5512 +5513 +5514 +5515 +5516 +5517 +5518 +5519 +5520 +5521 +5522 +5523 +5524 +5525 +5526 +5527 +5528 +5529 +5530 +5531 +5532 +5533 +5534 +5535 +5536 +5537 +5538 +5539 +5540 +5541 +5542 +5543 +5544 +5545 +5546 +5547 +5548 +5549 +5550 +5551 +5552 +5553 +5554 +5555 +5556 +5557 +5558 +5559 +5560 +5561 +5562 +5563 +5564 +5565 +5566 +5567 +5568 +5569 +5570 +5571 +5572 +5573 +5574 +5575 +5576 +5577 +5578 +5579 +5580 +5581 +5582 +5583 +5584 +5585 +5586 +5587 +5588 +5589 +5590 +5591 +5592 +5593 +5594 +5595 +5596 +5597 +5598 +5599 +5600 +5601 +5602 +5603 +5604 +5605 +5606 +5607 +5608 +5609 +5610 +5611 +5612 +5613 +5614 +5615 +5616 +5617 +5618 +5619 +5620 +5621 +5622 +5623 +5624 +5625 +5626 +5627 +5628 +5629 +5630 +5631 +5632 +5633 +5634 +5635 +5636 +5637 +5638 +5639 +5640 +5641 +5642 +5643 +5644 +5645 +5646 +5647 +5648 +5649 +5650 +5651 +5652 +5653 +5654 +5655 +5656 +5657 +5658 +5659 +5660 +5661 +5662 +5663 +5664 +5665 +5666 +5667 +5668 +5669 +5670 +5671 +5672 +5673 +5674 +5675 +5676 +5677 +5678 +5679 +5680 +5681 +5682 +5683 +5684 +5685 +5686 +5687 +5688 +5689 +5690 +5691 +5692 +5693 +5694 +5695 +5696 +5697 +5698 +5699 +5700 +5701 +5702 +5703 +5704 +5705 +5706 +5707 +5708 +5709 +5710 +5711 +5712 +5713 +5714 +5715 +5716 +5717 +5718 +5719 +5720 +5721 +5722 +5723 +5724 +5725 +5726 +5727 +5728 +5729 +5730 +5731 +5732 +5733 +5734 +5735 +5736 +5737 +5738 +5739 +5740 +5741 +5742 +5743 +5744 +5745 +5746 +5747 +5748 +5749 +5750 +5751 +5752 +5753 +5754 +5755 +5756 +5757 +5758 +5759 +5760 +5761 +5762 +5763 +5764 +5765 +5766 +5767 +5768 +5769 +5770 +5771 +5772 +5773 +5774 +5775 +5776 +5777 +5778 +5779 +5780 +5781 +5782 +5783 +5784 +5785 +5786 +5787 +5788 +5789 +5790 +5791 +5792 +5793 +5794 +5795 +5796 +5797 +5798 +5799 +5800 +5801 +5802 +5803 +5804 +5805 +5806 +5807 +5808 +5809 +5810 +5811 +5812 +5813 +5814 +5815 +5816 +5817 +5818 +5819 +5820 +5821 +5822 +5823 +5824 +5825 +5826 +5827 +5828 +5829 +5830 +5831 +5832 +5833 +5834 +5835 +5836 +5837 +5838 +5839 +5840 +5841 +5842 +5843 +5844 +5845 +5846 +5847 +5848 +5849 +5850 +5851 +5852 +5853 +5854 +5855 +5856 +5857 +5858 +5859 +5860 +5861 +5862 +5863 +5864 +5865 +5866 +5867 +5868 +5869 +5870 +5871 +5872 +5873 +5874 +5875 +5876 +5877 +5878 +5879 +5880 +5881 +5882 +5883 +5884 +5885 +5886 +5887 +5888 +5889 +5890 +5891 +5892 +5893 +5894 +5895 +5896 +5897 +5898 +5899 +5900 +5901 +5902 +5903 +5904 +5905 +5906 +5907 +5908 +5909 +5910 +5911 +5912 +5913 +5914 +5915 +5916 +5917 +5918 +5919 +5920 +5921 +5922 +5923 +5924 +5925 +5926 +5927 +5928 +5929 +5930 +5931 +5932 +5933 +5934 +5935 +5936 +5937 +5938 +5939 +5940 +5941 +5942 +5943 +5944 +5945 +5946 +5947 +5948 +5949 +5950 +5951 +5952 +5953 +5954 +5955 +5956 +5957 +5958 +5959 +5960 +5961 +5962 +5963 +5964 +5965 +5966 +5967 +5968 +5969 +5970 +5971 +5972 +5973 +5974 +5975 +5976 +5977 +5978 +5979 +5980 +5981 +5982 +5983 +5984 +5985 +5986 +5987 +5988 +5989 +5990 +5991 +5992 +5993 +5994 +5995 +5996 +5997 +5998 +5999 +6000 +6001 +6002 +6003 +6004 +6005 +6006 +6007 +6008 +6009 +6010 +6011 +6012 +6013 +6014 +6015 +6016 +6017 +6018 +6019 +6020 +6021 +6022 +6023 +6024 +6025 +6026 +6027 +6028 +6029 +6030 +6031 +6032 +6033 +6034 +6035 +6036 +6037 +6038 +6039 +6040 +6041 +6042 +6043 +6044 +6045 +6046 +6047 +6048 +6049 +6050 +6051 +6052 +6053 +6054 +6055 +6056 +6057 +6058 +6059 +6060 +6061 +6062 +6063 +6064 +6065 +6066 +6067 +6068 +6069 +6070 +6071 +6072 +6073 +6074 +6075 +6076 +6077 +6078 +6079 +6080 +6081 +6082 +6083 +6084 +6085 +6086 +6087 +6088 +6089 +6090 +6091 +6092 +6093 +6094 +6095 +6096 +6097 +6098 +6099 +6100 +6101 +6102 +6103 +6104 +6105 +6106 +6107 +6108 +6109 +6110 +6111 +6112 +6113 +6114 +6115 +6116 +6117 +6118 +6119 +6120 +6121 +6122 +6123 +6124 +6125 +6126 +6127 +6128 +6129 +6130 +6131 +6132 +6133 +6134 +6135 +6136 +6137 +6138 +6139 +6140 +6141 +6142 +6143 +6144 +6145 +6146 +6147 +6148 +6149 +6150 +6151 +6152 +6153 +6154 +6155 +6156 +6157 +6158 +6159 +6160 +6161 +6162 +6163 +6164 +6165 +6166 +6167 +6168 +6169 +6170 +6171 +6172 +6173 +6174 +6175 +6176 +6177 +6178 +6179 +6180 +6181 +6182 +6183 +6184 +6185 +6186 +6187 +6188 +6189 +6190 +6191 +6192 +6193 +6194 +6195 +6196 +6197 +6198 +6199 +6200 +6201 +6202 +6203 +6204 +6205 +6206 +6207 +6208 +6209 +6210 +6211 +6212 +6213 +6214 +6215 +6216 +6217 +6218 +6219 +6220 +6221 +6222 +6223 +6224 +6225 +6226 +6227 +6228 +6229 +6230 +6231 +6232 +6233 +6234 +6235 +6236 +6237 +6238 +6239 +6240 +6241 +6242 +6243 +6244 +6245 +6246 +6247 +6248 +6249 +6250 +6251 +6252 +6253 +6254 +6255 +6256 +6257 +6258 +6259 +6260 +6261 +6262 +6263 +6264 +6265 +6266 +6267 +6268 +6269 +6270 +6271 +6272 +6273 +6274 +6275 +6276 +6277 +6278 +6279 +6280 +6281 +6282 +6283 +6284 +6285 +6286 +6287 +6288 +6289 +6290 +6291 +6292 +6293 +6294 +6295 +6296 +6297 +6298 +6299 +6300 +6301 +6302 +6303 +6304 +6305 +6306 +6307 +6308 +6309 +6310 +6311 +6312 +6313 +6314 +6315 +6316 +6317 +6318 +6319 +6320 +6321 +6322 +6323 +6324 +6325 +6326 +6327 +6328 +6329 +6330 +6331 +6332 +6333 +6334 +6335 +6336 +6337 +6338 +6339 +6340 +6341 +6342 +6343 +6344 +6345 +6346 +6347 +6348 +6349 +6350 +6351 +6352 +6353 +6354 +6355 +6356 +6357 +6358 +6359 +6360 +6361 +6362 +6363 +6364 +6365 +6366 +6367 +6368 +6369 +6370 +6371 +6372 +6373 +6374 +6375 +6376 +6377 +6378 +6379 +6380 +6381 +6382 +6383 +6384 +6385 +6386 +6387 +6388 +6389 +6390 +6391 +6392 +6393 +6394 +6395 +6396 +6397 +6398 +6399 +6400 +6401 +6402 +6403 +6404 +6405 +6406 +6407 +6408 +6409 +6410 +6411 +6412 +6413 +6414 +6415 +6416 +6417 +6418 +6419 +6420 +6421 +6422 +6423 +6424 +6425 +6426 +6427 +6428 +6429 +6430 +6431 +6432 +6433 +6434 +6435 +6436 +6437 +6438 +6439 +6440 +6441 +6442 +6443 +6444 +6445 +6446 +6447 +6448 +6449 +6450 +6451 +6452 +6453 +6454 +6455 +6456 +6457 +6458 +6459 +6460 +6461 +6462 +6463 +6464 +6465 +6466 +6467 +6468 +6469 +6470 +6471 +6472 +6473 +6474 +6475 +6476 +6477 +6478 +6479 +6480 +6481 +6482 +6483 +6484 +6485 +6486 +6487 +6488 +6489 +6490 +6491 +6492 +6493 +6494 +6495 +6496 +6497 +6498 +6499 +6500 +6501 +6502 +6503 +6504 +6505 +6506 +6507 +6508 +6509 +6510 +6511 +6512 +6513 +6514 +6515 +6516 +6517 +6518 +6519 +6520 +6521 +6522 +6523 +6524 +6525 +6526 +6527 +6528 +6529 +6530 +6531 +6532 +6533 +6534 +6535 +6536 +6537 +6538 +6539 +6540 +6541 +6542 +6543 +6544 +6545 +6546 +6547 +6548 +6549 +6550 +6551 +6552 +6553 +6554 +6555 +6556 +6557 +6558 +6559 +6560 +6561 +6562 +6563 +6564 +6565 +6566 +6567 +6568 +6569 +6570 +6571 +6572 +6573 +6574 +6575 +6576 +6577 +6578 +6579 +6580 +6581 +6582 +6583 +6584 +6585 +6586 +6587 +6588 +6589 +6590 +6591 +6592 +6593 +6594 +6595 +6596 +6597 +6598 +6599 +6600 +6601 +6602 +6603 +6604 +6605 +6606 +6607 +6608 +6609 +6610 +6611 +6612 +6613 +6614 +6615 +6616 +6617 +6618 +6619 +6620 +6621 +6622 +6623 +6624 +6625 +6626 +6627 +6628 +6629 +6630 +6631 +6632 +6633 +6634 +6635 +6636 +6637 +6638 +6639 +6640 +6641 +6642 +6643 +6644 +6645 +6646 +6647 +6648 +6649 +6650 +6651 +6652 +6653 +6654 +6655 +6656 +6657 +6658 +6659 +6660 +6661 +6662 +6663 +6664 +6665 +6666 +6667 +6668 +6669 +6670 +6671 +6672 +6673 +6674 +6675 +6676 +6677 +6678 +6679 +6680 +6681 +6682 +6683 +6684 +6685 +6686 +6687 +6688 +6689 +6690 +6691 +6692 +6693 +6694 +6695 +6696 +6697 +6698 +6699 +6700 +6701 +6702 +6703 +6704 +6705 +6706 +6707 +6708 +6709 +6710 +6711 +6712 +6713 +6714 +6715 +6716 +6717 +6718 +6719 +6720 +6721 +6722 +6723 +6724 +6725 +6726 +6727 +6728 +6729 +6730 +6731 +6732 +6733 +6734 +6735 +6736 +6737 +6738 +6739 +6740 +6741 +6742 +6743 +6744 +6745 +6746 +6747 +6748 +6749 +6750 +6751 +6752 +6753 +6754 +6755 +6756 +6757 +6758 +6759 +6760 +6761 +6762 +6763 +6764 +6765 +6766 +6767 +6768 +6769 +6770 +6771 +6772 +6773 +6774 +6775 +6776 +6777 +6778 +6779 +6780 +6781 +6782 +6783 +6784 +6785 +6786 +6787 +6788 +6789 +6790 +6791 +6792 +6793 +6794 +6795 +6796 +6797 +6798 +6799 +6800 +6801 +6802 +6803 +6804 +6805 +6806 +6807 +6808 +6809 +6810 +6811 +6812 +6813 +6814 +6815 +6816 +6817 +6818 +6819 +6820 +6821 +6822 +6823 +6824 +6825 +6826 +6827 +6828 +6829 +6830 +6831 +6832 +6833 +6834 +6835 +6836 +6837 +6838 +6839 +6840 +6841 +6842 +6843 +6844 +6845 +6846 +6847 +6848 +6849 +6850 +6851 +6852 +6853 +6854 +6855 +6856 +6857 +6858 +6859 +6860 +6861 +6862 +6863 +6864 +6865 +6866 +6867 +6868 +6869 +6870 +6871 +6872 +6873 +6874 +6875 +6876 +6877 +6878 +6879 +6880 +6881 +6882 +6883 +6884 +6885 +6886 +6887 +6888 +6889 +6890 +6891 +6892 +6893 +6894 +6895 +6896 +6897 +6898 +6899 +6900 +6901 +6902 +6903 +6904 +6905 +6906 +6907 +6908 +6909 +6910 +6911 +6912 +6913 +6914 +6915 +6916 +6917 +6918 +6919 +6920 +6921 +6922 +6923 +6924 +6925 +6926 +6927 +6928 +6929 +6930 +6931 +6932 +6933 +6934 +6935 +6936 +6937 +6938 +6939 +6940 +6941 +6942 +6943 +6944 +6945 +6946 +6947 +6948 +6949 +6950 +6951 +6952 +6953 +6954 +6955 +6956 +6957 +6958 +6959 +6960 +6961 +6962 +6963 +6964 +6965 +6966 +6967 +6968 +6969 +6970 +6971 +6972 +6973 +6974 +6975 +6976 +6977 +6978 +6979 +6980 +6981 +6982 +6983 +6984 +6985 +6986 +6987 +6988 +6989 +6990 +6991 +6992 +6993 +6994 +6995 +6996 +6997 +6998 +6999 +7000 +7001 +7002 +7003 +7004 +7005 +7006 +7007 +7008 +7009 +7010 +7011 +7012 +7013 +7014 +7015 +7016 +7017 +7018 +7019 +7020 +7021 +7022 +7023 +7024 +7025 +7026 +7027 +7028 +7029 +7030 +7031 +7032 +7033 +7034 +7035 +7036 +7037 +7038 +7039 +7040 +7041 +7042 +7043 +7044 +7045 +7046 +7047 +7048 +7049 +7050 +7051 +7052 +7053 +7054 +7055 +7056 +7057 +7058 +7059 +7060 +7061 +7062 +7063 +7064 +7065 +7066 +7067 +7068 +7069 +7070 +7071 +7072 +7073 +7074 +7075 +7076 +7077 +7078 +7079 +7080 +7081 +7082 +7083 +7084 +7085 +7086 +7087 +7088 +7089 +7090 +7091 +7092 +7093 +7094 +7095 +7096 +7097 +7098 +7099 +7100 +7101 +7102 +7103 +7104 +7105 +7106 +7107 +7108 +7109 +7110 +7111 +7112 +7113 +7114 +7115 +7116 +7117 +7118 +7119 +7120 +7121 +7122 +7123 +7124 +7125 +7126 +7127 +7128 +7129 +7130 +7131 +7132 +7133 +7134 +7135 +7136 +7137 +7138 +7139 +7140 +7141 +7142 +7143 +7144 +7145 +7146 +7147 +7148 +7149 +7150 +7151 +7152 +7153 +7154 +7155 +7156 +7157 +7158 +7159 +7160 +7161 +7162 +7163 +7164 +7165 +7166 +7167 +7168 +7169 +7170 +7171 +7172 +7173 +7174 +7175 +7176 +7177 +7178 +7179 +7180 +7181 +7182 +7183 +7184 +7185 +7186 +7187 +7188 +7189 +7190 +7191 +7192 +7193 +7194 +7195 +7196 +7197 +7198 +7199 +7200 +7201 +7202 +7203 +7204 +7205 +7206 +7207 +7208 +7209 +7210 +7211 +7212 +7213 +7214 +7215 +7216 +7217 +7218 +7219 +7220 +7221 +7222 +7223 +7224 +7225 +7226 +7227 +7228 +7229 +7230 +7231 +7232 +7233 +7234 +7235 +7236 +7237 +7238 +7239 +7240 +7241 +7242 +7243 +7244 +7245 +7246 +7247 +7248 +7249 +7250 +7251 +7252 +7253 +7254 +7255 +7256 +7257 +7258 +7259 +7260 +7261 +7262 +7263 +7264 +7265 +7266 +7267 +7268 +7269 +7270 +7271 +7272 +7273 +7274 +7275 +7276 +7277 +7278 +7279 +7280 +7281 +7282 +7283 +7284 +7285 +7286 +7287 +7288 +7289 +7290 +7291 +7292 +7293 +7294 +7295 +7296 +7297 +7298 +7299 +7300 +7301 +7302 +7303 +7304 +7305 +7306 +7307 +7308 +7309 +7310 +7311 +7312 +7313 +7314 +7315 +7316 +7317 +7318 +7319 +7320 +7321 +7322 +7323 +7324 +7325 +7326 +7327 +7328 +7329 +7330 +7331 +7332 +7333 +7334 +7335 +7336 +7337 +7338 +7339 +7340 +7341 +7342 +7343 +7344 +7345 +7346 +7347 +7348 +7349 +7350 +7351 +7352 +7353 +7354 +7355 +7356 +7357 +7358 +7359 +7360 +7361 +7362 +7363 +7364 +7365 +7366 +7367 +7368 +7369 +7370 +7371 +7372 +7373 +7374 +7375 +7376 +7377 +7378 +7379 +7380 +7381 +7382 +7383 +7384 +7385 +7386 +7387 +7388 +7389 +7390 +7391 +7392 +7393 +7394 +7395 +7396 +7397 +7398 +7399 +7400 +7401 +7402 +7403 +7404 +7405 +7406 +7407 +7408 +7409 +7410 +7411 +7412 +7413 +7414 +7415 +7416 +7417 +7418 +7419 +7420 +7421 +7422 +7423 +7424 +7425 +7426 +7427 +7428 +7429 +7430 +7431 +7432 +7433 +7434 +7435 +7436 +7437 +7438 +7439 +7440 +7441 +7442 +7443 +7444 +7445 +7446 +7447 +7448 +7449 +7450 +7451 +7452 +7453 +7454 +7455 +7456 +7457 +7458 +7459 +7460 +7461 +7462 +7463 +7464 +7465 +7466 +7467 +7468 +7469 +7470 +7471 +7472 +7473 +7474 +7475 +7476 +7477 +7478 +7479 +7480 +7481 +7482 +7483 +7484 +7485 +7486 +7487 +7488 +7489 +7490 +7491 +7492 +7493 +7494 +7495 +7496 +7497 +7498 +7499 +7500 +7501 +7502 +7503 +7504 +7505 +7506 +7507 +7508 +7509 +7510 +7511 +7512 +7513 +7514 +7515 +7516 +7517 +7518 +7519 +7520 +7521 +7522 +7523 +7524 +7525 +7526 +7527 +7528 +7529 +7530 +7531 +7532 +7533 +7534 +7535 +7536 +7537 +7538 +7539 +7540 +7541 +7542 +7543 +7544 +7545 +7546 +7547 +7548 +7549 +7550 +7551 +7552 +7553 +7554 +7555 +7556 +7557 +7558 +7559 +7560 +7561 +7562 +7563 +7564 +7565 +7566 +7567 +7568 +7569 +7570 +7571 +7572 +7573 +7574 +7575 +7576 +7577 +7578 +7579 +7580 +7581 +7582 +7583 +7584 +7585 +7586 +7587 +7588 +7589 +7590 +7591 +7592 +7593 +7594 +7595 +7596 +7597 +7598 +7599 +7600 +7601 +7602 +7603 +7604 +7605 +7606 +7607 +7608 +7609 +7610 +7611 +7612 +7613 +7614 +7615 +7616 +7617 +7618 +7619 +7620 +7621 +7622 +7623 +7624 +7625 +7626 +7627 +7628 +7629 +7630 +7631 +7632 +7633 +7634 +7635 +7636 +7637 +7638 +7639 +7640 +7641 +7642 +7643 +7644 +7645 +7646 +7647 +7648 +7649 +7650 +7651 +7652 +7653 +7654 +7655 +7656 +7657 +7658 +7659 +7660 +7661 +7662 +7663 +7664 +7665 +7666 +7667 +7668 +7669 +7670 +7671 +7672 +7673 +7674 +7675 +7676 +7677 +7678 +7679 +7680 +7681 +7682 +7683 +7684 +7685 +7686 +7687 +7688 +7689 +7690 +7691 +7692 +7693 +7694 +7695 +7696 +7697 +7698 +7699 +7700 +7701 +7702 +7703 +7704 +7705 +7706 +7707 +7708 +7709 +7710 +7711 +7712 +7713 +7714 +7715 +7716 +7717 +7718 +7719 +7720 +7721 +7722 +7723 +7724 +7725 +7726 +7727 +7728 +7729 +7730 +7731 +7732 +7733 +7734 +7735 +7736 +7737 +7738 +7739 +7740 +7741 +7742 +7743 +7744 +7745 +7746 +7747 +7748 +7749 +7750 +7751 +7752 +7753 +7754 +7755 +7756 +7757 +7758 +7759 +7760 +7761 +7762 +7763 +7764 +7765 +7766 +7767 +7768 +7769 +7770 +7771 +7772 +7773 +7774 +7775 +7776 +7777 +7778 +7779 +7780 +7781 +7782 +7783 +7784 +7785 +7786 +7787 +7788 +7789 +7790 +7791 +7792 +7793 +7794 +7795 +7796 +7797 +7798 +7799 +7800 +7801 +7802 +7803 +7804 +7805 +7806 +7807 +7808 +7809 +7810 +7811 +7812 +7813 +7814 +7815 +7816 +7817 +7818 +7819 +7820 +7821 +7822 +7823 +7824 +7825 +7826 +7827 +7828 +7829 +7830 +7831 +7832 +7833 +7834 +7835 +7836 +7837 +7838 +7839 +7840 +7841 +7842 +7843 +7844 +7845 +7846 +7847 +7848 +7849 +7850 +7851 +7852 +7853 +7854 +7855 +7856 +7857 +7858 +7859 +7860 +7861 +7862 +7863 +7864 +7865 +7866 +7867 +7868 +7869 +7870 +7871 +7872 +7873 +7874 +7875 +7876 +7877 +7878 +7879 +7880 +7881 +7882 +7883 +7884 +7885 +7886 +7887 +7888 +7889 +7890 +7891 +7892 +7893 +7894 +7895 +7896 +7897 +7898 +7899 +7900 +7901 +7902 +7903 +7904 +7905 +7906 +7907 +7908 +7909 +7910 +7911 +7912 +7913 +7914 +7915 +7916 +7917 +7918 +7919 +7920 +7921 +7922 +7923 +7924 +7925 +7926 +7927 +7928 +7929 +7930 +7931 +7932 +7933 +7934 +7935 +7936 +7937 +7938 +7939 +7940 +7941 +7942 +7943 +7944 +7945 +7946 +7947 +7948 +7949 +7950 +7951 +7952 +7953 +7954 +7955 +7956 +7957 +7958 +7959 +7960 +7961 +7962 +7963 +7964 +7965 +7966 +7967 +7968 +7969 +7970 +7971 +7972 +7973 +7974 +7975 +7976 +7977 +7978 +7979 +7980 +7981 +7982 +7983 +7984 +7985 +7986 +7987 +7988 +7989 +7990 +7991 +7992 +7993 +7994 +7995 +7996 +7997 +7998 +7999 +8000 +8001 +8002 +8003 +8004 +8005 +8006 +8007 +8008 +8009 +8010 +8011 +8012 +8013 +8014 +8015 +8016 +8017 +8018 +8019 +8020 +8021 +8022 +8023 +8024 +8025 +8026 +8027 +8028 +8029 +8030 +8031 +8032 +8033 +8034 +8035 +8036 +8037 +8038 +8039 +8040 +8041 +8042 +8043 +8044 +8045 +8046 +8047 +8048 +8049 +8050 +8051 +8052 +8053 +8054 +8055 +8056 +8057 +8058 +8059 +8060 +8061 +8062 +8063 +8064 +8065 +8066 +8067 +8068 +8069 +8070 +8071 +8072 +8073 +8074 +8075 +8076 +8077 +8078 +8079 +8080 +8081 +8082 +8083 +8084 +8085 +8086 +8087 +8088 +8089 +8090 +8091 +8092 +8093 +8094 +8095 +8096 +8097 +8098 +8099 +8100 +8101 +8102 +8103 +8104 +8105 +8106 +8107 +8108 +8109 +8110 +8111 +8112 +8113 +8114 +8115 +8116 +8117 +8118 +8119 +8120 +8121 +8122 +8123 +8124 +8125 +8126 +8127 +8128 +8129 +8130 +8131 +8132 +8133 +8134 +8135 +8136 +8137 +8138 +8139 +8140 +8141 +8142 +8143 +8144 +8145 +8146 +8147 +8148 +8149 +8150 +8151 +8152 +8153 +8154 +8155 +8156 +8157 +8158 +8159 +8160 +8161 +8162 +8163 +8164 +8165 +8166 +8167 +8168 +8169 +8170 +8171 +8172 +8173 +8174 +8175 +8176 +8177 +8178 +8179 +8180 +8181 +8182 +8183 +8184 +8185 +8186 +8187 +8188 +8189 +8190 +8191 +8192 +8193 +8194 +8195 +8196 +8197 +8198 +8199 +8200 +8201 +8202 +8203 +8204 +8205 +8206 +8207 +8208 +8209 +8210 +8211 +8212 +8213 +8214 +8215 +8216 +8217 +8218 +8219 +8220 +8221 +8222 +8223 +8224 +8225 +8226 +8227 +8228 +8229 +8230 +8231 +8232 +8233 +8234 +8235 +8236 +8237 +8238 +8239 +8240 +8241 +8242 +8243 +8244 +8245 +8246 +8247 +8248 +8249 +8250 +8251 +8252 +8253 +8254 +8255 +8256 +8257 +8258 +8259 +8260 +8261 +8262 +8263 +8264 +8265 +8266 +8267 +8268 +8269 +8270 +8271 +8272 +8273 +8274 +8275 +8276 +8277 +8278 +8279 +8280 +8281 +8282 +8283 +8284 +8285 +8286 +8287 +8288 +8289 +8290 +8291 +8292 +8293 +8294 +8295 +8296 +8297 +8298 +8299 +8300 +8301 +8302 +8303 +8304 +8305 +8306 +8307 +8308 +8309 +8310 +8311 +8312 +8313 +8314 +8315 +8316 +8317 +8318 +8319 +8320 +8321 +8322 +8323 +8324 +8325 +8326 +8327 +8328 +8329 +8330 +8331 +8332 +8333 +8334 +8335 +8336 +8337 +8338 +8339 +8340 +8341 +8342 +8343 +8344 +8345 +8346 +8347 +8348 +8349 +8350 +8351 +8352 +8353 +8354 +8355 +8356 +8357 +8358 +8359 +8360 +8361 +8362 +8363 +8364 +8365 +8366 +8367 +8368 +8369 +8370 +8371 +8372 +8373 +8374 +8375 +8376 +8377 +8378 +8379 +8380 +8381 +8382 +8383 +8384 +8385 +8386 +8387 +8388 +8389 +8390 +8391 +8392 +8393 +8394 +8395 +8396 +8397 +8398 +8399 +8400 +8401 +8402 +8403 +8404 +8405 +8406 +8407 +8408 +8409 +8410 +8411 +8412 +8413 +8414 +8415 +8416 +8417 +8418 +8419 +8420 +8421 +8422 +8423 +8424 +8425 +8426 +8427 +8428 +8429 +8430 +8431 +8432 +8433 +8434 +8435 +8436 +8437 +8438 +8439 +8440 +8441 +8442 +8443 +8444 +8445 +8446 +8447 +8448 +8449 +8450 +8451 +8452 +8453 +8454 +8455 +8456 +8457 +8458 +8459 +8460 +8461 +8462 +8463 +8464 +8465 +8466 +8467 +8468 +8469 +8470 +8471 +8472 +8473 +8474 +8475 +8476 +8477 +8478 +8479 +8480 +8481 +8482 +8483 +8484 +8485 +8486 +8487 +8488 +8489 +8490 +8491 +8492 +8493 +8494 +8495 +8496 +8497 +8498 +8499 +8500 +8501 +8502 +8503 +8504 +8505 +8506 +8507 +8508 +8509 +8510 +8511 +8512 +8513 +8514 +8515 +8516 +8517 +8518 +8519 +8520 +8521 +8522 +8523 +8524 +8525 +8526 +8527 +8528 +8529 +8530 +8531 +8532 +8533 +8534 +8535 +8536 +8537 +8538 +8539 +8540 +8541 +8542 +8543 +8544 +8545 +8546 +8547 +8548 +8549 +8550 +8551 +8552 +8553 +8554 +8555 +8556 +8557 +8558 +8559 +8560 +8561 +8562 +8563 +8564 +8565 +8566 +8567 +8568 +8569 +8570 +8571 +8572 +8573 +8574 +8575 +8576 +8577 +8578 +8579 +8580 +8581 +8582 +8583 +8584 +8585 +8586 +8587 +8588 +8589 +8590 +8591 +8592 +8593 +8594 +8595 +8596 +8597 +8598 +8599 +8600 +8601 +8602 +8603 +8604 +8605 +8606 +8607 +8608 +8609 +8610 +8611 +8612 +8613 +8614 +8615 +8616 +8617 +8618 +8619 +8620 +8621 +8622 +8623 +8624 +8625 +8626 +8627 +8628 +8629 +8630 +8631 +8632 +8633 +8634 +8635 +8636 +8637 +8638 +8639 +8640 +8641 +8642 +8643 +8644 +8645 +8646 +8647 +8648 +8649 +8650 +8651 +8652 +8653 +8654 +8655 +8656 +8657 +8658 +8659 +8660 +8661 +8662 +8663 +8664 +8665 +8666 +8667 +8668 +8669 +8670 +8671 +8672 +8673 +8674 +8675 +8676 +8677 +8678 +8679 +8680 +8681 +8682 +8683 +8684 +8685 +8686 +8687 +8688 +8689 +8690 +8691 +8692 +8693 +8694 +8695 +8696 +8697 +8698 +8699 +8700 +8701 +8702 +8703 +8704 +8705 +8706 +8707 +8708 +8709 +8710 +8711 +8712 +8713 +8714 +8715 +8716 +8717 +8718 +8719 +8720 +8721 +8722 +8723 +8724 +8725 +8726 +8727 +8728 +8729 +8730 +8731 +8732 +8733 +8734 +8735 +8736 +8737 +8738 +8739 +8740 +8741 +8742 +8743 +8744 +8745 +8746 +8747 +8748 +8749 +8750 +8751 +8752 +8753 +8754 +8755 +8756 +8757 +8758 +8759 +8760 +8761 +8762 +8763 +8764 +8765 +8766 +8767 +8768 +8769 +8770 +8771 +8772 +8773 +8774 +8775 +8776 +8777 +8778 +8779 +8780 +8781 +8782 +8783 +8784 +8785 +8786 +8787 +8788 +8789 +8790 +8791 +8792 +8793 +8794 +8795 +8796 +8797 +8798 +8799 +8800 +8801 +8802 +8803 +8804 +8805 +8806 +8807 +8808 +8809 +8810 +8811 +8812 +8813 +8814 +8815 +8816 +8817 +8818 +8819 +8820 +8821 +8822 +8823 +8824 +8825 +8826 +8827 +8828 +8829 +8830 +8831 +8832 +8833 +8834 +8835 +8836 +8837 +8838 +8839 +8840 +8841 +8842 +8843 +8844 +8845 +8846 +8847 +8848 +8849 +8850 +8851 +8852 +8853 +8854 +8855 +8856 +8857 +8858 +8859 +8860 +8861 +8862 +8863 +8864 +8865 +8866 +8867 +8868 +8869 +8870 +8871 +8872 +8873 +8874 +8875 +8876 +8877 +8878 +8879 +8880 +8881 +8882 +8883 +8884 +8885 +8886 +8887 +8888 +8889 +8890 +8891 +8892 +8893 +8894 +8895 +8896 +8897 +8898 +8899 +8900 +8901 +8902 +8903 +8904 +8905 +8906 +8907 +8908 +8909 +8910 +8911 +8912 +8913 +8914 +8915 +8916 +8917 +8918 +8919 +8920 +8921 +8922 +8923 +8924 +8925 +8926 +8927 +8928 +8929 +8930 +8931 +8932 +8933 +8934 +8935 +8936 +8937 +8938 +8939 +8940 +8941 +8942 +8943 +8944 +8945 +8946 +8947 +8948 +8949 +8950 +8951 +8952 +8953 +8954 +8955 +8956 +8957 +8958 +8959 +8960 +8961 +8962 +8963 +8964 +8965 +8966 +8967 +8968 +8969 +8970 +8971 +8972 +8973 +8974 +8975 +8976 +8977 +8978 +8979 +8980 +8981 +8982 +8983 +8984 +8985 +8986 +8987 +8988 +8989 +8990 +8991 +8992 +8993 +8994 +8995 +8996 +8997 +8998 +8999 +9000 +9001 +9002 +9003 +9004 +9005 +9006 +9007 +9008 +9009 +9010 +9011 +9012 +9013 +9014 +9015 +9016 +9017 +9018 +9019 +9020 +9021 +9022 +9023 +9024 +9025 +9026 +9027 +9028 +9029 +9030 +9031 +9032 +9033 +9034 +9035 +9036 +9037 +9038 +9039 +9040 +9041 +9042 +9043 +9044 +9045 +9046 +9047 +9048 +9049 +9050 +9051 +9052 +9053 +9054 +9055 +9056 +9057 +9058 +9059 +9060 +9061 +9062 +9063 +9064 +9065 +9066 +9067 +9068 +9069 +9070 +9071 +9072 +9073 +9074 +9075 +9076 +9077 +9078 +9079 +9080 +9081 +9082 +9083 +9084 +9085 +9086 +9087 +9088 +9089 +9090 +9091 +9092 +9093 +9094 +9095 +9096 +9097 +9098 +9099 +9100 +9101 +9102 +9103 +9104 +9105 +9106 +9107 +9108 +9109 +9110 +9111 +9112 +9113 +9114 +9115 +9116 +9117 +9118 +9119 +9120 +9121 +9122 +9123 +9124 +9125 +9126 +9127 +9128 +9129 +9130 +9131 +9132 +9133 +9134 +9135 +9136 +9137 +9138 +9139 +9140 +9141 +9142 +9143 +9144 +9145 +9146 +9147 +9148 +9149 +9150 +9151 +9152 +9153 +9154 +9155 +9156 +9157 +9158 +9159 +9160 +9161 +9162 +9163 +9164 +9165 +9166 +9167 +9168 +9169 +9170 +9171 +9172 +9173 +9174 +9175 +9176 +9177 +9178 +9179 +9180 +9181 +9182 +9183 +9184 +9185 +9186 +9187 +9188 +9189 +9190 +9191 +9192 +9193 +9194 +9195 +9196 +9197 +9198 +9199 +9200 +9201 +9202 +9203 +9204 +9205 +9206 +9207 +9208 +9209 +9210 +9211 +9212 +9213 +9214 +9215 +9216 +9217 +9218 +9219 +9220 +9221 +9222 +9223 +9224 +9225 +9226 +9227 +9228 +9229 +9230 +9231 +9232 +9233 +9234 +9235 +9236 +9237 +9238 +9239 +9240 +9241 +9242 +9243 +9244 +9245 +9246 +9247 +9248 +9249 +9250 +9251 +9252 +9253 +9254 +9255 +9256 +9257 +9258 +9259 +9260 +9261 +9262 +9263 +9264 +9265 +9266 +9267 +9268 +9269 +9270 +9271 +9272 +9273 +9274 +9275 +9276 +9277 +9278 +9279 +9280 +9281 +9282 +9283 +9284 +9285 +9286 +9287 +9288 +9289 +9290 +9291 +9292 +9293 +9294 +9295 +9296 +9297 +9298 +9299 +9300 +9301 +9302 +9303 +9304 +9305 +9306 +9307 +9308 +9309 +9310 +9311 +9312 +9313 +9314 +9315 +9316 +9317 +9318 +9319 +9320 +9321 +9322 +9323 +9324 +9325 +9326 +9327 +9328 +9329 +9330 +9331 +9332 +9333 +9334 +9335 +9336 +9337 +9338 +9339 +9340 +9341 +9342 +9343 +9344 +9345 +9346 +9347 +9348 +9349 +9350 +9351 +9352 +9353 +9354 +9355 +9356 +9357 +9358 +9359 +9360 +9361 +9362 +9363 +9364 +9365 +9366 +9367 +9368 +9369 +9370 +9371 +9372 +9373 +9374 +9375 +9376 +9377 +9378 +9379 +9380 +9381 +9382 +9383 +9384 +9385 +9386 +9387 +9388 +9389 +9390 +9391 +9392 +9393 +9394 +9395 +9396 +9397 +9398 +9399 +9400 +9401 +9402 +9403 +9404 +9405 +9406 +9407 +9408 +9409 +9410 +9411 +9412 +9413 +9414 +9415 +9416 +9417 +9418 +9419 +9420 +9421 +9422 +9423 +9424 +9425 +9426 +9427 +9428 +9429 +9430 +9431 +9432 +9433 +9434 +9435 +9436 +9437 +9438 +9439 +9440 +9441 +9442 +9443 +9444 +9445 +9446 +9447 +9448 +9449 +9450 +9451 +9452 +9453 +9454 +9455 +9456 +9457 +9458 +9459 +9460 +9461 +9462 +9463 +9464 +9465 +9466 +9467 +9468 +9469 +9470 +9471 +9472 +9473 +9474 +9475 +9476 +9477 +9478 +9479 +9480 +9481 +9482 +9483 +9484 +9485 +9486 +9487 +9488 +9489 +9490 +9491 +9492 +9493 +9494 +9495 +9496 +9497 +9498 +9499 +9500 +9501 +9502 +9503 +9504 +9505 +9506 +9507 +9508 +9509 +9510 +9511 +9512 +9513 +9514 +9515 +9516 +9517 +9518 +9519 +9520 +9521 +9522 +9523 +9524 +9525 +9526 +9527 +9528 +9529 +9530 +9531 +9532 +9533 +9534 +9535 +9536 +9537 +9538 +9539 +9540 +9541 +9542 +9543 +9544 +9545 +9546 +9547 +9548 +9549 +9550 +9551 +9552 +9553 +9554 +9555 +9556 +9557 +9558 +9559 +9560 +9561 +9562 +9563 +9564 +9565 +9566 +9567 +9568 +9569 +9570 +9571 +9572 +9573 +9574 +9575 +9576 +9577 +9578 +9579 +9580 +9581 +9582 +9583 +9584 +9585 +9586 +9587 +9588 +9589 +9590 +9591 +9592 +9593 +9594 +9595 +9596 +9597 +9598 +9599 +9600 +9601 +9602 +9603 +9604 +9605 +9606 +9607 +9608 +9609 +9610 +9611 +9612 +9613 +9614 +9615 +9616 +9617 +9618 +9619 +9620 +9621 +9622 +9623 +9624 +9625 +9626 +9627 +9628 +9629 +9630 +9631 +9632 +9633 +9634 +9635 +9636 +9637 +9638 +9639 +9640 +9641 +9642 +9643 +9644 +9645 +9646 +9647 +9648 +9649 +9650 +9651 +9652 +9653 +9654 +9655 +9656 +9657 +9658 +9659 +9660 +9661 +9662 +9663 +9664 +9665 +9666 +9667 +9668 +9669 +9670 +9671 +9672 +9673 +9674 +9675 +9676 +9677 +9678 +9679 +9680 +9681 +9682 +9683 +9684 +9685 +9686 +9687 +9688 +9689 +9690 +9691 +9692 +9693 +9694 +9695 +9696 +9697 +9698 +9699 +9700 +9701 +9702 +9703 +9704 +9705 +9706 +9707 +9708 +9709 +9710 +9711 +9712 +9713 +9714 +9715 +9716 +9717 +9718 +9719 +9720 +9721 +9722 +9723 +9724 +9725 +9726 +9727 +9728 +9729 +9730 +9731 +9732 +9733 +9734 +9735 +9736 +9737 +9738 +9739 +9740 +9741 +9742 +9743 +9744 +9745 +9746 +9747 +9748 +9749 +9750 +9751 +9752 +9753 +9754 +9755 +9756 +9757 +9758 +9759 +9760 +9761 +9762 +9763 +9764 +9765 +9766 +9767 +9768 +9769 +9770 +9771 +9772 +9773 +9774 +9775 +9776 +9777 +9778 +9779 +9780 +9781 +9782 +9783 +9784 +9785 +9786 +9787 +9788 +9789 +9790 +9791 +9792 +9793 +9794 +9795 +9796 +9797 +9798 +9799 +9800 +9801 +9802 +9803 +9804 +9805 +9806 +9807 +9808 +9809 +9810 +9811 +9812 +9813 +9814 +9815 +9816 +9817 +9818 +9819 +9820 +9821 +9822 +9823 +9824 +9825 +9826 +9827 +9828 +9829 +9830 +9831 +9832 +9833 +9834 +9835 +9836 +9837 +9838 +9839 +9840 +9841 +9842 +9843 +9844 +9845 +9846 +9847 +9848 +9849 +9850 +9851 +9852 +9853 +9854 +9855 +9856 +9857 +9858 +9859 +9860 +9861 +9862 +9863 +9864 +9865 +9866 +9867 +9868 +9869 +9870 +9871 +9872 +9873 +9874 +9875 +9876 +9877 +9878 +9879 +9880 +9881 +9882 +9883 +9884 +9885 +9886 +9887 +9888 +9889 +9890 +9891 +9892 +9893 +9894 +9895 +9896 +9897 +9898 +9899 +9900 +9901 +9902 +9903 +9904 +9905 +9906 +9907 +9908 +9909 +9910 +9911 +9912 +9913 +9914 +9915 +9916 +9917 +9918 +9919 +9920 +9921 +9922 +9923 +9924 +9925 +9926 +9927 +9928 +9929 +9930 +9931 +9932 +9933 +9934 +9935 +9936 +9937 +9938 +9939 +9940 +9941 +9942 +9943 +9944 +9945 +9946 +9947 +9948 +9949 +9950 +9951 +9952 +9953 +9954 +9955 +9956 +9957 +9958 +9959 +9960 +9961 +9962 +9963 +9964 +9965 +9966 +9967 +9968 +9969 +9970 +9971 +9972 +9973 +9974 +9975 +9976 +9977 +9978 +9979 +9980 +9981 +9982 +9983 +9984 +9985 +9986 +9987 +9988 +9989 +9990 +9991 +9992 +9993 +9994 +9995 +9996 +9997 +9998 +9999 diff --git a/core-java-io/pom.xml b/core-java-modules/core-java-io/pom.xml similarity index 99% rename from core-java-io/pom.xml rename to core-java-modules/core-java-io/pom.xml index b6f8a317f6..44c703ee68 100644 --- a/core-java-io/pom.xml +++ b/core-java-modules/core-java-io/pom.xml @@ -10,7 +10,7 @@ com.baeldung parent-java 0.0.1-SNAPSHOT - ../parent-java + ../../parent-java diff --git a/core-java-io/src/main/java/com/baeldung/bufferedreader/BufferedReaderExample.java b/core-java-modules/core-java-io/src/main/java/com/baeldung/bufferedreader/BufferedReaderExample.java similarity index 100% rename from core-java-io/src/main/java/com/baeldung/bufferedreader/BufferedReaderExample.java rename to core-java-modules/core-java-io/src/main/java/com/baeldung/bufferedreader/BufferedReaderExample.java diff --git a/core-java-io/src/main/java/com/baeldung/csv/WriteCsvFileExample.java b/core-java-modules/core-java-io/src/main/java/com/baeldung/csv/WriteCsvFileExample.java similarity index 100% rename from core-java-io/src/main/java/com/baeldung/csv/WriteCsvFileExample.java rename to core-java-modules/core-java-io/src/main/java/com/baeldung/csv/WriteCsvFileExample.java diff --git a/core-java-io/src/main/java/com/baeldung/dirmonitoring/DirectoryMonitoringExample.java b/core-java-modules/core-java-io/src/main/java/com/baeldung/dirmonitoring/DirectoryMonitoringExample.java similarity index 100% rename from core-java-io/src/main/java/com/baeldung/dirmonitoring/DirectoryMonitoringExample.java rename to core-java-modules/core-java-io/src/main/java/com/baeldung/dirmonitoring/DirectoryMonitoringExample.java diff --git a/core-java-io/src/main/java/com/baeldung/download/FileDownload.java b/core-java-modules/core-java-io/src/main/java/com/baeldung/download/FileDownload.java similarity index 100% rename from core-java-io/src/main/java/com/baeldung/download/FileDownload.java rename to core-java-modules/core-java-io/src/main/java/com/baeldung/download/FileDownload.java diff --git a/core-java-io/src/main/java/com/baeldung/download/ResumableDownload.java b/core-java-modules/core-java-io/src/main/java/com/baeldung/download/ResumableDownload.java similarity index 100% rename from core-java-io/src/main/java/com/baeldung/download/ResumableDownload.java rename to core-java-modules/core-java-io/src/main/java/com/baeldung/download/ResumableDownload.java diff --git a/core-java-io/src/main/java/com/baeldung/extension/Extension.java b/core-java-modules/core-java-io/src/main/java/com/baeldung/extension/Extension.java similarity index 100% rename from core-java-io/src/main/java/com/baeldung/extension/Extension.java rename to core-java-modules/core-java-io/src/main/java/com/baeldung/extension/Extension.java diff --git a/core-java-io/src/main/java/com/baeldung/fileparser/BufferedReaderExample.java b/core-java-modules/core-java-io/src/main/java/com/baeldung/fileparser/BufferedReaderExample.java similarity index 100% rename from core-java-io/src/main/java/com/baeldung/fileparser/BufferedReaderExample.java rename to core-java-modules/core-java-io/src/main/java/com/baeldung/fileparser/BufferedReaderExample.java diff --git a/core-java-io/src/main/java/com/baeldung/fileparser/FileReaderExample.java b/core-java-modules/core-java-io/src/main/java/com/baeldung/fileparser/FileReaderExample.java similarity index 100% rename from core-java-io/src/main/java/com/baeldung/fileparser/FileReaderExample.java rename to core-java-modules/core-java-io/src/main/java/com/baeldung/fileparser/FileReaderExample.java diff --git a/core-java-io/src/main/java/com/baeldung/fileparser/FilesReadLinesExample.java b/core-java-modules/core-java-io/src/main/java/com/baeldung/fileparser/FilesReadLinesExample.java similarity index 100% rename from core-java-io/src/main/java/com/baeldung/fileparser/FilesReadLinesExample.java rename to core-java-modules/core-java-io/src/main/java/com/baeldung/fileparser/FilesReadLinesExample.java diff --git a/core-java-io/src/main/java/com/baeldung/fileparser/ScannerIntExample.java b/core-java-modules/core-java-io/src/main/java/com/baeldung/fileparser/ScannerIntExample.java similarity index 100% rename from core-java-io/src/main/java/com/baeldung/fileparser/ScannerIntExample.java rename to core-java-modules/core-java-io/src/main/java/com/baeldung/fileparser/ScannerIntExample.java diff --git a/core-java-io/src/main/java/com/baeldung/fileparser/ScannerStringExample.java b/core-java-modules/core-java-io/src/main/java/com/baeldung/fileparser/ScannerStringExample.java similarity index 100% rename from core-java-io/src/main/java/com/baeldung/fileparser/ScannerStringExample.java rename to core-java-modules/core-java-io/src/main/java/com/baeldung/fileparser/ScannerStringExample.java diff --git a/core-java-io/src/main/java/com/baeldung/files/ListFiles.java b/core-java-modules/core-java-io/src/main/java/com/baeldung/files/ListFiles.java similarity index 100% rename from core-java-io/src/main/java/com/baeldung/files/ListFiles.java rename to core-java-modules/core-java-io/src/main/java/com/baeldung/files/ListFiles.java diff --git a/core-java-io/src/main/java/com/baeldung/filesystem/jndi/LookupFSJNDI.java b/core-java-modules/core-java-io/src/main/java/com/baeldung/filesystem/jndi/LookupFSJNDI.java similarity index 100% rename from core-java-io/src/main/java/com/baeldung/filesystem/jndi/LookupFSJNDI.java rename to core-java-modules/core-java-io/src/main/java/com/baeldung/filesystem/jndi/LookupFSJNDI.java diff --git a/core-java-io/src/main/java/com/baeldung/java/nio/selector/EchoClient.java b/core-java-modules/core-java-io/src/main/java/com/baeldung/java/nio/selector/EchoClient.java similarity index 100% rename from core-java-io/src/main/java/com/baeldung/java/nio/selector/EchoClient.java rename to core-java-modules/core-java-io/src/main/java/com/baeldung/java/nio/selector/EchoClient.java diff --git a/core-java-io/src/main/java/com/baeldung/java/nio/selector/EchoServer.java b/core-java-modules/core-java-io/src/main/java/com/baeldung/java/nio/selector/EchoServer.java similarity index 100% rename from core-java-io/src/main/java/com/baeldung/java/nio/selector/EchoServer.java rename to core-java-modules/core-java-io/src/main/java/com/baeldung/java/nio/selector/EchoServer.java diff --git a/core-java-io/src/main/java/com/baeldung/java/nio/selector/README.md b/core-java-modules/core-java-io/src/main/java/com/baeldung/java/nio/selector/README.md similarity index 100% rename from core-java-io/src/main/java/com/baeldung/java/nio/selector/README.md rename to core-java-modules/core-java-io/src/main/java/com/baeldung/java/nio/selector/README.md diff --git a/core-java-io/src/main/java/com/baeldung/java/nio2/visitor/FileSearchExample.java b/core-java-modules/core-java-io/src/main/java/com/baeldung/java/nio2/visitor/FileSearchExample.java similarity index 100% rename from core-java-io/src/main/java/com/baeldung/java/nio2/visitor/FileSearchExample.java rename to core-java-modules/core-java-io/src/main/java/com/baeldung/java/nio2/visitor/FileSearchExample.java diff --git a/core-java-io/src/main/java/com/baeldung/java/nio2/visitor/FileVisitorImpl.java b/core-java-modules/core-java-io/src/main/java/com/baeldung/java/nio2/visitor/FileVisitorImpl.java similarity index 100% rename from core-java-io/src/main/java/com/baeldung/java/nio2/visitor/FileVisitorImpl.java rename to core-java-modules/core-java-io/src/main/java/com/baeldung/java/nio2/visitor/FileVisitorImpl.java diff --git a/core-java-io/src/main/java/com/baeldung/java/nio2/watcher/DirectoryWatcherExample.java b/core-java-modules/core-java-io/src/main/java/com/baeldung/java/nio2/watcher/DirectoryWatcherExample.java similarity index 100% rename from core-java-io/src/main/java/com/baeldung/java/nio2/watcher/DirectoryWatcherExample.java rename to core-java-modules/core-java-io/src/main/java/com/baeldung/java/nio2/watcher/DirectoryWatcherExample.java diff --git a/core-java-io/src/main/java/com/baeldung/stream/FileCopy.java b/core-java-modules/core-java-io/src/main/java/com/baeldung/stream/FileCopy.java similarity index 100% rename from core-java-io/src/main/java/com/baeldung/stream/FileCopy.java rename to core-java-modules/core-java-io/src/main/java/com/baeldung/stream/FileCopy.java diff --git a/core-java-io/src/main/java/com/baeldung/stream/OutputStreamExamples.java b/core-java-modules/core-java-io/src/main/java/com/baeldung/stream/OutputStreamExamples.java similarity index 100% rename from core-java-io/src/main/java/com/baeldung/stream/OutputStreamExamples.java rename to core-java-modules/core-java-io/src/main/java/com/baeldung/stream/OutputStreamExamples.java diff --git a/core-java-io/src/main/java/com/baeldung/symlink/SymLinkExample.java b/core-java-modules/core-java-io/src/main/java/com/baeldung/symlink/SymLinkExample.java similarity index 100% rename from core-java-io/src/main/java/com/baeldung/symlink/SymLinkExample.java rename to core-java-modules/core-java-io/src/main/java/com/baeldung/symlink/SymLinkExample.java diff --git a/core-java-io/src/main/java/com/baeldung/unzip/UnzipFile.java b/core-java-modules/core-java-io/src/main/java/com/baeldung/unzip/UnzipFile.java similarity index 100% rename from core-java-io/src/main/java/com/baeldung/unzip/UnzipFile.java rename to core-java-modules/core-java-io/src/main/java/com/baeldung/unzip/UnzipFile.java diff --git a/core-java-io/src/main/java/com/baeldung/util/StreamUtils.java b/core-java-modules/core-java-io/src/main/java/com/baeldung/util/StreamUtils.java similarity index 100% rename from core-java-io/src/main/java/com/baeldung/util/StreamUtils.java rename to core-java-modules/core-java-io/src/main/java/com/baeldung/util/StreamUtils.java diff --git a/core-java-io/src/main/java/com/baeldung/zip/ZipDirectory.java b/core-java-modules/core-java-io/src/main/java/com/baeldung/zip/ZipDirectory.java similarity index 100% rename from core-java-io/src/main/java/com/baeldung/zip/ZipDirectory.java rename to core-java-modules/core-java-io/src/main/java/com/baeldung/zip/ZipDirectory.java diff --git a/core-java-io/src/main/java/com/baeldung/zip/ZipFile.java b/core-java-modules/core-java-io/src/main/java/com/baeldung/zip/ZipFile.java similarity index 100% rename from core-java-io/src/main/java/com/baeldung/zip/ZipFile.java rename to core-java-modules/core-java-io/src/main/java/com/baeldung/zip/ZipFile.java diff --git a/core-java-io/src/main/java/com/baeldung/zip/ZipMultipleFiles.java b/core-java-modules/core-java-io/src/main/java/com/baeldung/zip/ZipMultipleFiles.java similarity index 100% rename from core-java-io/src/main/java/com/baeldung/zip/ZipMultipleFiles.java rename to core-java-modules/core-java-io/src/main/java/com/baeldung/zip/ZipMultipleFiles.java diff --git a/core-java-io/src/main/resources/ESAPI.properties b/core-java-modules/core-java-io/src/main/resources/ESAPI.properties similarity index 100% rename from core-java-io/src/main/resources/ESAPI.properties rename to core-java-modules/core-java-io/src/main/resources/ESAPI.properties diff --git a/core-java-io/src/main/resources/META-INF/BenchmarkList b/core-java-modules/core-java-io/src/main/resources/META-INF/BenchmarkList old mode 100755 new mode 100644 similarity index 100% rename from core-java-io/src/main/resources/META-INF/BenchmarkList rename to core-java-modules/core-java-io/src/main/resources/META-INF/BenchmarkList diff --git a/core-java-io/src/main/resources/META-INF/persistence.xml b/core-java-modules/core-java-io/src/main/resources/META-INF/persistence.xml similarity index 100% rename from core-java-io/src/main/resources/META-INF/persistence.xml rename to core-java-modules/core-java-io/src/main/resources/META-INF/persistence.xml diff --git a/core-java-io/src/main/resources/META-INF/services/com.sun.source.util.Plugin b/core-java-modules/core-java-io/src/main/resources/META-INF/services/com.sun.source.util.Plugin similarity index 100% rename from core-java-io/src/main/resources/META-INF/services/com.sun.source.util.Plugin rename to core-java-modules/core-java-io/src/main/resources/META-INF/services/com.sun.source.util.Plugin diff --git a/core-java-io/src/main/resources/countries.properties b/core-java-modules/core-java-io/src/main/resources/countries.properties similarity index 82% rename from core-java-io/src/main/resources/countries.properties rename to core-java-modules/core-java-io/src/main/resources/countries.properties index e743b5a40b..3c1f53aded 100644 --- a/core-java-io/src/main/resources/countries.properties +++ b/core-java-modules/core-java-io/src/main/resources/countries.properties @@ -1,3 +1,3 @@ -UK -US -Germany +UK +US +Germany diff --git a/core-java-io/src/main/resources/data.csv b/core-java-modules/core-java-io/src/main/resources/data.csv similarity index 100% rename from core-java-io/src/main/resources/data.csv rename to core-java-modules/core-java-io/src/main/resources/data.csv diff --git a/core-java-io/src/main/resources/datasource.properties b/core-java-modules/core-java-io/src/main/resources/datasource.properties similarity index 100% rename from core-java-io/src/main/resources/datasource.properties rename to core-java-modules/core-java-io/src/main/resources/datasource.properties diff --git a/core-java-io/src/main/resources/dirCompressed.zip b/core-java-modules/core-java-io/src/main/resources/dirCompressed.zip similarity index 100% rename from core-java-io/src/main/resources/dirCompressed.zip rename to core-java-modules/core-java-io/src/main/resources/dirCompressed.zip diff --git a/core-java-io/src/main/resources/input.txt b/core-java-modules/core-java-io/src/main/resources/input.txt similarity index 100% rename from core-java-io/src/main/resources/input.txt rename to core-java-modules/core-java-io/src/main/resources/input.txt diff --git a/core-java-io/src/main/resources/js/bind.js b/core-java-modules/core-java-io/src/main/resources/js/bind.js similarity index 100% rename from core-java-io/src/main/resources/js/bind.js rename to core-java-modules/core-java-io/src/main/resources/js/bind.js diff --git a/core-java-io/src/main/resources/js/locations.js b/core-java-modules/core-java-io/src/main/resources/js/locations.js similarity index 100% rename from core-java-io/src/main/resources/js/locations.js rename to core-java-modules/core-java-io/src/main/resources/js/locations.js diff --git a/core-java-io/src/main/resources/js/math_module.js b/core-java-modules/core-java-io/src/main/resources/js/math_module.js similarity index 100% rename from core-java-io/src/main/resources/js/math_module.js rename to core-java-modules/core-java-io/src/main/resources/js/math_module.js diff --git a/core-java-io/src/main/resources/js/no_such.js b/core-java-modules/core-java-io/src/main/resources/js/no_such.js similarity index 100% rename from core-java-io/src/main/resources/js/no_such.js rename to core-java-modules/core-java-io/src/main/resources/js/no_such.js diff --git a/core-java-io/src/main/resources/js/script.js b/core-java-modules/core-java-io/src/main/resources/js/script.js similarity index 100% rename from core-java-io/src/main/resources/js/script.js rename to core-java-modules/core-java-io/src/main/resources/js/script.js diff --git a/core-java-io/src/main/resources/js/trim.js b/core-java-modules/core-java-io/src/main/resources/js/trim.js similarity index 100% rename from core-java-io/src/main/resources/js/trim.js rename to core-java-modules/core-java-io/src/main/resources/js/trim.js diff --git a/core-java-io/src/main/resources/js/typed_arrays.js b/core-java-modules/core-java-io/src/main/resources/js/typed_arrays.js similarity index 100% rename from core-java-io/src/main/resources/js/typed_arrays.js rename to core-java-modules/core-java-io/src/main/resources/js/typed_arrays.js diff --git a/core-java-io/src/main/resources/log4j.properties b/core-java-modules/core-java-io/src/main/resources/log4j.properties similarity index 100% rename from core-java-io/src/main/resources/log4j.properties rename to core-java-modules/core-java-io/src/main/resources/log4j.properties diff --git a/core-java-io/src/main/resources/log4jstructuraldp.properties b/core-java-modules/core-java-io/src/main/resources/log4jstructuraldp.properties similarity index 100% rename from core-java-io/src/main/resources/log4jstructuraldp.properties rename to core-java-modules/core-java-io/src/main/resources/log4jstructuraldp.properties diff --git a/core-java-io/src/main/resources/logback.xml b/core-java-modules/core-java-io/src/main/resources/logback.xml similarity index 100% rename from core-java-io/src/main/resources/logback.xml rename to core-java-modules/core-java-io/src/main/resources/logback.xml diff --git a/core-java-io/src/main/resources/multiCompressed.zip b/core-java-modules/core-java-io/src/main/resources/multiCompressed.zip similarity index 100% rename from core-java-io/src/main/resources/multiCompressed.zip rename to core-java-modules/core-java-io/src/main/resources/multiCompressed.zip diff --git a/core-java-io/src/main/resources/unzipTest/compressed.zip b/core-java-modules/core-java-io/src/main/resources/unzipTest/compressed.zip similarity index 100% rename from core-java-io/src/main/resources/unzipTest/compressed.zip rename to core-java-modules/core-java-io/src/main/resources/unzipTest/compressed.zip diff --git a/core-java-io/src/main/resources/zipTest/test1.txt b/core-java-modules/core-java-io/src/main/resources/zipTest/test1.txt similarity index 100% rename from core-java-io/src/main/resources/zipTest/test1.txt rename to core-java-modules/core-java-io/src/main/resources/zipTest/test1.txt diff --git a/core-java-io/src/main/resources/zipTest/test2.txt b/core-java-modules/core-java-io/src/main/resources/zipTest/test2.txt similarity index 100% rename from core-java-io/src/main/resources/zipTest/test2.txt rename to core-java-modules/core-java-io/src/main/resources/zipTest/test2.txt diff --git a/core-java-io/src/test/java/com/baeldung/bufferedreader/BufferedReaderExampleUnitTest.java b/core-java-modules/core-java-io/src/test/java/com/baeldung/bufferedreader/BufferedReaderExampleUnitTest.java similarity index 100% rename from core-java-io/src/test/java/com/baeldung/bufferedreader/BufferedReaderExampleUnitTest.java rename to core-java-modules/core-java-io/src/test/java/com/baeldung/bufferedreader/BufferedReaderExampleUnitTest.java diff --git a/core-java-io/src/test/java/com/baeldung/bufferedreader/BufferedReaderUnitTest.java b/core-java-modules/core-java-io/src/test/java/com/baeldung/bufferedreader/BufferedReaderUnitTest.java similarity index 100% rename from core-java-io/src/test/java/com/baeldung/bufferedreader/BufferedReaderUnitTest.java rename to core-java-modules/core-java-io/src/test/java/com/baeldung/bufferedreader/BufferedReaderUnitTest.java diff --git a/core-java-io/src/test/java/com/baeldung/copyfiles/FileCopierIntegrationTest.java b/core-java-modules/core-java-io/src/test/java/com/baeldung/copyfiles/FileCopierIntegrationTest.java similarity index 97% rename from core-java-io/src/test/java/com/baeldung/copyfiles/FileCopierIntegrationTest.java rename to core-java-modules/core-java-io/src/test/java/com/baeldung/copyfiles/FileCopierIntegrationTest.java index 4603644bf5..2b4a15ed59 100644 --- a/core-java-io/src/test/java/com/baeldung/copyfiles/FileCopierIntegrationTest.java +++ b/core-java-modules/core-java-io/src/test/java/com/baeldung/copyfiles/FileCopierIntegrationTest.java @@ -1,69 +1,69 @@ -package com.baeldung.copyfiles; - -import java.io.BufferedInputStream; -import java.io.BufferedOutputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.nio.file.StandardCopyOption; - -import org.apache.commons.io.FileUtils; -import org.junit.Before; -import org.junit.Test; -import static org.assertj.core.api.Assertions.*; - -public class FileCopierIntegrationTest { - File original = new File("src/test/resources/original.txt"); - - @Before - public void init() throws IOException { - if (!original.exists()) - Files.createFile(original.toPath()); - } - - @Test - public void givenIoAPI_whenCopied_thenCopyExistsWithSameContents() throws IOException { - File copied = new File("src/test/resources/copiedWithIo.txt"); - try (InputStream in = new BufferedInputStream(new FileInputStream(original)); OutputStream out = new BufferedOutputStream(new FileOutputStream(copied))) { - byte[] buffer = new byte[1024]; - int lengthRead; - while ((lengthRead = in.read(buffer)) > 0) { - out.write(buffer, 0, lengthRead); - out.flush(); - } - } - assertThat(copied).exists(); - assertThat(Files.readAllLines(original.toPath()).equals(Files.readAllLines(copied.toPath()))); - } - - @Test - public void givenCommonsIoAPI_whenCopied_thenCopyExistsWithSameContents() throws IOException { - File copied = new File("src/test/resources/copiedWithApacheCommons.txt"); - FileUtils.copyFile(original, copied); - assertThat(copied).exists(); - assertThat(Files.readAllLines(original.toPath()).equals(Files.readAllLines(copied.toPath()))); - } - - @Test - public void givenNIO2_whenCopied_thenCopyExistsWithSameContents() throws IOException { - Path copied = Paths.get("src/test/resources/copiedWithNio.txt"); - Path originalPath = original.toPath(); - Files.copy(originalPath, copied, StandardCopyOption.REPLACE_EXISTING); - assertThat(copied).exists(); - assertThat(Files.readAllLines(originalPath).equals(Files.readAllLines(copied))); - } - - @Test - public void givenGuava_whenCopied_thenCopyExistsWithSameContents() throws IOException { - File copied = new File("src/test/resources/copiedWithApacheCommons.txt"); - com.google.common.io.Files.copy(original, copied); - assertThat(copied).exists(); - assertThat(Files.readAllLines(original.toPath()).equals(Files.readAllLines(copied.toPath()))); - } -} +package com.baeldung.copyfiles; + +import java.io.BufferedInputStream; +import java.io.BufferedOutputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.StandardCopyOption; + +import org.apache.commons.io.FileUtils; +import org.junit.Before; +import org.junit.Test; +import static org.assertj.core.api.Assertions.*; + +public class FileCopierIntegrationTest { + File original = new File("src/test/resources/original.txt"); + + @Before + public void init() throws IOException { + if (!original.exists()) + Files.createFile(original.toPath()); + } + + @Test + public void givenIoAPI_whenCopied_thenCopyExistsWithSameContents() throws IOException { + File copied = new File("src/test/resources/copiedWithIo.txt"); + try (InputStream in = new BufferedInputStream(new FileInputStream(original)); OutputStream out = new BufferedOutputStream(new FileOutputStream(copied))) { + byte[] buffer = new byte[1024]; + int lengthRead; + while ((lengthRead = in.read(buffer)) > 0) { + out.write(buffer, 0, lengthRead); + out.flush(); + } + } + assertThat(copied).exists(); + assertThat(Files.readAllLines(original.toPath()).equals(Files.readAllLines(copied.toPath()))); + } + + @Test + public void givenCommonsIoAPI_whenCopied_thenCopyExistsWithSameContents() throws IOException { + File copied = new File("src/test/resources/copiedWithApacheCommons.txt"); + FileUtils.copyFile(original, copied); + assertThat(copied).exists(); + assertThat(Files.readAllLines(original.toPath()).equals(Files.readAllLines(copied.toPath()))); + } + + @Test + public void givenNIO2_whenCopied_thenCopyExistsWithSameContents() throws IOException { + Path copied = Paths.get("src/test/resources/copiedWithNio.txt"); + Path originalPath = original.toPath(); + Files.copy(originalPath, copied, StandardCopyOption.REPLACE_EXISTING); + assertThat(copied).exists(); + assertThat(Files.readAllLines(originalPath).equals(Files.readAllLines(copied))); + } + + @Test + public void givenGuava_whenCopied_thenCopyExistsWithSameContents() throws IOException { + File copied = new File("src/test/resources/copiedWithApacheCommons.txt"); + com.google.common.io.Files.copy(original, copied); + assertThat(copied).exists(); + assertThat(Files.readAllLines(original.toPath()).equals(Files.readAllLines(copied.toPath()))); + } +} diff --git a/core-java-io/src/test/java/com/baeldung/csv/ReadCSVInArrayUnitTest.java b/core-java-modules/core-java-io/src/test/java/com/baeldung/csv/ReadCSVInArrayUnitTest.java similarity index 100% rename from core-java-io/src/test/java/com/baeldung/csv/ReadCSVInArrayUnitTest.java rename to core-java-modules/core-java-io/src/test/java/com/baeldung/csv/ReadCSVInArrayUnitTest.java diff --git a/core-java-io/src/test/java/com/baeldung/csv/WriteCsvFileExampleUnitTest.java b/core-java-modules/core-java-io/src/test/java/com/baeldung/csv/WriteCsvFileExampleUnitTest.java similarity index 100% rename from core-java-io/src/test/java/com/baeldung/csv/WriteCsvFileExampleUnitTest.java rename to core-java-modules/core-java-io/src/test/java/com/baeldung/csv/WriteCsvFileExampleUnitTest.java diff --git a/core-java-io/src/test/java/com/baeldung/directories/NewDirectoryUnitTest.java b/core-java-modules/core-java-io/src/test/java/com/baeldung/directories/NewDirectoryUnitTest.java similarity index 100% rename from core-java-io/src/test/java/com/baeldung/directories/NewDirectoryUnitTest.java rename to core-java-modules/core-java-io/src/test/java/com/baeldung/directories/NewDirectoryUnitTest.java diff --git a/core-java-io/src/test/java/com/baeldung/download/FileDownloadIntegrationTest.java b/core-java-modules/core-java-io/src/test/java/com/baeldung/download/FileDownloadIntegrationTest.java similarity index 100% rename from core-java-io/src/test/java/com/baeldung/download/FileDownloadIntegrationTest.java rename to core-java-modules/core-java-io/src/test/java/com/baeldung/download/FileDownloadIntegrationTest.java diff --git a/core-java-io/src/test/java/com/baeldung/extension/ExtensionUnitTest.java b/core-java-modules/core-java-io/src/test/java/com/baeldung/extension/ExtensionUnitTest.java similarity index 100% rename from core-java-io/src/test/java/com/baeldung/extension/ExtensionUnitTest.java rename to core-java-modules/core-java-io/src/test/java/com/baeldung/extension/ExtensionUnitTest.java diff --git a/core-java-io/src/test/java/com/baeldung/file/FileOperationsManualTest.java b/core-java-modules/core-java-io/src/test/java/com/baeldung/file/FileOperationsManualTest.java similarity index 100% rename from core-java-io/src/test/java/com/baeldung/file/FileOperationsManualTest.java rename to core-java-modules/core-java-io/src/test/java/com/baeldung/file/FileOperationsManualTest.java diff --git a/core-java-io/src/test/java/com/baeldung/file/FilenameFilterManualTest.java b/core-java-modules/core-java-io/src/test/java/com/baeldung/file/FilenameFilterManualTest.java similarity index 100% rename from core-java-io/src/test/java/com/baeldung/file/FilenameFilterManualTest.java rename to core-java-modules/core-java-io/src/test/java/com/baeldung/file/FilenameFilterManualTest.java diff --git a/core-java-io/src/test/java/com/baeldung/file/FilesClearDataUnitTest.java b/core-java-modules/core-java-io/src/test/java/com/baeldung/file/FilesClearDataUnitTest.java similarity index 100% rename from core-java-io/src/test/java/com/baeldung/file/FilesClearDataUnitTest.java rename to core-java-modules/core-java-io/src/test/java/com/baeldung/file/FilesClearDataUnitTest.java diff --git a/core-java-io/src/test/java/com/baeldung/file/FilesManualTest.java b/core-java-modules/core-java-io/src/test/java/com/baeldung/file/FilesManualTest.java similarity index 100% rename from core-java-io/src/test/java/com/baeldung/file/FilesManualTest.java rename to core-java-modules/core-java-io/src/test/java/com/baeldung/file/FilesManualTest.java diff --git a/core-java-io/src/test/java/com/baeldung/file/ListFilesUnitTest.java b/core-java-modules/core-java-io/src/test/java/com/baeldung/file/ListFilesUnitTest.java similarity index 100% rename from core-java-io/src/test/java/com/baeldung/file/ListFilesUnitTest.java rename to core-java-modules/core-java-io/src/test/java/com/baeldung/file/ListFilesUnitTest.java diff --git a/core-java-io/src/test/java/com/baeldung/filechannel/FileChannelUnitTest.java b/core-java-modules/core-java-io/src/test/java/com/baeldung/filechannel/FileChannelUnitTest.java similarity index 100% rename from core-java-io/src/test/java/com/baeldung/filechannel/FileChannelUnitTest.java rename to core-java-modules/core-java-io/src/test/java/com/baeldung/filechannel/FileChannelUnitTest.java diff --git a/core-java-io/src/test/java/com/baeldung/fileparser/BufferedReaderUnitTest.java b/core-java-modules/core-java-io/src/test/java/com/baeldung/fileparser/BufferedReaderUnitTest.java similarity index 100% rename from core-java-io/src/test/java/com/baeldung/fileparser/BufferedReaderUnitTest.java rename to core-java-modules/core-java-io/src/test/java/com/baeldung/fileparser/BufferedReaderUnitTest.java diff --git a/core-java-io/src/test/java/com/baeldung/fileparser/FileReaderUnitTest.java b/core-java-modules/core-java-io/src/test/java/com/baeldung/fileparser/FileReaderUnitTest.java similarity index 100% rename from core-java-io/src/test/java/com/baeldung/fileparser/FileReaderUnitTest.java rename to core-java-modules/core-java-io/src/test/java/com/baeldung/fileparser/FileReaderUnitTest.java diff --git a/core-java-io/src/test/java/com/baeldung/fileparser/FilesReadAllLinesUnitTest.java b/core-java-modules/core-java-io/src/test/java/com/baeldung/fileparser/FilesReadAllLinesUnitTest.java similarity index 100% rename from core-java-io/src/test/java/com/baeldung/fileparser/FilesReadAllLinesUnitTest.java rename to core-java-modules/core-java-io/src/test/java/com/baeldung/fileparser/FilesReadAllLinesUnitTest.java diff --git a/core-java-io/src/test/java/com/baeldung/fileparser/ScannerIntUnitTest.java b/core-java-modules/core-java-io/src/test/java/com/baeldung/fileparser/ScannerIntUnitTest.java similarity index 100% rename from core-java-io/src/test/java/com/baeldung/fileparser/ScannerIntUnitTest.java rename to core-java-modules/core-java-io/src/test/java/com/baeldung/fileparser/ScannerIntUnitTest.java diff --git a/core-java-io/src/test/java/com/baeldung/fileparser/ScannerStringUnitTest.java b/core-java-modules/core-java-io/src/test/java/com/baeldung/fileparser/ScannerStringUnitTest.java similarity index 100% rename from core-java-io/src/test/java/com/baeldung/fileparser/ScannerStringUnitTest.java rename to core-java-modules/core-java-io/src/test/java/com/baeldung/fileparser/ScannerStringUnitTest.java diff --git a/core-java-io/src/test/java/com/baeldung/filesystem/jndi/test/LookupFSJNDIIntegrationTest.java b/core-java-modules/core-java-io/src/test/java/com/baeldung/filesystem/jndi/test/LookupFSJNDIIntegrationTest.java similarity index 100% rename from core-java-io/src/test/java/com/baeldung/filesystem/jndi/test/LookupFSJNDIIntegrationTest.java rename to core-java-modules/core-java-io/src/test/java/com/baeldung/filesystem/jndi/test/LookupFSJNDIIntegrationTest.java diff --git a/core-java-io/src/test/java/com/baeldung/java/mimetype/MimeTypeUnitTest.java b/core-java-modules/core-java-io/src/test/java/com/baeldung/java/mimetype/MimeTypeUnitTest.java similarity index 100% rename from core-java-io/src/test/java/com/baeldung/java/mimetype/MimeTypeUnitTest.java rename to core-java-modules/core-java-io/src/test/java/com/baeldung/java/mimetype/MimeTypeUnitTest.java diff --git a/core-java-io/src/test/java/com/baeldung/java/nio/selector/NioEchoLiveTest.java b/core-java-modules/core-java-io/src/test/java/com/baeldung/java/nio/selector/NioEchoLiveTest.java similarity index 100% rename from core-java-io/src/test/java/com/baeldung/java/nio/selector/NioEchoLiveTest.java rename to core-java-modules/core-java-io/src/test/java/com/baeldung/java/nio/selector/NioEchoLiveTest.java diff --git a/core-java-io/src/test/java/com/baeldung/java/nio2/FileIntegrationTest.java b/core-java-modules/core-java-io/src/test/java/com/baeldung/java/nio2/FileIntegrationTest.java similarity index 100% rename from core-java-io/src/test/java/com/baeldung/java/nio2/FileIntegrationTest.java rename to core-java-modules/core-java-io/src/test/java/com/baeldung/java/nio2/FileIntegrationTest.java diff --git a/core-java-io/src/test/java/com/baeldung/java/nio2/PathManualTest.java b/core-java-modules/core-java-io/src/test/java/com/baeldung/java/nio2/PathManualTest.java similarity index 100% rename from core-java-io/src/test/java/com/baeldung/java/nio2/PathManualTest.java rename to core-java-modules/core-java-io/src/test/java/com/baeldung/java/nio2/PathManualTest.java diff --git a/core-java-io/src/test/java/com/baeldung/java/nio2/README.md b/core-java-modules/core-java-io/src/test/java/com/baeldung/java/nio2/README.md similarity index 100% rename from core-java-io/src/test/java/com/baeldung/java/nio2/README.md rename to core-java-modules/core-java-io/src/test/java/com/baeldung/java/nio2/README.md diff --git a/core-java-io/src/test/java/com/baeldung/java/nio2/async/AsyncEchoClient.java b/core-java-modules/core-java-io/src/test/java/com/baeldung/java/nio2/async/AsyncEchoClient.java similarity index 100% rename from core-java-io/src/test/java/com/baeldung/java/nio2/async/AsyncEchoClient.java rename to core-java-modules/core-java-io/src/test/java/com/baeldung/java/nio2/async/AsyncEchoClient.java diff --git a/core-java-io/src/test/java/com/baeldung/java/nio2/async/AsyncEchoIntegrationTest.java b/core-java-modules/core-java-io/src/test/java/com/baeldung/java/nio2/async/AsyncEchoIntegrationTest.java similarity index 100% rename from core-java-io/src/test/java/com/baeldung/java/nio2/async/AsyncEchoIntegrationTest.java rename to core-java-modules/core-java-io/src/test/java/com/baeldung/java/nio2/async/AsyncEchoIntegrationTest.java diff --git a/core-java-io/src/test/java/com/baeldung/java/nio2/async/AsyncEchoServer.java b/core-java-modules/core-java-io/src/test/java/com/baeldung/java/nio2/async/AsyncEchoServer.java similarity index 100% rename from core-java-io/src/test/java/com/baeldung/java/nio2/async/AsyncEchoServer.java rename to core-java-modules/core-java-io/src/test/java/com/baeldung/java/nio2/async/AsyncEchoServer.java diff --git a/core-java-io/src/test/java/com/baeldung/java/nio2/async/AsyncEchoServer2.java b/core-java-modules/core-java-io/src/test/java/com/baeldung/java/nio2/async/AsyncEchoServer2.java similarity index 100% rename from core-java-io/src/test/java/com/baeldung/java/nio2/async/AsyncEchoServer2.java rename to core-java-modules/core-java-io/src/test/java/com/baeldung/java/nio2/async/AsyncEchoServer2.java diff --git a/core-java-io/src/test/java/com/baeldung/java/nio2/async/AsyncFileIntegrationTest.java b/core-java-modules/core-java-io/src/test/java/com/baeldung/java/nio2/async/AsyncFileIntegrationTest.java similarity index 100% rename from core-java-io/src/test/java/com/baeldung/java/nio2/async/AsyncFileIntegrationTest.java rename to core-java-modules/core-java-io/src/test/java/com/baeldung/java/nio2/async/AsyncFileIntegrationTest.java diff --git a/core-java-io/src/test/java/com/baeldung/java/nio2/attributes/BasicAttribsIntegrationTest.java b/core-java-modules/core-java-io/src/test/java/com/baeldung/java/nio2/attributes/BasicAttribsIntegrationTest.java similarity index 100% rename from core-java-io/src/test/java/com/baeldung/java/nio2/attributes/BasicAttribsIntegrationTest.java rename to core-java-modules/core-java-io/src/test/java/com/baeldung/java/nio2/attributes/BasicAttribsIntegrationTest.java diff --git a/core-java-io/src/test/java/com/baeldung/java8/JavaFileSizeUnitTest.java b/core-java-modules/core-java-io/src/test/java/com/baeldung/java8/JavaFileSizeUnitTest.java similarity index 100% rename from core-java-io/src/test/java/com/baeldung/java8/JavaFileSizeUnitTest.java rename to core-java-modules/core-java-io/src/test/java/com/baeldung/java8/JavaFileSizeUnitTest.java diff --git a/core-java-io/src/test/java/com/baeldung/java8/JavaFolderSizeUnitTest.java b/core-java-modules/core-java-io/src/test/java/com/baeldung/java8/JavaFolderSizeUnitTest.java similarity index 100% rename from core-java-io/src/test/java/com/baeldung/java8/JavaFolderSizeUnitTest.java rename to core-java-modules/core-java-io/src/test/java/com/baeldung/java8/JavaFolderSizeUnitTest.java diff --git a/core-java-io/src/test/java/com/baeldung/mappedbytebuffer/MappedByteBufferUnitTest.java b/core-java-modules/core-java-io/src/test/java/com/baeldung/mappedbytebuffer/MappedByteBufferUnitTest.java similarity index 100% rename from core-java-io/src/test/java/com/baeldung/mappedbytebuffer/MappedByteBufferUnitTest.java rename to core-java-modules/core-java-io/src/test/java/com/baeldung/mappedbytebuffer/MappedByteBufferUnitTest.java diff --git a/core-java-io/src/test/java/com/baeldung/stream/FileCopyUnitTest.java b/core-java-modules/core-java-io/src/test/java/com/baeldung/stream/FileCopyUnitTest.java similarity index 100% rename from core-java-io/src/test/java/com/baeldung/stream/FileCopyUnitTest.java rename to core-java-modules/core-java-io/src/test/java/com/baeldung/stream/FileCopyUnitTest.java diff --git a/core-java-io/src/test/java/com/baeldung/stream/OutputStreamExamplesUnitTest.java b/core-java-modules/core-java-io/src/test/java/com/baeldung/stream/OutputStreamExamplesUnitTest.java similarity index 100% rename from core-java-io/src/test/java/com/baeldung/stream/OutputStreamExamplesUnitTest.java rename to core-java-modules/core-java-io/src/test/java/com/baeldung/stream/OutputStreamExamplesUnitTest.java diff --git a/core-java-io/src/test/java/com/baeldung/symlink/SymLinkExampleManualTest.java b/core-java-modules/core-java-io/src/test/java/com/baeldung/symlink/SymLinkExampleManualTest.java similarity index 100% rename from core-java-io/src/test/java/com/baeldung/symlink/SymLinkExampleManualTest.java rename to core-java-modules/core-java-io/src/test/java/com/baeldung/symlink/SymLinkExampleManualTest.java diff --git a/core-java-io/src/test/java/org/baeldung/core/exceptions/FileNotFoundExceptionUnitTest.java b/core-java-modules/core-java-io/src/test/java/org/baeldung/core/exceptions/FileNotFoundExceptionUnitTest.java similarity index 100% rename from core-java-io/src/test/java/org/baeldung/core/exceptions/FileNotFoundExceptionUnitTest.java rename to core-java-modules/core-java-io/src/test/java/org/baeldung/core/exceptions/FileNotFoundExceptionUnitTest.java diff --git a/core-java-io/src/test/java/org/baeldung/java/io/InputStreamToByteBufferUnitTest.java b/core-java-modules/core-java-io/src/test/java/org/baeldung/java/io/InputStreamToByteBufferUnitTest.java similarity index 100% rename from core-java-io/src/test/java/org/baeldung/java/io/InputStreamToByteBufferUnitTest.java rename to core-java-modules/core-java-io/src/test/java/org/baeldung/java/io/InputStreamToByteBufferUnitTest.java diff --git a/core-java-io/src/test/java/org/baeldung/java/io/JavaFilePathUnitTest.java b/core-java-modules/core-java-io/src/test/java/org/baeldung/java/io/JavaFilePathUnitTest.java similarity index 100% rename from core-java-io/src/test/java/org/baeldung/java/io/JavaFilePathUnitTest.java rename to core-java-modules/core-java-io/src/test/java/org/baeldung/java/io/JavaFilePathUnitTest.java diff --git a/core-java-io/src/test/java/org/baeldung/java/io/JavaFileUnitTest.java b/core-java-modules/core-java-io/src/test/java/org/baeldung/java/io/JavaFileUnitTest.java similarity index 100% rename from core-java-io/src/test/java/org/baeldung/java/io/JavaFileUnitTest.java rename to core-java-modules/core-java-io/src/test/java/org/baeldung/java/io/JavaFileUnitTest.java diff --git a/core-java-io/src/test/java/org/baeldung/java/io/JavaInputStreamToXUnitTest.java b/core-java-modules/core-java-io/src/test/java/org/baeldung/java/io/JavaInputStreamToXUnitTest.java similarity index 100% rename from core-java-io/src/test/java/org/baeldung/java/io/JavaInputStreamToXUnitTest.java rename to core-java-modules/core-java-io/src/test/java/org/baeldung/java/io/JavaInputStreamToXUnitTest.java diff --git a/core-java-io/src/test/java/org/baeldung/java/io/JavaReadFromFileUnitTest.java b/core-java-modules/core-java-io/src/test/java/org/baeldung/java/io/JavaReadFromFileUnitTest.java similarity index 100% rename from core-java-io/src/test/java/org/baeldung/java/io/JavaReadFromFileUnitTest.java rename to core-java-modules/core-java-io/src/test/java/org/baeldung/java/io/JavaReadFromFileUnitTest.java diff --git a/core-java-io/src/test/java/org/baeldung/java/io/JavaReaderToXUnitTest.java b/core-java-modules/core-java-io/src/test/java/org/baeldung/java/io/JavaReaderToXUnitTest.java similarity index 100% rename from core-java-io/src/test/java/org/baeldung/java/io/JavaReaderToXUnitTest.java rename to core-java-modules/core-java-io/src/test/java/org/baeldung/java/io/JavaReaderToXUnitTest.java diff --git a/core-java-io/src/test/java/org/baeldung/java/io/JavaScannerUnitTest.java b/core-java-modules/core-java-io/src/test/java/org/baeldung/java/io/JavaScannerUnitTest.java similarity index 100% rename from core-java-io/src/test/java/org/baeldung/java/io/JavaScannerUnitTest.java rename to core-java-modules/core-java-io/src/test/java/org/baeldung/java/io/JavaScannerUnitTest.java diff --git a/core-java-io/src/test/java/org/baeldung/java/io/JavaWriteToFileUnitTest.java b/core-java-modules/core-java-io/src/test/java/org/baeldung/java/io/JavaWriteToFileUnitTest.java similarity index 100% rename from core-java-io/src/test/java/org/baeldung/java/io/JavaWriteToFileUnitTest.java rename to core-java-modules/core-java-io/src/test/java/org/baeldung/java/io/JavaWriteToFileUnitTest.java diff --git a/core-java-io/src/test/java/org/baeldung/java/io/JavaXToByteArrayUnitTest.java b/core-java-modules/core-java-io/src/test/java/org/baeldung/java/io/JavaXToByteArrayUnitTest.java similarity index 100% rename from core-java-io/src/test/java/org/baeldung/java/io/JavaXToByteArrayUnitTest.java rename to core-java-modules/core-java-io/src/test/java/org/baeldung/java/io/JavaXToByteArrayUnitTest.java diff --git a/core-java-io/src/test/java/org/baeldung/java/io/JavaXToInputStreamUnitTest.java b/core-java-modules/core-java-io/src/test/java/org/baeldung/java/io/JavaXToInputStreamUnitTest.java similarity index 100% rename from core-java-io/src/test/java/org/baeldung/java/io/JavaXToInputStreamUnitTest.java rename to core-java-modules/core-java-io/src/test/java/org/baeldung/java/io/JavaXToInputStreamUnitTest.java diff --git a/core-java-io/src/test/java/org/baeldung/java/io/JavaXToReaderUnitTest.java b/core-java-modules/core-java-io/src/test/java/org/baeldung/java/io/JavaXToReaderUnitTest.java similarity index 100% rename from core-java-io/src/test/java/org/baeldung/java/io/JavaXToReaderUnitTest.java rename to core-java-modules/core-java-io/src/test/java/org/baeldung/java/io/JavaXToReaderUnitTest.java diff --git a/core-java-io/src/test/java/org/baeldung/java/io/JavaXToWriterUnitTest.java b/core-java-modules/core-java-io/src/test/java/org/baeldung/java/io/JavaXToWriterUnitTest.java similarity index 100% rename from core-java-io/src/test/java/org/baeldung/java/io/JavaXToWriterUnitTest.java rename to core-java-modules/core-java-io/src/test/java/org/baeldung/java/io/JavaXToWriterUnitTest.java diff --git a/core-java-io/src/test/resources/.gitignore b/core-java-modules/core-java-io/src/test/resources/.gitignore similarity index 100% rename from core-java-io/src/test/resources/.gitignore rename to core-java-modules/core-java-io/src/test/resources/.gitignore diff --git a/core-java-io/src/test/resources/META-INF/mime.types b/core-java-modules/core-java-io/src/test/resources/META-INF/mime.types similarity index 100% rename from core-java-io/src/test/resources/META-INF/mime.types rename to core-java-modules/core-java-io/src/test/resources/META-INF/mime.types diff --git a/core-java-io/src/test/resources/anothersample.txt b/core-java-modules/core-java-io/src/test/resources/anothersample.txt similarity index 100% rename from core-java-io/src/test/resources/anothersample.txt rename to core-java-modules/core-java-io/src/test/resources/anothersample.txt diff --git a/core-java-io/src/test/resources/book.csv b/core-java-modules/core-java-io/src/test/resources/book.csv similarity index 100% rename from core-java-io/src/test/resources/book.csv rename to core-java-modules/core-java-io/src/test/resources/book.csv diff --git a/core-java-io/src/test/resources/configuration.properties b/core-java-modules/core-java-io/src/test/resources/configuration.properties similarity index 100% rename from core-java-io/src/test/resources/configuration.properties rename to core-java-modules/core-java-io/src/test/resources/configuration.properties diff --git a/core-java-io/src/test/resources/copiedWithApacheCommons.txt b/core-java-modules/core-java-io/src/test/resources/copiedWithApacheCommons.txt similarity index 100% rename from core-java-io/src/test/resources/copiedWithApacheCommons.txt rename to core-java-modules/core-java-io/src/test/resources/copiedWithApacheCommons.txt diff --git a/core-java-io/src/test/resources/copiedWithIo.txt b/core-java-modules/core-java-io/src/test/resources/copiedWithIo.txt similarity index 100% rename from core-java-io/src/test/resources/copiedWithIo.txt rename to core-java-modules/core-java-io/src/test/resources/copiedWithIo.txt diff --git a/core-java-io/src/test/resources/copiedWithNio.txt b/core-java-modules/core-java-io/src/test/resources/copiedWithNio.txt similarity index 100% rename from core-java-io/src/test/resources/copiedWithNio.txt rename to core-java-modules/core-java-io/src/test/resources/copiedWithNio.txt diff --git a/core-java-io/src/test/resources/copyTest/dest/readme.txt b/core-java-modules/core-java-io/src/test/resources/copyTest/dest/readme.txt similarity index 100% rename from core-java-io/src/test/resources/copyTest/dest/readme.txt rename to core-java-modules/core-java-io/src/test/resources/copyTest/dest/readme.txt diff --git a/core-java-io/src/test/resources/copyTest/src/test_apache.txt b/core-java-modules/core-java-io/src/test/resources/copyTest/src/test_apache.txt similarity index 100% rename from core-java-io/src/test/resources/copyTest/src/test_apache.txt rename to core-java-modules/core-java-io/src/test/resources/copyTest/src/test_apache.txt diff --git a/core-java-io/src/test/resources/copyTest/src/test_channel.txt b/core-java-modules/core-java-io/src/test/resources/copyTest/src/test_channel.txt similarity index 100% rename from core-java-io/src/test/resources/copyTest/src/test_channel.txt rename to core-java-modules/core-java-io/src/test/resources/copyTest/src/test_channel.txt diff --git a/core-java-io/src/test/resources/copyTest/src/test_files.txt b/core-java-modules/core-java-io/src/test/resources/copyTest/src/test_files.txt similarity index 100% rename from core-java-io/src/test/resources/copyTest/src/test_files.txt rename to core-java-modules/core-java-io/src/test/resources/copyTest/src/test_files.txt diff --git a/core-java-io/src/test/resources/copyTest/src/test_stream.txt b/core-java-modules/core-java-io/src/test/resources/copyTest/src/test_stream.txt similarity index 100% rename from core-java-io/src/test/resources/copyTest/src/test_stream.txt rename to core-java-modules/core-java-io/src/test/resources/copyTest/src/test_stream.txt diff --git a/core-java-io/src/test/resources/dictionary.in b/core-java-modules/core-java-io/src/test/resources/dictionary.in similarity index 100% rename from core-java-io/src/test/resources/dictionary.in rename to core-java-modules/core-java-io/src/test/resources/dictionary.in diff --git a/core-java-io/src/test/resources/file.txt b/core-java-modules/core-java-io/src/test/resources/file.txt similarity index 100% rename from core-java-io/src/test/resources/file.txt rename to core-java-modules/core-java-io/src/test/resources/file.txt diff --git a/core-java-io/src/test/resources/fileNameFilterManualTestFolder/people.json b/core-java-modules/core-java-io/src/test/resources/fileNameFilterManualTestFolder/people.json similarity index 100% rename from core-java-io/src/test/resources/fileNameFilterManualTestFolder/people.json rename to core-java-modules/core-java-io/src/test/resources/fileNameFilterManualTestFolder/people.json diff --git a/core-java-io/src/test/resources/fileNameFilterManualTestFolder/students.json b/core-java-modules/core-java-io/src/test/resources/fileNameFilterManualTestFolder/students.json similarity index 100% rename from core-java-io/src/test/resources/fileNameFilterManualTestFolder/students.json rename to core-java-modules/core-java-io/src/test/resources/fileNameFilterManualTestFolder/students.json diff --git a/core-java-io/src/test/resources/fileNameFilterManualTestFolder/teachers.xml b/core-java-modules/core-java-io/src/test/resources/fileNameFilterManualTestFolder/teachers.xml similarity index 100% rename from core-java-io/src/test/resources/fileNameFilterManualTestFolder/teachers.xml rename to core-java-modules/core-java-io/src/test/resources/fileNameFilterManualTestFolder/teachers.xml diff --git a/core-java-io/src/test/resources/fileNameFilterManualTestFolder/workers.xml b/core-java-modules/core-java-io/src/test/resources/fileNameFilterManualTestFolder/workers.xml similarity index 100% rename from core-java-io/src/test/resources/fileNameFilterManualTestFolder/workers.xml rename to core-java-modules/core-java-io/src/test/resources/fileNameFilterManualTestFolder/workers.xml diff --git a/core-java-io/src/test/resources/fileTest.txt b/core-java-modules/core-java-io/src/test/resources/fileTest.txt similarity index 100% rename from core-java-io/src/test/resources/fileTest.txt rename to core-java-modules/core-java-io/src/test/resources/fileTest.txt diff --git a/core-java-io/src/test/resources/fileToRead.txt b/core-java-modules/core-java-io/src/test/resources/fileToRead.txt similarity index 100% rename from core-java-io/src/test/resources/fileToRead.txt rename to core-java-modules/core-java-io/src/test/resources/fileToRead.txt diff --git a/core-java-io/src/test/resources/fileToWriteTo.txt b/core-java-modules/core-java-io/src/test/resources/fileToWriteTo.txt similarity index 100% rename from core-java-io/src/test/resources/fileToWriteTo.txt rename to core-java-modules/core-java-io/src/test/resources/fileToWriteTo.txt diff --git a/core-java-io/src/test/resources/fileexample.txt b/core-java-modules/core-java-io/src/test/resources/fileexample.txt similarity index 100% rename from core-java-io/src/test/resources/fileexample.txt rename to core-java-modules/core-java-io/src/test/resources/fileexample.txt diff --git a/core-java-io/src/test/resources/frontenac-2257154_960_720.jpg b/core-java-modules/core-java-io/src/test/resources/frontenac-2257154_960_720.jpg similarity index 100% rename from core-java-io/src/test/resources/frontenac-2257154_960_720.jpg rename to core-java-modules/core-java-io/src/test/resources/frontenac-2257154_960_720.jpg diff --git a/core-java-io/src/test/resources/initialFile.txt b/core-java-modules/core-java-io/src/test/resources/initialFile.txt similarity index 100% rename from core-java-io/src/test/resources/initialFile.txt rename to core-java-modules/core-java-io/src/test/resources/initialFile.txt diff --git a/core-java-io/src/test/resources/listFilesUnitTestFolder/country.txt b/core-java-modules/core-java-io/src/test/resources/listFilesUnitTestFolder/country.txt similarity index 100% rename from core-java-io/src/test/resources/listFilesUnitTestFolder/country.txt rename to core-java-modules/core-java-io/src/test/resources/listFilesUnitTestFolder/country.txt diff --git a/core-java-io/src/test/resources/listFilesUnitTestFolder/employee.json b/core-java-modules/core-java-io/src/test/resources/listFilesUnitTestFolder/employee.json similarity index 100% rename from core-java-io/src/test/resources/listFilesUnitTestFolder/employee.json rename to core-java-modules/core-java-io/src/test/resources/listFilesUnitTestFolder/employee.json diff --git a/core-java-io/src/test/resources/listFilesUnitTestFolder/students.json b/core-java-modules/core-java-io/src/test/resources/listFilesUnitTestFolder/students.json similarity index 100% rename from core-java-io/src/test/resources/listFilesUnitTestFolder/students.json rename to core-java-modules/core-java-io/src/test/resources/listFilesUnitTestFolder/students.json diff --git a/core-java-io/src/test/resources/listFilesUnitTestFolder/test.xml b/core-java-modules/core-java-io/src/test/resources/listFilesUnitTestFolder/test.xml similarity index 100% rename from core-java-io/src/test/resources/listFilesUnitTestFolder/test.xml rename to core-java-modules/core-java-io/src/test/resources/listFilesUnitTestFolder/test.xml diff --git a/core-java-io/src/test/resources/original.txt b/core-java-modules/core-java-io/src/test/resources/original.txt similarity index 100% rename from core-java-io/src/test/resources/original.txt rename to core-java-modules/core-java-io/src/test/resources/original.txt diff --git a/core-java-io/src/test/resources/product.png b/core-java-modules/core-java-io/src/test/resources/product.png similarity index 100% rename from core-java-io/src/test/resources/product.png rename to core-java-modules/core-java-io/src/test/resources/product.png diff --git a/core-java-io/src/test/resources/sample.txt b/core-java-modules/core-java-io/src/test/resources/sample.txt similarity index 100% rename from core-java-io/src/test/resources/sample.txt rename to core-java-modules/core-java-io/src/test/resources/sample.txt diff --git a/core-java-io/src/test/resources/sampleNumberFile.txt b/core-java-modules/core-java-io/src/test/resources/sampleNumberFile.txt similarity index 100% rename from core-java-io/src/test/resources/sampleNumberFile.txt rename to core-java-modules/core-java-io/src/test/resources/sampleNumberFile.txt diff --git a/core-java-io/src/test/resources/sampleTextFile.txt b/core-java-modules/core-java-io/src/test/resources/sampleTextFile.txt similarity index 100% rename from core-java-io/src/test/resources/sampleTextFile.txt rename to core-java-modules/core-java-io/src/test/resources/sampleTextFile.txt diff --git a/core-java-io/src/test/resources/targetFile.tmp b/core-java-modules/core-java-io/src/test/resources/targetFile.tmp similarity index 100% rename from core-java-io/src/test/resources/targetFile.tmp rename to core-java-modules/core-java-io/src/test/resources/targetFile.tmp diff --git a/core-java-io/src/test/resources/targetFile.txt b/core-java-modules/core-java-io/src/test/resources/targetFile.txt similarity index 100% rename from core-java-io/src/test/resources/targetFile.txt rename to core-java-modules/core-java-io/src/test/resources/targetFile.txt diff --git a/core-java-io/src/test/resources/test.find b/core-java-modules/core-java-io/src/test/resources/test.find similarity index 100% rename from core-java-io/src/test/resources/test.find rename to core-java-modules/core-java-io/src/test/resources/test.find diff --git a/core-java-io/src/test/resources/testFolder/sample_file_1.in b/core-java-modules/core-java-io/src/test/resources/testFolder/sample_file_1.in similarity index 100% rename from core-java-io/src/test/resources/testFolder/sample_file_1.in rename to core-java-modules/core-java-io/src/test/resources/testFolder/sample_file_1.in diff --git a/core-java-io/src/test/resources/testFolder/sample_file_2.in b/core-java-modules/core-java-io/src/test/resources/testFolder/sample_file_2.in similarity index 100% rename from core-java-io/src/test/resources/testFolder/sample_file_2.in rename to core-java-modules/core-java-io/src/test/resources/testFolder/sample_file_2.in diff --git a/core-java-io/src/test/resources/test_read.in b/core-java-modules/core-java-io/src/test/resources/test_read.in similarity index 100% rename from core-java-io/src/test/resources/test_read.in rename to core-java-modules/core-java-io/src/test/resources/test_read.in diff --git a/core-java-io/src/test/resources/test_read1.in b/core-java-modules/core-java-io/src/test/resources/test_read1.in similarity index 100% rename from core-java-io/src/test/resources/test_read1.in rename to core-java-modules/core-java-io/src/test/resources/test_read1.in diff --git a/core-java-io/src/test/resources/test_read2.in b/core-java-modules/core-java-io/src/test/resources/test_read2.in similarity index 100% rename from core-java-io/src/test/resources/test_read2.in rename to core-java-modules/core-java-io/src/test/resources/test_read2.in diff --git a/core-java-io/src/test/resources/test_read3.in b/core-java-modules/core-java-io/src/test/resources/test_read3.in similarity index 100% rename from core-java-io/src/test/resources/test_read3.in rename to core-java-modules/core-java-io/src/test/resources/test_read3.in diff --git a/core-java-io/src/test/resources/test_read4.in b/core-java-modules/core-java-io/src/test/resources/test_read4.in similarity index 100% rename from core-java-io/src/test/resources/test_read4.in rename to core-java-modules/core-java-io/src/test/resources/test_read4.in diff --git a/core-java-io/src/test/resources/test_read7.in b/core-java-modules/core-java-io/src/test/resources/test_read7.in similarity index 100% rename from core-java-io/src/test/resources/test_read7.in rename to core-java-modules/core-java-io/src/test/resources/test_read7.in diff --git a/core-java-io/src/test/resources/test_read8.in b/core-java-modules/core-java-io/src/test/resources/test_read8.in similarity index 100% rename from core-java-io/src/test/resources/test_read8.in rename to core-java-modules/core-java-io/src/test/resources/test_read8.in diff --git a/core-java-io/src/test/resources/test_read_d.in b/core-java-modules/core-java-io/src/test/resources/test_read_d.in similarity index 100% rename from core-java-io/src/test/resources/test_read_d.in rename to core-java-modules/core-java-io/src/test/resources/test_read_d.in diff --git a/core-java-io/src/test/resources/test_read_multiple.in b/core-java-modules/core-java-io/src/test/resources/test_read_multiple.in similarity index 100% rename from core-java-io/src/test/resources/test_read_multiple.in rename to core-java-modules/core-java-io/src/test/resources/test_read_multiple.in diff --git a/core-java-io/src/test/resources/test_truncate.txt b/core-java-modules/core-java-io/src/test/resources/test_truncate.txt similarity index 100% rename from core-java-io/src/test/resources/test_truncate.txt rename to core-java-modules/core-java-io/src/test/resources/test_truncate.txt diff --git a/core-java-io/src/test/resources/test_write.txt b/core-java-modules/core-java-io/src/test/resources/test_write.txt similarity index 100% rename from core-java-io/src/test/resources/test_write.txt rename to core-java-modules/core-java-io/src/test/resources/test_write.txt diff --git a/core-java-io/src/test/resources/test_write_1.txt b/core-java-modules/core-java-io/src/test/resources/test_write_1.txt similarity index 100% rename from core-java-io/src/test/resources/test_write_1.txt rename to core-java-modules/core-java-io/src/test/resources/test_write_1.txt diff --git a/core-java-io/src/test/resources/test_write_2.txt b/core-java-modules/core-java-io/src/test/resources/test_write_2.txt similarity index 100% rename from core-java-io/src/test/resources/test_write_2.txt rename to core-java-modules/core-java-io/src/test/resources/test_write_2.txt diff --git a/core-java-io/src/test/resources/test_write_3.txt b/core-java-modules/core-java-io/src/test/resources/test_write_3.txt similarity index 100% rename from core-java-io/src/test/resources/test_write_3.txt rename to core-java-modules/core-java-io/src/test/resources/test_write_3.txt diff --git a/core-java-io/src/test/resources/test_write_4.txt b/core-java-modules/core-java-io/src/test/resources/test_write_4.txt similarity index 100% rename from core-java-io/src/test/resources/test_write_4.txt rename to core-java-modules/core-java-io/src/test/resources/test_write_4.txt diff --git a/core-java-io/src/test/resources/test_write_5.txt b/core-java-modules/core-java-io/src/test/resources/test_write_5.txt similarity index 100% rename from core-java-io/src/test/resources/test_write_5.txt rename to core-java-modules/core-java-io/src/test/resources/test_write_5.txt diff --git a/core-java-io/src/test/resources/test_write_using_filechannel.txt b/core-java-modules/core-java-io/src/test/resources/test_write_using_filechannel.txt similarity index 100% rename from core-java-io/src/test/resources/test_write_using_filechannel.txt rename to core-java-modules/core-java-io/src/test/resources/test_write_using_filechannel.txt diff --git a/core-java-modules/core-java-io/target_link.txt b/core-java-modules/core-java-io/target_link.txt new file mode 100644 index 0000000000..931a810b8d --- /dev/null +++ b/core-java-modules/core-java-io/target_link.txt @@ -0,0 +1,10000 @@ +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 +75 +76 +77 +78 +79 +80 +81 +82 +83 +84 +85 +86 +87 +88 +89 +90 +91 +92 +93 +94 +95 +96 +97 +98 +99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 +129 +130 +131 +132 +133 +134 +135 +136 +137 +138 +139 +140 +141 +142 +143 +144 +145 +146 +147 +148 +149 +150 +151 +152 +153 +154 +155 +156 +157 +158 +159 +160 +161 +162 +163 +164 +165 +166 +167 +168 +169 +170 +171 +172 +173 +174 +175 +176 +177 +178 +179 +180 +181 +182 +183 +184 +185 +186 +187 +188 +189 +190 +191 +192 +193 +194 +195 +196 +197 +198 +199 +200 +201 +202 +203 +204 +205 +206 +207 +208 +209 +210 +211 +212 +213 +214 +215 +216 +217 +218 +219 +220 +221 +222 +223 +224 +225 +226 +227 +228 +229 +230 +231 +232 +233 +234 +235 +236 +237 +238 +239 +240 +241 +242 +243 +244 +245 +246 +247 +248 +249 +250 +251 +252 +253 +254 +255 +256 +257 +258 +259 +260 +261 +262 +263 +264 +265 +266 +267 +268 +269 +270 +271 +272 +273 +274 +275 +276 +277 +278 +279 +280 +281 +282 +283 +284 +285 +286 +287 +288 +289 +290 +291 +292 +293 +294 +295 +296 +297 +298 +299 +300 +301 +302 +303 +304 +305 +306 +307 +308 +309 +310 +311 +312 +313 +314 +315 +316 +317 +318 +319 +320 +321 +322 +323 +324 +325 +326 +327 +328 +329 +330 +331 +332 +333 +334 +335 +336 +337 +338 +339 +340 +341 +342 +343 +344 +345 +346 +347 +348 +349 +350 +351 +352 +353 +354 +355 +356 +357 +358 +359 +360 +361 +362 +363 +364 +365 +366 +367 +368 +369 +370 +371 +372 +373 +374 +375 +376 +377 +378 +379 +380 +381 +382 +383 +384 +385 +386 +387 +388 +389 +390 +391 +392 +393 +394 +395 +396 +397 +398 +399 +400 +401 +402 +403 +404 +405 +406 +407 +408 +409 +410 +411 +412 +413 +414 +415 +416 +417 +418 +419 +420 +421 +422 +423 +424 +425 +426 +427 +428 +429 +430 +431 +432 +433 +434 +435 +436 +437 +438 +439 +440 +441 +442 +443 +444 +445 +446 +447 +448 +449 +450 +451 +452 +453 +454 +455 +456 +457 +458 +459 +460 +461 +462 +463 +464 +465 +466 +467 +468 +469 +470 +471 +472 +473 +474 +475 +476 +477 +478 +479 +480 +481 +482 +483 +484 +485 +486 +487 +488 +489 +490 +491 +492 +493 +494 +495 +496 +497 +498 +499 +500 +501 +502 +503 +504 +505 +506 +507 +508 +509 +510 +511 +512 +513 +514 +515 +516 +517 +518 +519 +520 +521 +522 +523 +524 +525 +526 +527 +528 +529 +530 +531 +532 +533 +534 +535 +536 +537 +538 +539 +540 +541 +542 +543 +544 +545 +546 +547 +548 +549 +550 +551 +552 +553 +554 +555 +556 +557 +558 +559 +560 +561 +562 +563 +564 +565 +566 +567 +568 +569 +570 +571 +572 +573 +574 +575 +576 +577 +578 +579 +580 +581 +582 +583 +584 +585 +586 +587 +588 +589 +590 +591 +592 +593 +594 +595 +596 +597 +598 +599 +600 +601 +602 +603 +604 +605 +606 +607 +608 +609 +610 +611 +612 +613 +614 +615 +616 +617 +618 +619 +620 +621 +622 +623 +624 +625 +626 +627 +628 +629 +630 +631 +632 +633 +634 +635 +636 +637 +638 +639 +640 +641 +642 +643 +644 +645 +646 +647 +648 +649 +650 +651 +652 +653 +654 +655 +656 +657 +658 +659 +660 +661 +662 +663 +664 +665 +666 +667 +668 +669 +670 +671 +672 +673 +674 +675 +676 +677 +678 +679 +680 +681 +682 +683 +684 +685 +686 +687 +688 +689 +690 +691 +692 +693 +694 +695 +696 +697 +698 +699 +700 +701 +702 +703 +704 +705 +706 +707 +708 +709 +710 +711 +712 +713 +714 +715 +716 +717 +718 +719 +720 +721 +722 +723 +724 +725 +726 +727 +728 +729 +730 +731 +732 +733 +734 +735 +736 +737 +738 +739 +740 +741 +742 +743 +744 +745 +746 +747 +748 +749 +750 +751 +752 +753 +754 +755 +756 +757 +758 +759 +760 +761 +762 +763 +764 +765 +766 +767 +768 +769 +770 +771 +772 +773 +774 +775 +776 +777 +778 +779 +780 +781 +782 +783 +784 +785 +786 +787 +788 +789 +790 +791 +792 +793 +794 +795 +796 +797 +798 +799 +800 +801 +802 +803 +804 +805 +806 +807 +808 +809 +810 +811 +812 +813 +814 +815 +816 +817 +818 +819 +820 +821 +822 +823 +824 +825 +826 +827 +828 +829 +830 +831 +832 +833 +834 +835 +836 +837 +838 +839 +840 +841 +842 +843 +844 +845 +846 +847 +848 +849 +850 +851 +852 +853 +854 +855 +856 +857 +858 +859 +860 +861 +862 +863 +864 +865 +866 +867 +868 +869 +870 +871 +872 +873 +874 +875 +876 +877 +878 +879 +880 +881 +882 +883 +884 +885 +886 +887 +888 +889 +890 +891 +892 +893 +894 +895 +896 +897 +898 +899 +900 +901 +902 +903 +904 +905 +906 +907 +908 +909 +910 +911 +912 +913 +914 +915 +916 +917 +918 +919 +920 +921 +922 +923 +924 +925 +926 +927 +928 +929 +930 +931 +932 +933 +934 +935 +936 +937 +938 +939 +940 +941 +942 +943 +944 +945 +946 +947 +948 +949 +950 +951 +952 +953 +954 +955 +956 +957 +958 +959 +960 +961 +962 +963 +964 +965 +966 +967 +968 +969 +970 +971 +972 +973 +974 +975 +976 +977 +978 +979 +980 +981 +982 +983 +984 +985 +986 +987 +988 +989 +990 +991 +992 +993 +994 +995 +996 +997 +998 +999 +1000 +1001 +1002 +1003 +1004 +1005 +1006 +1007 +1008 +1009 +1010 +1011 +1012 +1013 +1014 +1015 +1016 +1017 +1018 +1019 +1020 +1021 +1022 +1023 +1024 +1025 +1026 +1027 +1028 +1029 +1030 +1031 +1032 +1033 +1034 +1035 +1036 +1037 +1038 +1039 +1040 +1041 +1042 +1043 +1044 +1045 +1046 +1047 +1048 +1049 +1050 +1051 +1052 +1053 +1054 +1055 +1056 +1057 +1058 +1059 +1060 +1061 +1062 +1063 +1064 +1065 +1066 +1067 +1068 +1069 +1070 +1071 +1072 +1073 +1074 +1075 +1076 +1077 +1078 +1079 +1080 +1081 +1082 +1083 +1084 +1085 +1086 +1087 +1088 +1089 +1090 +1091 +1092 +1093 +1094 +1095 +1096 +1097 +1098 +1099 +1100 +1101 +1102 +1103 +1104 +1105 +1106 +1107 +1108 +1109 +1110 +1111 +1112 +1113 +1114 +1115 +1116 +1117 +1118 +1119 +1120 +1121 +1122 +1123 +1124 +1125 +1126 +1127 +1128 +1129 +1130 +1131 +1132 +1133 +1134 +1135 +1136 +1137 +1138 +1139 +1140 +1141 +1142 +1143 +1144 +1145 +1146 +1147 +1148 +1149 +1150 +1151 +1152 +1153 +1154 +1155 +1156 +1157 +1158 +1159 +1160 +1161 +1162 +1163 +1164 +1165 +1166 +1167 +1168 +1169 +1170 +1171 +1172 +1173 +1174 +1175 +1176 +1177 +1178 +1179 +1180 +1181 +1182 +1183 +1184 +1185 +1186 +1187 +1188 +1189 +1190 +1191 +1192 +1193 +1194 +1195 +1196 +1197 +1198 +1199 +1200 +1201 +1202 +1203 +1204 +1205 +1206 +1207 +1208 +1209 +1210 +1211 +1212 +1213 +1214 +1215 +1216 +1217 +1218 +1219 +1220 +1221 +1222 +1223 +1224 +1225 +1226 +1227 +1228 +1229 +1230 +1231 +1232 +1233 +1234 +1235 +1236 +1237 +1238 +1239 +1240 +1241 +1242 +1243 +1244 +1245 +1246 +1247 +1248 +1249 +1250 +1251 +1252 +1253 +1254 +1255 +1256 +1257 +1258 +1259 +1260 +1261 +1262 +1263 +1264 +1265 +1266 +1267 +1268 +1269 +1270 +1271 +1272 +1273 +1274 +1275 +1276 +1277 +1278 +1279 +1280 +1281 +1282 +1283 +1284 +1285 +1286 +1287 +1288 +1289 +1290 +1291 +1292 +1293 +1294 +1295 +1296 +1297 +1298 +1299 +1300 +1301 +1302 +1303 +1304 +1305 +1306 +1307 +1308 +1309 +1310 +1311 +1312 +1313 +1314 +1315 +1316 +1317 +1318 +1319 +1320 +1321 +1322 +1323 +1324 +1325 +1326 +1327 +1328 +1329 +1330 +1331 +1332 +1333 +1334 +1335 +1336 +1337 +1338 +1339 +1340 +1341 +1342 +1343 +1344 +1345 +1346 +1347 +1348 +1349 +1350 +1351 +1352 +1353 +1354 +1355 +1356 +1357 +1358 +1359 +1360 +1361 +1362 +1363 +1364 +1365 +1366 +1367 +1368 +1369 +1370 +1371 +1372 +1373 +1374 +1375 +1376 +1377 +1378 +1379 +1380 +1381 +1382 +1383 +1384 +1385 +1386 +1387 +1388 +1389 +1390 +1391 +1392 +1393 +1394 +1395 +1396 +1397 +1398 +1399 +1400 +1401 +1402 +1403 +1404 +1405 +1406 +1407 +1408 +1409 +1410 +1411 +1412 +1413 +1414 +1415 +1416 +1417 +1418 +1419 +1420 +1421 +1422 +1423 +1424 +1425 +1426 +1427 +1428 +1429 +1430 +1431 +1432 +1433 +1434 +1435 +1436 +1437 +1438 +1439 +1440 +1441 +1442 +1443 +1444 +1445 +1446 +1447 +1448 +1449 +1450 +1451 +1452 +1453 +1454 +1455 +1456 +1457 +1458 +1459 +1460 +1461 +1462 +1463 +1464 +1465 +1466 +1467 +1468 +1469 +1470 +1471 +1472 +1473 +1474 +1475 +1476 +1477 +1478 +1479 +1480 +1481 +1482 +1483 +1484 +1485 +1486 +1487 +1488 +1489 +1490 +1491 +1492 +1493 +1494 +1495 +1496 +1497 +1498 +1499 +1500 +1501 +1502 +1503 +1504 +1505 +1506 +1507 +1508 +1509 +1510 +1511 +1512 +1513 +1514 +1515 +1516 +1517 +1518 +1519 +1520 +1521 +1522 +1523 +1524 +1525 +1526 +1527 +1528 +1529 +1530 +1531 +1532 +1533 +1534 +1535 +1536 +1537 +1538 +1539 +1540 +1541 +1542 +1543 +1544 +1545 +1546 +1547 +1548 +1549 +1550 +1551 +1552 +1553 +1554 +1555 +1556 +1557 +1558 +1559 +1560 +1561 +1562 +1563 +1564 +1565 +1566 +1567 +1568 +1569 +1570 +1571 +1572 +1573 +1574 +1575 +1576 +1577 +1578 +1579 +1580 +1581 +1582 +1583 +1584 +1585 +1586 +1587 +1588 +1589 +1590 +1591 +1592 +1593 +1594 +1595 +1596 +1597 +1598 +1599 +1600 +1601 +1602 +1603 +1604 +1605 +1606 +1607 +1608 +1609 +1610 +1611 +1612 +1613 +1614 +1615 +1616 +1617 +1618 +1619 +1620 +1621 +1622 +1623 +1624 +1625 +1626 +1627 +1628 +1629 +1630 +1631 +1632 +1633 +1634 +1635 +1636 +1637 +1638 +1639 +1640 +1641 +1642 +1643 +1644 +1645 +1646 +1647 +1648 +1649 +1650 +1651 +1652 +1653 +1654 +1655 +1656 +1657 +1658 +1659 +1660 +1661 +1662 +1663 +1664 +1665 +1666 +1667 +1668 +1669 +1670 +1671 +1672 +1673 +1674 +1675 +1676 +1677 +1678 +1679 +1680 +1681 +1682 +1683 +1684 +1685 +1686 +1687 +1688 +1689 +1690 +1691 +1692 +1693 +1694 +1695 +1696 +1697 +1698 +1699 +1700 +1701 +1702 +1703 +1704 +1705 +1706 +1707 +1708 +1709 +1710 +1711 +1712 +1713 +1714 +1715 +1716 +1717 +1718 +1719 +1720 +1721 +1722 +1723 +1724 +1725 +1726 +1727 +1728 +1729 +1730 +1731 +1732 +1733 +1734 +1735 +1736 +1737 +1738 +1739 +1740 +1741 +1742 +1743 +1744 +1745 +1746 +1747 +1748 +1749 +1750 +1751 +1752 +1753 +1754 +1755 +1756 +1757 +1758 +1759 +1760 +1761 +1762 +1763 +1764 +1765 +1766 +1767 +1768 +1769 +1770 +1771 +1772 +1773 +1774 +1775 +1776 +1777 +1778 +1779 +1780 +1781 +1782 +1783 +1784 +1785 +1786 +1787 +1788 +1789 +1790 +1791 +1792 +1793 +1794 +1795 +1796 +1797 +1798 +1799 +1800 +1801 +1802 +1803 +1804 +1805 +1806 +1807 +1808 +1809 +1810 +1811 +1812 +1813 +1814 +1815 +1816 +1817 +1818 +1819 +1820 +1821 +1822 +1823 +1824 +1825 +1826 +1827 +1828 +1829 +1830 +1831 +1832 +1833 +1834 +1835 +1836 +1837 +1838 +1839 +1840 +1841 +1842 +1843 +1844 +1845 +1846 +1847 +1848 +1849 +1850 +1851 +1852 +1853 +1854 +1855 +1856 +1857 +1858 +1859 +1860 +1861 +1862 +1863 +1864 +1865 +1866 +1867 +1868 +1869 +1870 +1871 +1872 +1873 +1874 +1875 +1876 +1877 +1878 +1879 +1880 +1881 +1882 +1883 +1884 +1885 +1886 +1887 +1888 +1889 +1890 +1891 +1892 +1893 +1894 +1895 +1896 +1897 +1898 +1899 +1900 +1901 +1902 +1903 +1904 +1905 +1906 +1907 +1908 +1909 +1910 +1911 +1912 +1913 +1914 +1915 +1916 +1917 +1918 +1919 +1920 +1921 +1922 +1923 +1924 +1925 +1926 +1927 +1928 +1929 +1930 +1931 +1932 +1933 +1934 +1935 +1936 +1937 +1938 +1939 +1940 +1941 +1942 +1943 +1944 +1945 +1946 +1947 +1948 +1949 +1950 +1951 +1952 +1953 +1954 +1955 +1956 +1957 +1958 +1959 +1960 +1961 +1962 +1963 +1964 +1965 +1966 +1967 +1968 +1969 +1970 +1971 +1972 +1973 +1974 +1975 +1976 +1977 +1978 +1979 +1980 +1981 +1982 +1983 +1984 +1985 +1986 +1987 +1988 +1989 +1990 +1991 +1992 +1993 +1994 +1995 +1996 +1997 +1998 +1999 +2000 +2001 +2002 +2003 +2004 +2005 +2006 +2007 +2008 +2009 +2010 +2011 +2012 +2013 +2014 +2015 +2016 +2017 +2018 +2019 +2020 +2021 +2022 +2023 +2024 +2025 +2026 +2027 +2028 +2029 +2030 +2031 +2032 +2033 +2034 +2035 +2036 +2037 +2038 +2039 +2040 +2041 +2042 +2043 +2044 +2045 +2046 +2047 +2048 +2049 +2050 +2051 +2052 +2053 +2054 +2055 +2056 +2057 +2058 +2059 +2060 +2061 +2062 +2063 +2064 +2065 +2066 +2067 +2068 +2069 +2070 +2071 +2072 +2073 +2074 +2075 +2076 +2077 +2078 +2079 +2080 +2081 +2082 +2083 +2084 +2085 +2086 +2087 +2088 +2089 +2090 +2091 +2092 +2093 +2094 +2095 +2096 +2097 +2098 +2099 +2100 +2101 +2102 +2103 +2104 +2105 +2106 +2107 +2108 +2109 +2110 +2111 +2112 +2113 +2114 +2115 +2116 +2117 +2118 +2119 +2120 +2121 +2122 +2123 +2124 +2125 +2126 +2127 +2128 +2129 +2130 +2131 +2132 +2133 +2134 +2135 +2136 +2137 +2138 +2139 +2140 +2141 +2142 +2143 +2144 +2145 +2146 +2147 +2148 +2149 +2150 +2151 +2152 +2153 +2154 +2155 +2156 +2157 +2158 +2159 +2160 +2161 +2162 +2163 +2164 +2165 +2166 +2167 +2168 +2169 +2170 +2171 +2172 +2173 +2174 +2175 +2176 +2177 +2178 +2179 +2180 +2181 +2182 +2183 +2184 +2185 +2186 +2187 +2188 +2189 +2190 +2191 +2192 +2193 +2194 +2195 +2196 +2197 +2198 +2199 +2200 +2201 +2202 +2203 +2204 +2205 +2206 +2207 +2208 +2209 +2210 +2211 +2212 +2213 +2214 +2215 +2216 +2217 +2218 +2219 +2220 +2221 +2222 +2223 +2224 +2225 +2226 +2227 +2228 +2229 +2230 +2231 +2232 +2233 +2234 +2235 +2236 +2237 +2238 +2239 +2240 +2241 +2242 +2243 +2244 +2245 +2246 +2247 +2248 +2249 +2250 +2251 +2252 +2253 +2254 +2255 +2256 +2257 +2258 +2259 +2260 +2261 +2262 +2263 +2264 +2265 +2266 +2267 +2268 +2269 +2270 +2271 +2272 +2273 +2274 +2275 +2276 +2277 +2278 +2279 +2280 +2281 +2282 +2283 +2284 +2285 +2286 +2287 +2288 +2289 +2290 +2291 +2292 +2293 +2294 +2295 +2296 +2297 +2298 +2299 +2300 +2301 +2302 +2303 +2304 +2305 +2306 +2307 +2308 +2309 +2310 +2311 +2312 +2313 +2314 +2315 +2316 +2317 +2318 +2319 +2320 +2321 +2322 +2323 +2324 +2325 +2326 +2327 +2328 +2329 +2330 +2331 +2332 +2333 +2334 +2335 +2336 +2337 +2338 +2339 +2340 +2341 +2342 +2343 +2344 +2345 +2346 +2347 +2348 +2349 +2350 +2351 +2352 +2353 +2354 +2355 +2356 +2357 +2358 +2359 +2360 +2361 +2362 +2363 +2364 +2365 +2366 +2367 +2368 +2369 +2370 +2371 +2372 +2373 +2374 +2375 +2376 +2377 +2378 +2379 +2380 +2381 +2382 +2383 +2384 +2385 +2386 +2387 +2388 +2389 +2390 +2391 +2392 +2393 +2394 +2395 +2396 +2397 +2398 +2399 +2400 +2401 +2402 +2403 +2404 +2405 +2406 +2407 +2408 +2409 +2410 +2411 +2412 +2413 +2414 +2415 +2416 +2417 +2418 +2419 +2420 +2421 +2422 +2423 +2424 +2425 +2426 +2427 +2428 +2429 +2430 +2431 +2432 +2433 +2434 +2435 +2436 +2437 +2438 +2439 +2440 +2441 +2442 +2443 +2444 +2445 +2446 +2447 +2448 +2449 +2450 +2451 +2452 +2453 +2454 +2455 +2456 +2457 +2458 +2459 +2460 +2461 +2462 +2463 +2464 +2465 +2466 +2467 +2468 +2469 +2470 +2471 +2472 +2473 +2474 +2475 +2476 +2477 +2478 +2479 +2480 +2481 +2482 +2483 +2484 +2485 +2486 +2487 +2488 +2489 +2490 +2491 +2492 +2493 +2494 +2495 +2496 +2497 +2498 +2499 +2500 +2501 +2502 +2503 +2504 +2505 +2506 +2507 +2508 +2509 +2510 +2511 +2512 +2513 +2514 +2515 +2516 +2517 +2518 +2519 +2520 +2521 +2522 +2523 +2524 +2525 +2526 +2527 +2528 +2529 +2530 +2531 +2532 +2533 +2534 +2535 +2536 +2537 +2538 +2539 +2540 +2541 +2542 +2543 +2544 +2545 +2546 +2547 +2548 +2549 +2550 +2551 +2552 +2553 +2554 +2555 +2556 +2557 +2558 +2559 +2560 +2561 +2562 +2563 +2564 +2565 +2566 +2567 +2568 +2569 +2570 +2571 +2572 +2573 +2574 +2575 +2576 +2577 +2578 +2579 +2580 +2581 +2582 +2583 +2584 +2585 +2586 +2587 +2588 +2589 +2590 +2591 +2592 +2593 +2594 +2595 +2596 +2597 +2598 +2599 +2600 +2601 +2602 +2603 +2604 +2605 +2606 +2607 +2608 +2609 +2610 +2611 +2612 +2613 +2614 +2615 +2616 +2617 +2618 +2619 +2620 +2621 +2622 +2623 +2624 +2625 +2626 +2627 +2628 +2629 +2630 +2631 +2632 +2633 +2634 +2635 +2636 +2637 +2638 +2639 +2640 +2641 +2642 +2643 +2644 +2645 +2646 +2647 +2648 +2649 +2650 +2651 +2652 +2653 +2654 +2655 +2656 +2657 +2658 +2659 +2660 +2661 +2662 +2663 +2664 +2665 +2666 +2667 +2668 +2669 +2670 +2671 +2672 +2673 +2674 +2675 +2676 +2677 +2678 +2679 +2680 +2681 +2682 +2683 +2684 +2685 +2686 +2687 +2688 +2689 +2690 +2691 +2692 +2693 +2694 +2695 +2696 +2697 +2698 +2699 +2700 +2701 +2702 +2703 +2704 +2705 +2706 +2707 +2708 +2709 +2710 +2711 +2712 +2713 +2714 +2715 +2716 +2717 +2718 +2719 +2720 +2721 +2722 +2723 +2724 +2725 +2726 +2727 +2728 +2729 +2730 +2731 +2732 +2733 +2734 +2735 +2736 +2737 +2738 +2739 +2740 +2741 +2742 +2743 +2744 +2745 +2746 +2747 +2748 +2749 +2750 +2751 +2752 +2753 +2754 +2755 +2756 +2757 +2758 +2759 +2760 +2761 +2762 +2763 +2764 +2765 +2766 +2767 +2768 +2769 +2770 +2771 +2772 +2773 +2774 +2775 +2776 +2777 +2778 +2779 +2780 +2781 +2782 +2783 +2784 +2785 +2786 +2787 +2788 +2789 +2790 +2791 +2792 +2793 +2794 +2795 +2796 +2797 +2798 +2799 +2800 +2801 +2802 +2803 +2804 +2805 +2806 +2807 +2808 +2809 +2810 +2811 +2812 +2813 +2814 +2815 +2816 +2817 +2818 +2819 +2820 +2821 +2822 +2823 +2824 +2825 +2826 +2827 +2828 +2829 +2830 +2831 +2832 +2833 +2834 +2835 +2836 +2837 +2838 +2839 +2840 +2841 +2842 +2843 +2844 +2845 +2846 +2847 +2848 +2849 +2850 +2851 +2852 +2853 +2854 +2855 +2856 +2857 +2858 +2859 +2860 +2861 +2862 +2863 +2864 +2865 +2866 +2867 +2868 +2869 +2870 +2871 +2872 +2873 +2874 +2875 +2876 +2877 +2878 +2879 +2880 +2881 +2882 +2883 +2884 +2885 +2886 +2887 +2888 +2889 +2890 +2891 +2892 +2893 +2894 +2895 +2896 +2897 +2898 +2899 +2900 +2901 +2902 +2903 +2904 +2905 +2906 +2907 +2908 +2909 +2910 +2911 +2912 +2913 +2914 +2915 +2916 +2917 +2918 +2919 +2920 +2921 +2922 +2923 +2924 +2925 +2926 +2927 +2928 +2929 +2930 +2931 +2932 +2933 +2934 +2935 +2936 +2937 +2938 +2939 +2940 +2941 +2942 +2943 +2944 +2945 +2946 +2947 +2948 +2949 +2950 +2951 +2952 +2953 +2954 +2955 +2956 +2957 +2958 +2959 +2960 +2961 +2962 +2963 +2964 +2965 +2966 +2967 +2968 +2969 +2970 +2971 +2972 +2973 +2974 +2975 +2976 +2977 +2978 +2979 +2980 +2981 +2982 +2983 +2984 +2985 +2986 +2987 +2988 +2989 +2990 +2991 +2992 +2993 +2994 +2995 +2996 +2997 +2998 +2999 +3000 +3001 +3002 +3003 +3004 +3005 +3006 +3007 +3008 +3009 +3010 +3011 +3012 +3013 +3014 +3015 +3016 +3017 +3018 +3019 +3020 +3021 +3022 +3023 +3024 +3025 +3026 +3027 +3028 +3029 +3030 +3031 +3032 +3033 +3034 +3035 +3036 +3037 +3038 +3039 +3040 +3041 +3042 +3043 +3044 +3045 +3046 +3047 +3048 +3049 +3050 +3051 +3052 +3053 +3054 +3055 +3056 +3057 +3058 +3059 +3060 +3061 +3062 +3063 +3064 +3065 +3066 +3067 +3068 +3069 +3070 +3071 +3072 +3073 +3074 +3075 +3076 +3077 +3078 +3079 +3080 +3081 +3082 +3083 +3084 +3085 +3086 +3087 +3088 +3089 +3090 +3091 +3092 +3093 +3094 +3095 +3096 +3097 +3098 +3099 +3100 +3101 +3102 +3103 +3104 +3105 +3106 +3107 +3108 +3109 +3110 +3111 +3112 +3113 +3114 +3115 +3116 +3117 +3118 +3119 +3120 +3121 +3122 +3123 +3124 +3125 +3126 +3127 +3128 +3129 +3130 +3131 +3132 +3133 +3134 +3135 +3136 +3137 +3138 +3139 +3140 +3141 +3142 +3143 +3144 +3145 +3146 +3147 +3148 +3149 +3150 +3151 +3152 +3153 +3154 +3155 +3156 +3157 +3158 +3159 +3160 +3161 +3162 +3163 +3164 +3165 +3166 +3167 +3168 +3169 +3170 +3171 +3172 +3173 +3174 +3175 +3176 +3177 +3178 +3179 +3180 +3181 +3182 +3183 +3184 +3185 +3186 +3187 +3188 +3189 +3190 +3191 +3192 +3193 +3194 +3195 +3196 +3197 +3198 +3199 +3200 +3201 +3202 +3203 +3204 +3205 +3206 +3207 +3208 +3209 +3210 +3211 +3212 +3213 +3214 +3215 +3216 +3217 +3218 +3219 +3220 +3221 +3222 +3223 +3224 +3225 +3226 +3227 +3228 +3229 +3230 +3231 +3232 +3233 +3234 +3235 +3236 +3237 +3238 +3239 +3240 +3241 +3242 +3243 +3244 +3245 +3246 +3247 +3248 +3249 +3250 +3251 +3252 +3253 +3254 +3255 +3256 +3257 +3258 +3259 +3260 +3261 +3262 +3263 +3264 +3265 +3266 +3267 +3268 +3269 +3270 +3271 +3272 +3273 +3274 +3275 +3276 +3277 +3278 +3279 +3280 +3281 +3282 +3283 +3284 +3285 +3286 +3287 +3288 +3289 +3290 +3291 +3292 +3293 +3294 +3295 +3296 +3297 +3298 +3299 +3300 +3301 +3302 +3303 +3304 +3305 +3306 +3307 +3308 +3309 +3310 +3311 +3312 +3313 +3314 +3315 +3316 +3317 +3318 +3319 +3320 +3321 +3322 +3323 +3324 +3325 +3326 +3327 +3328 +3329 +3330 +3331 +3332 +3333 +3334 +3335 +3336 +3337 +3338 +3339 +3340 +3341 +3342 +3343 +3344 +3345 +3346 +3347 +3348 +3349 +3350 +3351 +3352 +3353 +3354 +3355 +3356 +3357 +3358 +3359 +3360 +3361 +3362 +3363 +3364 +3365 +3366 +3367 +3368 +3369 +3370 +3371 +3372 +3373 +3374 +3375 +3376 +3377 +3378 +3379 +3380 +3381 +3382 +3383 +3384 +3385 +3386 +3387 +3388 +3389 +3390 +3391 +3392 +3393 +3394 +3395 +3396 +3397 +3398 +3399 +3400 +3401 +3402 +3403 +3404 +3405 +3406 +3407 +3408 +3409 +3410 +3411 +3412 +3413 +3414 +3415 +3416 +3417 +3418 +3419 +3420 +3421 +3422 +3423 +3424 +3425 +3426 +3427 +3428 +3429 +3430 +3431 +3432 +3433 +3434 +3435 +3436 +3437 +3438 +3439 +3440 +3441 +3442 +3443 +3444 +3445 +3446 +3447 +3448 +3449 +3450 +3451 +3452 +3453 +3454 +3455 +3456 +3457 +3458 +3459 +3460 +3461 +3462 +3463 +3464 +3465 +3466 +3467 +3468 +3469 +3470 +3471 +3472 +3473 +3474 +3475 +3476 +3477 +3478 +3479 +3480 +3481 +3482 +3483 +3484 +3485 +3486 +3487 +3488 +3489 +3490 +3491 +3492 +3493 +3494 +3495 +3496 +3497 +3498 +3499 +3500 +3501 +3502 +3503 +3504 +3505 +3506 +3507 +3508 +3509 +3510 +3511 +3512 +3513 +3514 +3515 +3516 +3517 +3518 +3519 +3520 +3521 +3522 +3523 +3524 +3525 +3526 +3527 +3528 +3529 +3530 +3531 +3532 +3533 +3534 +3535 +3536 +3537 +3538 +3539 +3540 +3541 +3542 +3543 +3544 +3545 +3546 +3547 +3548 +3549 +3550 +3551 +3552 +3553 +3554 +3555 +3556 +3557 +3558 +3559 +3560 +3561 +3562 +3563 +3564 +3565 +3566 +3567 +3568 +3569 +3570 +3571 +3572 +3573 +3574 +3575 +3576 +3577 +3578 +3579 +3580 +3581 +3582 +3583 +3584 +3585 +3586 +3587 +3588 +3589 +3590 +3591 +3592 +3593 +3594 +3595 +3596 +3597 +3598 +3599 +3600 +3601 +3602 +3603 +3604 +3605 +3606 +3607 +3608 +3609 +3610 +3611 +3612 +3613 +3614 +3615 +3616 +3617 +3618 +3619 +3620 +3621 +3622 +3623 +3624 +3625 +3626 +3627 +3628 +3629 +3630 +3631 +3632 +3633 +3634 +3635 +3636 +3637 +3638 +3639 +3640 +3641 +3642 +3643 +3644 +3645 +3646 +3647 +3648 +3649 +3650 +3651 +3652 +3653 +3654 +3655 +3656 +3657 +3658 +3659 +3660 +3661 +3662 +3663 +3664 +3665 +3666 +3667 +3668 +3669 +3670 +3671 +3672 +3673 +3674 +3675 +3676 +3677 +3678 +3679 +3680 +3681 +3682 +3683 +3684 +3685 +3686 +3687 +3688 +3689 +3690 +3691 +3692 +3693 +3694 +3695 +3696 +3697 +3698 +3699 +3700 +3701 +3702 +3703 +3704 +3705 +3706 +3707 +3708 +3709 +3710 +3711 +3712 +3713 +3714 +3715 +3716 +3717 +3718 +3719 +3720 +3721 +3722 +3723 +3724 +3725 +3726 +3727 +3728 +3729 +3730 +3731 +3732 +3733 +3734 +3735 +3736 +3737 +3738 +3739 +3740 +3741 +3742 +3743 +3744 +3745 +3746 +3747 +3748 +3749 +3750 +3751 +3752 +3753 +3754 +3755 +3756 +3757 +3758 +3759 +3760 +3761 +3762 +3763 +3764 +3765 +3766 +3767 +3768 +3769 +3770 +3771 +3772 +3773 +3774 +3775 +3776 +3777 +3778 +3779 +3780 +3781 +3782 +3783 +3784 +3785 +3786 +3787 +3788 +3789 +3790 +3791 +3792 +3793 +3794 +3795 +3796 +3797 +3798 +3799 +3800 +3801 +3802 +3803 +3804 +3805 +3806 +3807 +3808 +3809 +3810 +3811 +3812 +3813 +3814 +3815 +3816 +3817 +3818 +3819 +3820 +3821 +3822 +3823 +3824 +3825 +3826 +3827 +3828 +3829 +3830 +3831 +3832 +3833 +3834 +3835 +3836 +3837 +3838 +3839 +3840 +3841 +3842 +3843 +3844 +3845 +3846 +3847 +3848 +3849 +3850 +3851 +3852 +3853 +3854 +3855 +3856 +3857 +3858 +3859 +3860 +3861 +3862 +3863 +3864 +3865 +3866 +3867 +3868 +3869 +3870 +3871 +3872 +3873 +3874 +3875 +3876 +3877 +3878 +3879 +3880 +3881 +3882 +3883 +3884 +3885 +3886 +3887 +3888 +3889 +3890 +3891 +3892 +3893 +3894 +3895 +3896 +3897 +3898 +3899 +3900 +3901 +3902 +3903 +3904 +3905 +3906 +3907 +3908 +3909 +3910 +3911 +3912 +3913 +3914 +3915 +3916 +3917 +3918 +3919 +3920 +3921 +3922 +3923 +3924 +3925 +3926 +3927 +3928 +3929 +3930 +3931 +3932 +3933 +3934 +3935 +3936 +3937 +3938 +3939 +3940 +3941 +3942 +3943 +3944 +3945 +3946 +3947 +3948 +3949 +3950 +3951 +3952 +3953 +3954 +3955 +3956 +3957 +3958 +3959 +3960 +3961 +3962 +3963 +3964 +3965 +3966 +3967 +3968 +3969 +3970 +3971 +3972 +3973 +3974 +3975 +3976 +3977 +3978 +3979 +3980 +3981 +3982 +3983 +3984 +3985 +3986 +3987 +3988 +3989 +3990 +3991 +3992 +3993 +3994 +3995 +3996 +3997 +3998 +3999 +4000 +4001 +4002 +4003 +4004 +4005 +4006 +4007 +4008 +4009 +4010 +4011 +4012 +4013 +4014 +4015 +4016 +4017 +4018 +4019 +4020 +4021 +4022 +4023 +4024 +4025 +4026 +4027 +4028 +4029 +4030 +4031 +4032 +4033 +4034 +4035 +4036 +4037 +4038 +4039 +4040 +4041 +4042 +4043 +4044 +4045 +4046 +4047 +4048 +4049 +4050 +4051 +4052 +4053 +4054 +4055 +4056 +4057 +4058 +4059 +4060 +4061 +4062 +4063 +4064 +4065 +4066 +4067 +4068 +4069 +4070 +4071 +4072 +4073 +4074 +4075 +4076 +4077 +4078 +4079 +4080 +4081 +4082 +4083 +4084 +4085 +4086 +4087 +4088 +4089 +4090 +4091 +4092 +4093 +4094 +4095 +4096 +4097 +4098 +4099 +4100 +4101 +4102 +4103 +4104 +4105 +4106 +4107 +4108 +4109 +4110 +4111 +4112 +4113 +4114 +4115 +4116 +4117 +4118 +4119 +4120 +4121 +4122 +4123 +4124 +4125 +4126 +4127 +4128 +4129 +4130 +4131 +4132 +4133 +4134 +4135 +4136 +4137 +4138 +4139 +4140 +4141 +4142 +4143 +4144 +4145 +4146 +4147 +4148 +4149 +4150 +4151 +4152 +4153 +4154 +4155 +4156 +4157 +4158 +4159 +4160 +4161 +4162 +4163 +4164 +4165 +4166 +4167 +4168 +4169 +4170 +4171 +4172 +4173 +4174 +4175 +4176 +4177 +4178 +4179 +4180 +4181 +4182 +4183 +4184 +4185 +4186 +4187 +4188 +4189 +4190 +4191 +4192 +4193 +4194 +4195 +4196 +4197 +4198 +4199 +4200 +4201 +4202 +4203 +4204 +4205 +4206 +4207 +4208 +4209 +4210 +4211 +4212 +4213 +4214 +4215 +4216 +4217 +4218 +4219 +4220 +4221 +4222 +4223 +4224 +4225 +4226 +4227 +4228 +4229 +4230 +4231 +4232 +4233 +4234 +4235 +4236 +4237 +4238 +4239 +4240 +4241 +4242 +4243 +4244 +4245 +4246 +4247 +4248 +4249 +4250 +4251 +4252 +4253 +4254 +4255 +4256 +4257 +4258 +4259 +4260 +4261 +4262 +4263 +4264 +4265 +4266 +4267 +4268 +4269 +4270 +4271 +4272 +4273 +4274 +4275 +4276 +4277 +4278 +4279 +4280 +4281 +4282 +4283 +4284 +4285 +4286 +4287 +4288 +4289 +4290 +4291 +4292 +4293 +4294 +4295 +4296 +4297 +4298 +4299 +4300 +4301 +4302 +4303 +4304 +4305 +4306 +4307 +4308 +4309 +4310 +4311 +4312 +4313 +4314 +4315 +4316 +4317 +4318 +4319 +4320 +4321 +4322 +4323 +4324 +4325 +4326 +4327 +4328 +4329 +4330 +4331 +4332 +4333 +4334 +4335 +4336 +4337 +4338 +4339 +4340 +4341 +4342 +4343 +4344 +4345 +4346 +4347 +4348 +4349 +4350 +4351 +4352 +4353 +4354 +4355 +4356 +4357 +4358 +4359 +4360 +4361 +4362 +4363 +4364 +4365 +4366 +4367 +4368 +4369 +4370 +4371 +4372 +4373 +4374 +4375 +4376 +4377 +4378 +4379 +4380 +4381 +4382 +4383 +4384 +4385 +4386 +4387 +4388 +4389 +4390 +4391 +4392 +4393 +4394 +4395 +4396 +4397 +4398 +4399 +4400 +4401 +4402 +4403 +4404 +4405 +4406 +4407 +4408 +4409 +4410 +4411 +4412 +4413 +4414 +4415 +4416 +4417 +4418 +4419 +4420 +4421 +4422 +4423 +4424 +4425 +4426 +4427 +4428 +4429 +4430 +4431 +4432 +4433 +4434 +4435 +4436 +4437 +4438 +4439 +4440 +4441 +4442 +4443 +4444 +4445 +4446 +4447 +4448 +4449 +4450 +4451 +4452 +4453 +4454 +4455 +4456 +4457 +4458 +4459 +4460 +4461 +4462 +4463 +4464 +4465 +4466 +4467 +4468 +4469 +4470 +4471 +4472 +4473 +4474 +4475 +4476 +4477 +4478 +4479 +4480 +4481 +4482 +4483 +4484 +4485 +4486 +4487 +4488 +4489 +4490 +4491 +4492 +4493 +4494 +4495 +4496 +4497 +4498 +4499 +4500 +4501 +4502 +4503 +4504 +4505 +4506 +4507 +4508 +4509 +4510 +4511 +4512 +4513 +4514 +4515 +4516 +4517 +4518 +4519 +4520 +4521 +4522 +4523 +4524 +4525 +4526 +4527 +4528 +4529 +4530 +4531 +4532 +4533 +4534 +4535 +4536 +4537 +4538 +4539 +4540 +4541 +4542 +4543 +4544 +4545 +4546 +4547 +4548 +4549 +4550 +4551 +4552 +4553 +4554 +4555 +4556 +4557 +4558 +4559 +4560 +4561 +4562 +4563 +4564 +4565 +4566 +4567 +4568 +4569 +4570 +4571 +4572 +4573 +4574 +4575 +4576 +4577 +4578 +4579 +4580 +4581 +4582 +4583 +4584 +4585 +4586 +4587 +4588 +4589 +4590 +4591 +4592 +4593 +4594 +4595 +4596 +4597 +4598 +4599 +4600 +4601 +4602 +4603 +4604 +4605 +4606 +4607 +4608 +4609 +4610 +4611 +4612 +4613 +4614 +4615 +4616 +4617 +4618 +4619 +4620 +4621 +4622 +4623 +4624 +4625 +4626 +4627 +4628 +4629 +4630 +4631 +4632 +4633 +4634 +4635 +4636 +4637 +4638 +4639 +4640 +4641 +4642 +4643 +4644 +4645 +4646 +4647 +4648 +4649 +4650 +4651 +4652 +4653 +4654 +4655 +4656 +4657 +4658 +4659 +4660 +4661 +4662 +4663 +4664 +4665 +4666 +4667 +4668 +4669 +4670 +4671 +4672 +4673 +4674 +4675 +4676 +4677 +4678 +4679 +4680 +4681 +4682 +4683 +4684 +4685 +4686 +4687 +4688 +4689 +4690 +4691 +4692 +4693 +4694 +4695 +4696 +4697 +4698 +4699 +4700 +4701 +4702 +4703 +4704 +4705 +4706 +4707 +4708 +4709 +4710 +4711 +4712 +4713 +4714 +4715 +4716 +4717 +4718 +4719 +4720 +4721 +4722 +4723 +4724 +4725 +4726 +4727 +4728 +4729 +4730 +4731 +4732 +4733 +4734 +4735 +4736 +4737 +4738 +4739 +4740 +4741 +4742 +4743 +4744 +4745 +4746 +4747 +4748 +4749 +4750 +4751 +4752 +4753 +4754 +4755 +4756 +4757 +4758 +4759 +4760 +4761 +4762 +4763 +4764 +4765 +4766 +4767 +4768 +4769 +4770 +4771 +4772 +4773 +4774 +4775 +4776 +4777 +4778 +4779 +4780 +4781 +4782 +4783 +4784 +4785 +4786 +4787 +4788 +4789 +4790 +4791 +4792 +4793 +4794 +4795 +4796 +4797 +4798 +4799 +4800 +4801 +4802 +4803 +4804 +4805 +4806 +4807 +4808 +4809 +4810 +4811 +4812 +4813 +4814 +4815 +4816 +4817 +4818 +4819 +4820 +4821 +4822 +4823 +4824 +4825 +4826 +4827 +4828 +4829 +4830 +4831 +4832 +4833 +4834 +4835 +4836 +4837 +4838 +4839 +4840 +4841 +4842 +4843 +4844 +4845 +4846 +4847 +4848 +4849 +4850 +4851 +4852 +4853 +4854 +4855 +4856 +4857 +4858 +4859 +4860 +4861 +4862 +4863 +4864 +4865 +4866 +4867 +4868 +4869 +4870 +4871 +4872 +4873 +4874 +4875 +4876 +4877 +4878 +4879 +4880 +4881 +4882 +4883 +4884 +4885 +4886 +4887 +4888 +4889 +4890 +4891 +4892 +4893 +4894 +4895 +4896 +4897 +4898 +4899 +4900 +4901 +4902 +4903 +4904 +4905 +4906 +4907 +4908 +4909 +4910 +4911 +4912 +4913 +4914 +4915 +4916 +4917 +4918 +4919 +4920 +4921 +4922 +4923 +4924 +4925 +4926 +4927 +4928 +4929 +4930 +4931 +4932 +4933 +4934 +4935 +4936 +4937 +4938 +4939 +4940 +4941 +4942 +4943 +4944 +4945 +4946 +4947 +4948 +4949 +4950 +4951 +4952 +4953 +4954 +4955 +4956 +4957 +4958 +4959 +4960 +4961 +4962 +4963 +4964 +4965 +4966 +4967 +4968 +4969 +4970 +4971 +4972 +4973 +4974 +4975 +4976 +4977 +4978 +4979 +4980 +4981 +4982 +4983 +4984 +4985 +4986 +4987 +4988 +4989 +4990 +4991 +4992 +4993 +4994 +4995 +4996 +4997 +4998 +4999 +5000 +5001 +5002 +5003 +5004 +5005 +5006 +5007 +5008 +5009 +5010 +5011 +5012 +5013 +5014 +5015 +5016 +5017 +5018 +5019 +5020 +5021 +5022 +5023 +5024 +5025 +5026 +5027 +5028 +5029 +5030 +5031 +5032 +5033 +5034 +5035 +5036 +5037 +5038 +5039 +5040 +5041 +5042 +5043 +5044 +5045 +5046 +5047 +5048 +5049 +5050 +5051 +5052 +5053 +5054 +5055 +5056 +5057 +5058 +5059 +5060 +5061 +5062 +5063 +5064 +5065 +5066 +5067 +5068 +5069 +5070 +5071 +5072 +5073 +5074 +5075 +5076 +5077 +5078 +5079 +5080 +5081 +5082 +5083 +5084 +5085 +5086 +5087 +5088 +5089 +5090 +5091 +5092 +5093 +5094 +5095 +5096 +5097 +5098 +5099 +5100 +5101 +5102 +5103 +5104 +5105 +5106 +5107 +5108 +5109 +5110 +5111 +5112 +5113 +5114 +5115 +5116 +5117 +5118 +5119 +5120 +5121 +5122 +5123 +5124 +5125 +5126 +5127 +5128 +5129 +5130 +5131 +5132 +5133 +5134 +5135 +5136 +5137 +5138 +5139 +5140 +5141 +5142 +5143 +5144 +5145 +5146 +5147 +5148 +5149 +5150 +5151 +5152 +5153 +5154 +5155 +5156 +5157 +5158 +5159 +5160 +5161 +5162 +5163 +5164 +5165 +5166 +5167 +5168 +5169 +5170 +5171 +5172 +5173 +5174 +5175 +5176 +5177 +5178 +5179 +5180 +5181 +5182 +5183 +5184 +5185 +5186 +5187 +5188 +5189 +5190 +5191 +5192 +5193 +5194 +5195 +5196 +5197 +5198 +5199 +5200 +5201 +5202 +5203 +5204 +5205 +5206 +5207 +5208 +5209 +5210 +5211 +5212 +5213 +5214 +5215 +5216 +5217 +5218 +5219 +5220 +5221 +5222 +5223 +5224 +5225 +5226 +5227 +5228 +5229 +5230 +5231 +5232 +5233 +5234 +5235 +5236 +5237 +5238 +5239 +5240 +5241 +5242 +5243 +5244 +5245 +5246 +5247 +5248 +5249 +5250 +5251 +5252 +5253 +5254 +5255 +5256 +5257 +5258 +5259 +5260 +5261 +5262 +5263 +5264 +5265 +5266 +5267 +5268 +5269 +5270 +5271 +5272 +5273 +5274 +5275 +5276 +5277 +5278 +5279 +5280 +5281 +5282 +5283 +5284 +5285 +5286 +5287 +5288 +5289 +5290 +5291 +5292 +5293 +5294 +5295 +5296 +5297 +5298 +5299 +5300 +5301 +5302 +5303 +5304 +5305 +5306 +5307 +5308 +5309 +5310 +5311 +5312 +5313 +5314 +5315 +5316 +5317 +5318 +5319 +5320 +5321 +5322 +5323 +5324 +5325 +5326 +5327 +5328 +5329 +5330 +5331 +5332 +5333 +5334 +5335 +5336 +5337 +5338 +5339 +5340 +5341 +5342 +5343 +5344 +5345 +5346 +5347 +5348 +5349 +5350 +5351 +5352 +5353 +5354 +5355 +5356 +5357 +5358 +5359 +5360 +5361 +5362 +5363 +5364 +5365 +5366 +5367 +5368 +5369 +5370 +5371 +5372 +5373 +5374 +5375 +5376 +5377 +5378 +5379 +5380 +5381 +5382 +5383 +5384 +5385 +5386 +5387 +5388 +5389 +5390 +5391 +5392 +5393 +5394 +5395 +5396 +5397 +5398 +5399 +5400 +5401 +5402 +5403 +5404 +5405 +5406 +5407 +5408 +5409 +5410 +5411 +5412 +5413 +5414 +5415 +5416 +5417 +5418 +5419 +5420 +5421 +5422 +5423 +5424 +5425 +5426 +5427 +5428 +5429 +5430 +5431 +5432 +5433 +5434 +5435 +5436 +5437 +5438 +5439 +5440 +5441 +5442 +5443 +5444 +5445 +5446 +5447 +5448 +5449 +5450 +5451 +5452 +5453 +5454 +5455 +5456 +5457 +5458 +5459 +5460 +5461 +5462 +5463 +5464 +5465 +5466 +5467 +5468 +5469 +5470 +5471 +5472 +5473 +5474 +5475 +5476 +5477 +5478 +5479 +5480 +5481 +5482 +5483 +5484 +5485 +5486 +5487 +5488 +5489 +5490 +5491 +5492 +5493 +5494 +5495 +5496 +5497 +5498 +5499 +5500 +5501 +5502 +5503 +5504 +5505 +5506 +5507 +5508 +5509 +5510 +5511 +5512 +5513 +5514 +5515 +5516 +5517 +5518 +5519 +5520 +5521 +5522 +5523 +5524 +5525 +5526 +5527 +5528 +5529 +5530 +5531 +5532 +5533 +5534 +5535 +5536 +5537 +5538 +5539 +5540 +5541 +5542 +5543 +5544 +5545 +5546 +5547 +5548 +5549 +5550 +5551 +5552 +5553 +5554 +5555 +5556 +5557 +5558 +5559 +5560 +5561 +5562 +5563 +5564 +5565 +5566 +5567 +5568 +5569 +5570 +5571 +5572 +5573 +5574 +5575 +5576 +5577 +5578 +5579 +5580 +5581 +5582 +5583 +5584 +5585 +5586 +5587 +5588 +5589 +5590 +5591 +5592 +5593 +5594 +5595 +5596 +5597 +5598 +5599 +5600 +5601 +5602 +5603 +5604 +5605 +5606 +5607 +5608 +5609 +5610 +5611 +5612 +5613 +5614 +5615 +5616 +5617 +5618 +5619 +5620 +5621 +5622 +5623 +5624 +5625 +5626 +5627 +5628 +5629 +5630 +5631 +5632 +5633 +5634 +5635 +5636 +5637 +5638 +5639 +5640 +5641 +5642 +5643 +5644 +5645 +5646 +5647 +5648 +5649 +5650 +5651 +5652 +5653 +5654 +5655 +5656 +5657 +5658 +5659 +5660 +5661 +5662 +5663 +5664 +5665 +5666 +5667 +5668 +5669 +5670 +5671 +5672 +5673 +5674 +5675 +5676 +5677 +5678 +5679 +5680 +5681 +5682 +5683 +5684 +5685 +5686 +5687 +5688 +5689 +5690 +5691 +5692 +5693 +5694 +5695 +5696 +5697 +5698 +5699 +5700 +5701 +5702 +5703 +5704 +5705 +5706 +5707 +5708 +5709 +5710 +5711 +5712 +5713 +5714 +5715 +5716 +5717 +5718 +5719 +5720 +5721 +5722 +5723 +5724 +5725 +5726 +5727 +5728 +5729 +5730 +5731 +5732 +5733 +5734 +5735 +5736 +5737 +5738 +5739 +5740 +5741 +5742 +5743 +5744 +5745 +5746 +5747 +5748 +5749 +5750 +5751 +5752 +5753 +5754 +5755 +5756 +5757 +5758 +5759 +5760 +5761 +5762 +5763 +5764 +5765 +5766 +5767 +5768 +5769 +5770 +5771 +5772 +5773 +5774 +5775 +5776 +5777 +5778 +5779 +5780 +5781 +5782 +5783 +5784 +5785 +5786 +5787 +5788 +5789 +5790 +5791 +5792 +5793 +5794 +5795 +5796 +5797 +5798 +5799 +5800 +5801 +5802 +5803 +5804 +5805 +5806 +5807 +5808 +5809 +5810 +5811 +5812 +5813 +5814 +5815 +5816 +5817 +5818 +5819 +5820 +5821 +5822 +5823 +5824 +5825 +5826 +5827 +5828 +5829 +5830 +5831 +5832 +5833 +5834 +5835 +5836 +5837 +5838 +5839 +5840 +5841 +5842 +5843 +5844 +5845 +5846 +5847 +5848 +5849 +5850 +5851 +5852 +5853 +5854 +5855 +5856 +5857 +5858 +5859 +5860 +5861 +5862 +5863 +5864 +5865 +5866 +5867 +5868 +5869 +5870 +5871 +5872 +5873 +5874 +5875 +5876 +5877 +5878 +5879 +5880 +5881 +5882 +5883 +5884 +5885 +5886 +5887 +5888 +5889 +5890 +5891 +5892 +5893 +5894 +5895 +5896 +5897 +5898 +5899 +5900 +5901 +5902 +5903 +5904 +5905 +5906 +5907 +5908 +5909 +5910 +5911 +5912 +5913 +5914 +5915 +5916 +5917 +5918 +5919 +5920 +5921 +5922 +5923 +5924 +5925 +5926 +5927 +5928 +5929 +5930 +5931 +5932 +5933 +5934 +5935 +5936 +5937 +5938 +5939 +5940 +5941 +5942 +5943 +5944 +5945 +5946 +5947 +5948 +5949 +5950 +5951 +5952 +5953 +5954 +5955 +5956 +5957 +5958 +5959 +5960 +5961 +5962 +5963 +5964 +5965 +5966 +5967 +5968 +5969 +5970 +5971 +5972 +5973 +5974 +5975 +5976 +5977 +5978 +5979 +5980 +5981 +5982 +5983 +5984 +5985 +5986 +5987 +5988 +5989 +5990 +5991 +5992 +5993 +5994 +5995 +5996 +5997 +5998 +5999 +6000 +6001 +6002 +6003 +6004 +6005 +6006 +6007 +6008 +6009 +6010 +6011 +6012 +6013 +6014 +6015 +6016 +6017 +6018 +6019 +6020 +6021 +6022 +6023 +6024 +6025 +6026 +6027 +6028 +6029 +6030 +6031 +6032 +6033 +6034 +6035 +6036 +6037 +6038 +6039 +6040 +6041 +6042 +6043 +6044 +6045 +6046 +6047 +6048 +6049 +6050 +6051 +6052 +6053 +6054 +6055 +6056 +6057 +6058 +6059 +6060 +6061 +6062 +6063 +6064 +6065 +6066 +6067 +6068 +6069 +6070 +6071 +6072 +6073 +6074 +6075 +6076 +6077 +6078 +6079 +6080 +6081 +6082 +6083 +6084 +6085 +6086 +6087 +6088 +6089 +6090 +6091 +6092 +6093 +6094 +6095 +6096 +6097 +6098 +6099 +6100 +6101 +6102 +6103 +6104 +6105 +6106 +6107 +6108 +6109 +6110 +6111 +6112 +6113 +6114 +6115 +6116 +6117 +6118 +6119 +6120 +6121 +6122 +6123 +6124 +6125 +6126 +6127 +6128 +6129 +6130 +6131 +6132 +6133 +6134 +6135 +6136 +6137 +6138 +6139 +6140 +6141 +6142 +6143 +6144 +6145 +6146 +6147 +6148 +6149 +6150 +6151 +6152 +6153 +6154 +6155 +6156 +6157 +6158 +6159 +6160 +6161 +6162 +6163 +6164 +6165 +6166 +6167 +6168 +6169 +6170 +6171 +6172 +6173 +6174 +6175 +6176 +6177 +6178 +6179 +6180 +6181 +6182 +6183 +6184 +6185 +6186 +6187 +6188 +6189 +6190 +6191 +6192 +6193 +6194 +6195 +6196 +6197 +6198 +6199 +6200 +6201 +6202 +6203 +6204 +6205 +6206 +6207 +6208 +6209 +6210 +6211 +6212 +6213 +6214 +6215 +6216 +6217 +6218 +6219 +6220 +6221 +6222 +6223 +6224 +6225 +6226 +6227 +6228 +6229 +6230 +6231 +6232 +6233 +6234 +6235 +6236 +6237 +6238 +6239 +6240 +6241 +6242 +6243 +6244 +6245 +6246 +6247 +6248 +6249 +6250 +6251 +6252 +6253 +6254 +6255 +6256 +6257 +6258 +6259 +6260 +6261 +6262 +6263 +6264 +6265 +6266 +6267 +6268 +6269 +6270 +6271 +6272 +6273 +6274 +6275 +6276 +6277 +6278 +6279 +6280 +6281 +6282 +6283 +6284 +6285 +6286 +6287 +6288 +6289 +6290 +6291 +6292 +6293 +6294 +6295 +6296 +6297 +6298 +6299 +6300 +6301 +6302 +6303 +6304 +6305 +6306 +6307 +6308 +6309 +6310 +6311 +6312 +6313 +6314 +6315 +6316 +6317 +6318 +6319 +6320 +6321 +6322 +6323 +6324 +6325 +6326 +6327 +6328 +6329 +6330 +6331 +6332 +6333 +6334 +6335 +6336 +6337 +6338 +6339 +6340 +6341 +6342 +6343 +6344 +6345 +6346 +6347 +6348 +6349 +6350 +6351 +6352 +6353 +6354 +6355 +6356 +6357 +6358 +6359 +6360 +6361 +6362 +6363 +6364 +6365 +6366 +6367 +6368 +6369 +6370 +6371 +6372 +6373 +6374 +6375 +6376 +6377 +6378 +6379 +6380 +6381 +6382 +6383 +6384 +6385 +6386 +6387 +6388 +6389 +6390 +6391 +6392 +6393 +6394 +6395 +6396 +6397 +6398 +6399 +6400 +6401 +6402 +6403 +6404 +6405 +6406 +6407 +6408 +6409 +6410 +6411 +6412 +6413 +6414 +6415 +6416 +6417 +6418 +6419 +6420 +6421 +6422 +6423 +6424 +6425 +6426 +6427 +6428 +6429 +6430 +6431 +6432 +6433 +6434 +6435 +6436 +6437 +6438 +6439 +6440 +6441 +6442 +6443 +6444 +6445 +6446 +6447 +6448 +6449 +6450 +6451 +6452 +6453 +6454 +6455 +6456 +6457 +6458 +6459 +6460 +6461 +6462 +6463 +6464 +6465 +6466 +6467 +6468 +6469 +6470 +6471 +6472 +6473 +6474 +6475 +6476 +6477 +6478 +6479 +6480 +6481 +6482 +6483 +6484 +6485 +6486 +6487 +6488 +6489 +6490 +6491 +6492 +6493 +6494 +6495 +6496 +6497 +6498 +6499 +6500 +6501 +6502 +6503 +6504 +6505 +6506 +6507 +6508 +6509 +6510 +6511 +6512 +6513 +6514 +6515 +6516 +6517 +6518 +6519 +6520 +6521 +6522 +6523 +6524 +6525 +6526 +6527 +6528 +6529 +6530 +6531 +6532 +6533 +6534 +6535 +6536 +6537 +6538 +6539 +6540 +6541 +6542 +6543 +6544 +6545 +6546 +6547 +6548 +6549 +6550 +6551 +6552 +6553 +6554 +6555 +6556 +6557 +6558 +6559 +6560 +6561 +6562 +6563 +6564 +6565 +6566 +6567 +6568 +6569 +6570 +6571 +6572 +6573 +6574 +6575 +6576 +6577 +6578 +6579 +6580 +6581 +6582 +6583 +6584 +6585 +6586 +6587 +6588 +6589 +6590 +6591 +6592 +6593 +6594 +6595 +6596 +6597 +6598 +6599 +6600 +6601 +6602 +6603 +6604 +6605 +6606 +6607 +6608 +6609 +6610 +6611 +6612 +6613 +6614 +6615 +6616 +6617 +6618 +6619 +6620 +6621 +6622 +6623 +6624 +6625 +6626 +6627 +6628 +6629 +6630 +6631 +6632 +6633 +6634 +6635 +6636 +6637 +6638 +6639 +6640 +6641 +6642 +6643 +6644 +6645 +6646 +6647 +6648 +6649 +6650 +6651 +6652 +6653 +6654 +6655 +6656 +6657 +6658 +6659 +6660 +6661 +6662 +6663 +6664 +6665 +6666 +6667 +6668 +6669 +6670 +6671 +6672 +6673 +6674 +6675 +6676 +6677 +6678 +6679 +6680 +6681 +6682 +6683 +6684 +6685 +6686 +6687 +6688 +6689 +6690 +6691 +6692 +6693 +6694 +6695 +6696 +6697 +6698 +6699 +6700 +6701 +6702 +6703 +6704 +6705 +6706 +6707 +6708 +6709 +6710 +6711 +6712 +6713 +6714 +6715 +6716 +6717 +6718 +6719 +6720 +6721 +6722 +6723 +6724 +6725 +6726 +6727 +6728 +6729 +6730 +6731 +6732 +6733 +6734 +6735 +6736 +6737 +6738 +6739 +6740 +6741 +6742 +6743 +6744 +6745 +6746 +6747 +6748 +6749 +6750 +6751 +6752 +6753 +6754 +6755 +6756 +6757 +6758 +6759 +6760 +6761 +6762 +6763 +6764 +6765 +6766 +6767 +6768 +6769 +6770 +6771 +6772 +6773 +6774 +6775 +6776 +6777 +6778 +6779 +6780 +6781 +6782 +6783 +6784 +6785 +6786 +6787 +6788 +6789 +6790 +6791 +6792 +6793 +6794 +6795 +6796 +6797 +6798 +6799 +6800 +6801 +6802 +6803 +6804 +6805 +6806 +6807 +6808 +6809 +6810 +6811 +6812 +6813 +6814 +6815 +6816 +6817 +6818 +6819 +6820 +6821 +6822 +6823 +6824 +6825 +6826 +6827 +6828 +6829 +6830 +6831 +6832 +6833 +6834 +6835 +6836 +6837 +6838 +6839 +6840 +6841 +6842 +6843 +6844 +6845 +6846 +6847 +6848 +6849 +6850 +6851 +6852 +6853 +6854 +6855 +6856 +6857 +6858 +6859 +6860 +6861 +6862 +6863 +6864 +6865 +6866 +6867 +6868 +6869 +6870 +6871 +6872 +6873 +6874 +6875 +6876 +6877 +6878 +6879 +6880 +6881 +6882 +6883 +6884 +6885 +6886 +6887 +6888 +6889 +6890 +6891 +6892 +6893 +6894 +6895 +6896 +6897 +6898 +6899 +6900 +6901 +6902 +6903 +6904 +6905 +6906 +6907 +6908 +6909 +6910 +6911 +6912 +6913 +6914 +6915 +6916 +6917 +6918 +6919 +6920 +6921 +6922 +6923 +6924 +6925 +6926 +6927 +6928 +6929 +6930 +6931 +6932 +6933 +6934 +6935 +6936 +6937 +6938 +6939 +6940 +6941 +6942 +6943 +6944 +6945 +6946 +6947 +6948 +6949 +6950 +6951 +6952 +6953 +6954 +6955 +6956 +6957 +6958 +6959 +6960 +6961 +6962 +6963 +6964 +6965 +6966 +6967 +6968 +6969 +6970 +6971 +6972 +6973 +6974 +6975 +6976 +6977 +6978 +6979 +6980 +6981 +6982 +6983 +6984 +6985 +6986 +6987 +6988 +6989 +6990 +6991 +6992 +6993 +6994 +6995 +6996 +6997 +6998 +6999 +7000 +7001 +7002 +7003 +7004 +7005 +7006 +7007 +7008 +7009 +7010 +7011 +7012 +7013 +7014 +7015 +7016 +7017 +7018 +7019 +7020 +7021 +7022 +7023 +7024 +7025 +7026 +7027 +7028 +7029 +7030 +7031 +7032 +7033 +7034 +7035 +7036 +7037 +7038 +7039 +7040 +7041 +7042 +7043 +7044 +7045 +7046 +7047 +7048 +7049 +7050 +7051 +7052 +7053 +7054 +7055 +7056 +7057 +7058 +7059 +7060 +7061 +7062 +7063 +7064 +7065 +7066 +7067 +7068 +7069 +7070 +7071 +7072 +7073 +7074 +7075 +7076 +7077 +7078 +7079 +7080 +7081 +7082 +7083 +7084 +7085 +7086 +7087 +7088 +7089 +7090 +7091 +7092 +7093 +7094 +7095 +7096 +7097 +7098 +7099 +7100 +7101 +7102 +7103 +7104 +7105 +7106 +7107 +7108 +7109 +7110 +7111 +7112 +7113 +7114 +7115 +7116 +7117 +7118 +7119 +7120 +7121 +7122 +7123 +7124 +7125 +7126 +7127 +7128 +7129 +7130 +7131 +7132 +7133 +7134 +7135 +7136 +7137 +7138 +7139 +7140 +7141 +7142 +7143 +7144 +7145 +7146 +7147 +7148 +7149 +7150 +7151 +7152 +7153 +7154 +7155 +7156 +7157 +7158 +7159 +7160 +7161 +7162 +7163 +7164 +7165 +7166 +7167 +7168 +7169 +7170 +7171 +7172 +7173 +7174 +7175 +7176 +7177 +7178 +7179 +7180 +7181 +7182 +7183 +7184 +7185 +7186 +7187 +7188 +7189 +7190 +7191 +7192 +7193 +7194 +7195 +7196 +7197 +7198 +7199 +7200 +7201 +7202 +7203 +7204 +7205 +7206 +7207 +7208 +7209 +7210 +7211 +7212 +7213 +7214 +7215 +7216 +7217 +7218 +7219 +7220 +7221 +7222 +7223 +7224 +7225 +7226 +7227 +7228 +7229 +7230 +7231 +7232 +7233 +7234 +7235 +7236 +7237 +7238 +7239 +7240 +7241 +7242 +7243 +7244 +7245 +7246 +7247 +7248 +7249 +7250 +7251 +7252 +7253 +7254 +7255 +7256 +7257 +7258 +7259 +7260 +7261 +7262 +7263 +7264 +7265 +7266 +7267 +7268 +7269 +7270 +7271 +7272 +7273 +7274 +7275 +7276 +7277 +7278 +7279 +7280 +7281 +7282 +7283 +7284 +7285 +7286 +7287 +7288 +7289 +7290 +7291 +7292 +7293 +7294 +7295 +7296 +7297 +7298 +7299 +7300 +7301 +7302 +7303 +7304 +7305 +7306 +7307 +7308 +7309 +7310 +7311 +7312 +7313 +7314 +7315 +7316 +7317 +7318 +7319 +7320 +7321 +7322 +7323 +7324 +7325 +7326 +7327 +7328 +7329 +7330 +7331 +7332 +7333 +7334 +7335 +7336 +7337 +7338 +7339 +7340 +7341 +7342 +7343 +7344 +7345 +7346 +7347 +7348 +7349 +7350 +7351 +7352 +7353 +7354 +7355 +7356 +7357 +7358 +7359 +7360 +7361 +7362 +7363 +7364 +7365 +7366 +7367 +7368 +7369 +7370 +7371 +7372 +7373 +7374 +7375 +7376 +7377 +7378 +7379 +7380 +7381 +7382 +7383 +7384 +7385 +7386 +7387 +7388 +7389 +7390 +7391 +7392 +7393 +7394 +7395 +7396 +7397 +7398 +7399 +7400 +7401 +7402 +7403 +7404 +7405 +7406 +7407 +7408 +7409 +7410 +7411 +7412 +7413 +7414 +7415 +7416 +7417 +7418 +7419 +7420 +7421 +7422 +7423 +7424 +7425 +7426 +7427 +7428 +7429 +7430 +7431 +7432 +7433 +7434 +7435 +7436 +7437 +7438 +7439 +7440 +7441 +7442 +7443 +7444 +7445 +7446 +7447 +7448 +7449 +7450 +7451 +7452 +7453 +7454 +7455 +7456 +7457 +7458 +7459 +7460 +7461 +7462 +7463 +7464 +7465 +7466 +7467 +7468 +7469 +7470 +7471 +7472 +7473 +7474 +7475 +7476 +7477 +7478 +7479 +7480 +7481 +7482 +7483 +7484 +7485 +7486 +7487 +7488 +7489 +7490 +7491 +7492 +7493 +7494 +7495 +7496 +7497 +7498 +7499 +7500 +7501 +7502 +7503 +7504 +7505 +7506 +7507 +7508 +7509 +7510 +7511 +7512 +7513 +7514 +7515 +7516 +7517 +7518 +7519 +7520 +7521 +7522 +7523 +7524 +7525 +7526 +7527 +7528 +7529 +7530 +7531 +7532 +7533 +7534 +7535 +7536 +7537 +7538 +7539 +7540 +7541 +7542 +7543 +7544 +7545 +7546 +7547 +7548 +7549 +7550 +7551 +7552 +7553 +7554 +7555 +7556 +7557 +7558 +7559 +7560 +7561 +7562 +7563 +7564 +7565 +7566 +7567 +7568 +7569 +7570 +7571 +7572 +7573 +7574 +7575 +7576 +7577 +7578 +7579 +7580 +7581 +7582 +7583 +7584 +7585 +7586 +7587 +7588 +7589 +7590 +7591 +7592 +7593 +7594 +7595 +7596 +7597 +7598 +7599 +7600 +7601 +7602 +7603 +7604 +7605 +7606 +7607 +7608 +7609 +7610 +7611 +7612 +7613 +7614 +7615 +7616 +7617 +7618 +7619 +7620 +7621 +7622 +7623 +7624 +7625 +7626 +7627 +7628 +7629 +7630 +7631 +7632 +7633 +7634 +7635 +7636 +7637 +7638 +7639 +7640 +7641 +7642 +7643 +7644 +7645 +7646 +7647 +7648 +7649 +7650 +7651 +7652 +7653 +7654 +7655 +7656 +7657 +7658 +7659 +7660 +7661 +7662 +7663 +7664 +7665 +7666 +7667 +7668 +7669 +7670 +7671 +7672 +7673 +7674 +7675 +7676 +7677 +7678 +7679 +7680 +7681 +7682 +7683 +7684 +7685 +7686 +7687 +7688 +7689 +7690 +7691 +7692 +7693 +7694 +7695 +7696 +7697 +7698 +7699 +7700 +7701 +7702 +7703 +7704 +7705 +7706 +7707 +7708 +7709 +7710 +7711 +7712 +7713 +7714 +7715 +7716 +7717 +7718 +7719 +7720 +7721 +7722 +7723 +7724 +7725 +7726 +7727 +7728 +7729 +7730 +7731 +7732 +7733 +7734 +7735 +7736 +7737 +7738 +7739 +7740 +7741 +7742 +7743 +7744 +7745 +7746 +7747 +7748 +7749 +7750 +7751 +7752 +7753 +7754 +7755 +7756 +7757 +7758 +7759 +7760 +7761 +7762 +7763 +7764 +7765 +7766 +7767 +7768 +7769 +7770 +7771 +7772 +7773 +7774 +7775 +7776 +7777 +7778 +7779 +7780 +7781 +7782 +7783 +7784 +7785 +7786 +7787 +7788 +7789 +7790 +7791 +7792 +7793 +7794 +7795 +7796 +7797 +7798 +7799 +7800 +7801 +7802 +7803 +7804 +7805 +7806 +7807 +7808 +7809 +7810 +7811 +7812 +7813 +7814 +7815 +7816 +7817 +7818 +7819 +7820 +7821 +7822 +7823 +7824 +7825 +7826 +7827 +7828 +7829 +7830 +7831 +7832 +7833 +7834 +7835 +7836 +7837 +7838 +7839 +7840 +7841 +7842 +7843 +7844 +7845 +7846 +7847 +7848 +7849 +7850 +7851 +7852 +7853 +7854 +7855 +7856 +7857 +7858 +7859 +7860 +7861 +7862 +7863 +7864 +7865 +7866 +7867 +7868 +7869 +7870 +7871 +7872 +7873 +7874 +7875 +7876 +7877 +7878 +7879 +7880 +7881 +7882 +7883 +7884 +7885 +7886 +7887 +7888 +7889 +7890 +7891 +7892 +7893 +7894 +7895 +7896 +7897 +7898 +7899 +7900 +7901 +7902 +7903 +7904 +7905 +7906 +7907 +7908 +7909 +7910 +7911 +7912 +7913 +7914 +7915 +7916 +7917 +7918 +7919 +7920 +7921 +7922 +7923 +7924 +7925 +7926 +7927 +7928 +7929 +7930 +7931 +7932 +7933 +7934 +7935 +7936 +7937 +7938 +7939 +7940 +7941 +7942 +7943 +7944 +7945 +7946 +7947 +7948 +7949 +7950 +7951 +7952 +7953 +7954 +7955 +7956 +7957 +7958 +7959 +7960 +7961 +7962 +7963 +7964 +7965 +7966 +7967 +7968 +7969 +7970 +7971 +7972 +7973 +7974 +7975 +7976 +7977 +7978 +7979 +7980 +7981 +7982 +7983 +7984 +7985 +7986 +7987 +7988 +7989 +7990 +7991 +7992 +7993 +7994 +7995 +7996 +7997 +7998 +7999 +8000 +8001 +8002 +8003 +8004 +8005 +8006 +8007 +8008 +8009 +8010 +8011 +8012 +8013 +8014 +8015 +8016 +8017 +8018 +8019 +8020 +8021 +8022 +8023 +8024 +8025 +8026 +8027 +8028 +8029 +8030 +8031 +8032 +8033 +8034 +8035 +8036 +8037 +8038 +8039 +8040 +8041 +8042 +8043 +8044 +8045 +8046 +8047 +8048 +8049 +8050 +8051 +8052 +8053 +8054 +8055 +8056 +8057 +8058 +8059 +8060 +8061 +8062 +8063 +8064 +8065 +8066 +8067 +8068 +8069 +8070 +8071 +8072 +8073 +8074 +8075 +8076 +8077 +8078 +8079 +8080 +8081 +8082 +8083 +8084 +8085 +8086 +8087 +8088 +8089 +8090 +8091 +8092 +8093 +8094 +8095 +8096 +8097 +8098 +8099 +8100 +8101 +8102 +8103 +8104 +8105 +8106 +8107 +8108 +8109 +8110 +8111 +8112 +8113 +8114 +8115 +8116 +8117 +8118 +8119 +8120 +8121 +8122 +8123 +8124 +8125 +8126 +8127 +8128 +8129 +8130 +8131 +8132 +8133 +8134 +8135 +8136 +8137 +8138 +8139 +8140 +8141 +8142 +8143 +8144 +8145 +8146 +8147 +8148 +8149 +8150 +8151 +8152 +8153 +8154 +8155 +8156 +8157 +8158 +8159 +8160 +8161 +8162 +8163 +8164 +8165 +8166 +8167 +8168 +8169 +8170 +8171 +8172 +8173 +8174 +8175 +8176 +8177 +8178 +8179 +8180 +8181 +8182 +8183 +8184 +8185 +8186 +8187 +8188 +8189 +8190 +8191 +8192 +8193 +8194 +8195 +8196 +8197 +8198 +8199 +8200 +8201 +8202 +8203 +8204 +8205 +8206 +8207 +8208 +8209 +8210 +8211 +8212 +8213 +8214 +8215 +8216 +8217 +8218 +8219 +8220 +8221 +8222 +8223 +8224 +8225 +8226 +8227 +8228 +8229 +8230 +8231 +8232 +8233 +8234 +8235 +8236 +8237 +8238 +8239 +8240 +8241 +8242 +8243 +8244 +8245 +8246 +8247 +8248 +8249 +8250 +8251 +8252 +8253 +8254 +8255 +8256 +8257 +8258 +8259 +8260 +8261 +8262 +8263 +8264 +8265 +8266 +8267 +8268 +8269 +8270 +8271 +8272 +8273 +8274 +8275 +8276 +8277 +8278 +8279 +8280 +8281 +8282 +8283 +8284 +8285 +8286 +8287 +8288 +8289 +8290 +8291 +8292 +8293 +8294 +8295 +8296 +8297 +8298 +8299 +8300 +8301 +8302 +8303 +8304 +8305 +8306 +8307 +8308 +8309 +8310 +8311 +8312 +8313 +8314 +8315 +8316 +8317 +8318 +8319 +8320 +8321 +8322 +8323 +8324 +8325 +8326 +8327 +8328 +8329 +8330 +8331 +8332 +8333 +8334 +8335 +8336 +8337 +8338 +8339 +8340 +8341 +8342 +8343 +8344 +8345 +8346 +8347 +8348 +8349 +8350 +8351 +8352 +8353 +8354 +8355 +8356 +8357 +8358 +8359 +8360 +8361 +8362 +8363 +8364 +8365 +8366 +8367 +8368 +8369 +8370 +8371 +8372 +8373 +8374 +8375 +8376 +8377 +8378 +8379 +8380 +8381 +8382 +8383 +8384 +8385 +8386 +8387 +8388 +8389 +8390 +8391 +8392 +8393 +8394 +8395 +8396 +8397 +8398 +8399 +8400 +8401 +8402 +8403 +8404 +8405 +8406 +8407 +8408 +8409 +8410 +8411 +8412 +8413 +8414 +8415 +8416 +8417 +8418 +8419 +8420 +8421 +8422 +8423 +8424 +8425 +8426 +8427 +8428 +8429 +8430 +8431 +8432 +8433 +8434 +8435 +8436 +8437 +8438 +8439 +8440 +8441 +8442 +8443 +8444 +8445 +8446 +8447 +8448 +8449 +8450 +8451 +8452 +8453 +8454 +8455 +8456 +8457 +8458 +8459 +8460 +8461 +8462 +8463 +8464 +8465 +8466 +8467 +8468 +8469 +8470 +8471 +8472 +8473 +8474 +8475 +8476 +8477 +8478 +8479 +8480 +8481 +8482 +8483 +8484 +8485 +8486 +8487 +8488 +8489 +8490 +8491 +8492 +8493 +8494 +8495 +8496 +8497 +8498 +8499 +8500 +8501 +8502 +8503 +8504 +8505 +8506 +8507 +8508 +8509 +8510 +8511 +8512 +8513 +8514 +8515 +8516 +8517 +8518 +8519 +8520 +8521 +8522 +8523 +8524 +8525 +8526 +8527 +8528 +8529 +8530 +8531 +8532 +8533 +8534 +8535 +8536 +8537 +8538 +8539 +8540 +8541 +8542 +8543 +8544 +8545 +8546 +8547 +8548 +8549 +8550 +8551 +8552 +8553 +8554 +8555 +8556 +8557 +8558 +8559 +8560 +8561 +8562 +8563 +8564 +8565 +8566 +8567 +8568 +8569 +8570 +8571 +8572 +8573 +8574 +8575 +8576 +8577 +8578 +8579 +8580 +8581 +8582 +8583 +8584 +8585 +8586 +8587 +8588 +8589 +8590 +8591 +8592 +8593 +8594 +8595 +8596 +8597 +8598 +8599 +8600 +8601 +8602 +8603 +8604 +8605 +8606 +8607 +8608 +8609 +8610 +8611 +8612 +8613 +8614 +8615 +8616 +8617 +8618 +8619 +8620 +8621 +8622 +8623 +8624 +8625 +8626 +8627 +8628 +8629 +8630 +8631 +8632 +8633 +8634 +8635 +8636 +8637 +8638 +8639 +8640 +8641 +8642 +8643 +8644 +8645 +8646 +8647 +8648 +8649 +8650 +8651 +8652 +8653 +8654 +8655 +8656 +8657 +8658 +8659 +8660 +8661 +8662 +8663 +8664 +8665 +8666 +8667 +8668 +8669 +8670 +8671 +8672 +8673 +8674 +8675 +8676 +8677 +8678 +8679 +8680 +8681 +8682 +8683 +8684 +8685 +8686 +8687 +8688 +8689 +8690 +8691 +8692 +8693 +8694 +8695 +8696 +8697 +8698 +8699 +8700 +8701 +8702 +8703 +8704 +8705 +8706 +8707 +8708 +8709 +8710 +8711 +8712 +8713 +8714 +8715 +8716 +8717 +8718 +8719 +8720 +8721 +8722 +8723 +8724 +8725 +8726 +8727 +8728 +8729 +8730 +8731 +8732 +8733 +8734 +8735 +8736 +8737 +8738 +8739 +8740 +8741 +8742 +8743 +8744 +8745 +8746 +8747 +8748 +8749 +8750 +8751 +8752 +8753 +8754 +8755 +8756 +8757 +8758 +8759 +8760 +8761 +8762 +8763 +8764 +8765 +8766 +8767 +8768 +8769 +8770 +8771 +8772 +8773 +8774 +8775 +8776 +8777 +8778 +8779 +8780 +8781 +8782 +8783 +8784 +8785 +8786 +8787 +8788 +8789 +8790 +8791 +8792 +8793 +8794 +8795 +8796 +8797 +8798 +8799 +8800 +8801 +8802 +8803 +8804 +8805 +8806 +8807 +8808 +8809 +8810 +8811 +8812 +8813 +8814 +8815 +8816 +8817 +8818 +8819 +8820 +8821 +8822 +8823 +8824 +8825 +8826 +8827 +8828 +8829 +8830 +8831 +8832 +8833 +8834 +8835 +8836 +8837 +8838 +8839 +8840 +8841 +8842 +8843 +8844 +8845 +8846 +8847 +8848 +8849 +8850 +8851 +8852 +8853 +8854 +8855 +8856 +8857 +8858 +8859 +8860 +8861 +8862 +8863 +8864 +8865 +8866 +8867 +8868 +8869 +8870 +8871 +8872 +8873 +8874 +8875 +8876 +8877 +8878 +8879 +8880 +8881 +8882 +8883 +8884 +8885 +8886 +8887 +8888 +8889 +8890 +8891 +8892 +8893 +8894 +8895 +8896 +8897 +8898 +8899 +8900 +8901 +8902 +8903 +8904 +8905 +8906 +8907 +8908 +8909 +8910 +8911 +8912 +8913 +8914 +8915 +8916 +8917 +8918 +8919 +8920 +8921 +8922 +8923 +8924 +8925 +8926 +8927 +8928 +8929 +8930 +8931 +8932 +8933 +8934 +8935 +8936 +8937 +8938 +8939 +8940 +8941 +8942 +8943 +8944 +8945 +8946 +8947 +8948 +8949 +8950 +8951 +8952 +8953 +8954 +8955 +8956 +8957 +8958 +8959 +8960 +8961 +8962 +8963 +8964 +8965 +8966 +8967 +8968 +8969 +8970 +8971 +8972 +8973 +8974 +8975 +8976 +8977 +8978 +8979 +8980 +8981 +8982 +8983 +8984 +8985 +8986 +8987 +8988 +8989 +8990 +8991 +8992 +8993 +8994 +8995 +8996 +8997 +8998 +8999 +9000 +9001 +9002 +9003 +9004 +9005 +9006 +9007 +9008 +9009 +9010 +9011 +9012 +9013 +9014 +9015 +9016 +9017 +9018 +9019 +9020 +9021 +9022 +9023 +9024 +9025 +9026 +9027 +9028 +9029 +9030 +9031 +9032 +9033 +9034 +9035 +9036 +9037 +9038 +9039 +9040 +9041 +9042 +9043 +9044 +9045 +9046 +9047 +9048 +9049 +9050 +9051 +9052 +9053 +9054 +9055 +9056 +9057 +9058 +9059 +9060 +9061 +9062 +9063 +9064 +9065 +9066 +9067 +9068 +9069 +9070 +9071 +9072 +9073 +9074 +9075 +9076 +9077 +9078 +9079 +9080 +9081 +9082 +9083 +9084 +9085 +9086 +9087 +9088 +9089 +9090 +9091 +9092 +9093 +9094 +9095 +9096 +9097 +9098 +9099 +9100 +9101 +9102 +9103 +9104 +9105 +9106 +9107 +9108 +9109 +9110 +9111 +9112 +9113 +9114 +9115 +9116 +9117 +9118 +9119 +9120 +9121 +9122 +9123 +9124 +9125 +9126 +9127 +9128 +9129 +9130 +9131 +9132 +9133 +9134 +9135 +9136 +9137 +9138 +9139 +9140 +9141 +9142 +9143 +9144 +9145 +9146 +9147 +9148 +9149 +9150 +9151 +9152 +9153 +9154 +9155 +9156 +9157 +9158 +9159 +9160 +9161 +9162 +9163 +9164 +9165 +9166 +9167 +9168 +9169 +9170 +9171 +9172 +9173 +9174 +9175 +9176 +9177 +9178 +9179 +9180 +9181 +9182 +9183 +9184 +9185 +9186 +9187 +9188 +9189 +9190 +9191 +9192 +9193 +9194 +9195 +9196 +9197 +9198 +9199 +9200 +9201 +9202 +9203 +9204 +9205 +9206 +9207 +9208 +9209 +9210 +9211 +9212 +9213 +9214 +9215 +9216 +9217 +9218 +9219 +9220 +9221 +9222 +9223 +9224 +9225 +9226 +9227 +9228 +9229 +9230 +9231 +9232 +9233 +9234 +9235 +9236 +9237 +9238 +9239 +9240 +9241 +9242 +9243 +9244 +9245 +9246 +9247 +9248 +9249 +9250 +9251 +9252 +9253 +9254 +9255 +9256 +9257 +9258 +9259 +9260 +9261 +9262 +9263 +9264 +9265 +9266 +9267 +9268 +9269 +9270 +9271 +9272 +9273 +9274 +9275 +9276 +9277 +9278 +9279 +9280 +9281 +9282 +9283 +9284 +9285 +9286 +9287 +9288 +9289 +9290 +9291 +9292 +9293 +9294 +9295 +9296 +9297 +9298 +9299 +9300 +9301 +9302 +9303 +9304 +9305 +9306 +9307 +9308 +9309 +9310 +9311 +9312 +9313 +9314 +9315 +9316 +9317 +9318 +9319 +9320 +9321 +9322 +9323 +9324 +9325 +9326 +9327 +9328 +9329 +9330 +9331 +9332 +9333 +9334 +9335 +9336 +9337 +9338 +9339 +9340 +9341 +9342 +9343 +9344 +9345 +9346 +9347 +9348 +9349 +9350 +9351 +9352 +9353 +9354 +9355 +9356 +9357 +9358 +9359 +9360 +9361 +9362 +9363 +9364 +9365 +9366 +9367 +9368 +9369 +9370 +9371 +9372 +9373 +9374 +9375 +9376 +9377 +9378 +9379 +9380 +9381 +9382 +9383 +9384 +9385 +9386 +9387 +9388 +9389 +9390 +9391 +9392 +9393 +9394 +9395 +9396 +9397 +9398 +9399 +9400 +9401 +9402 +9403 +9404 +9405 +9406 +9407 +9408 +9409 +9410 +9411 +9412 +9413 +9414 +9415 +9416 +9417 +9418 +9419 +9420 +9421 +9422 +9423 +9424 +9425 +9426 +9427 +9428 +9429 +9430 +9431 +9432 +9433 +9434 +9435 +9436 +9437 +9438 +9439 +9440 +9441 +9442 +9443 +9444 +9445 +9446 +9447 +9448 +9449 +9450 +9451 +9452 +9453 +9454 +9455 +9456 +9457 +9458 +9459 +9460 +9461 +9462 +9463 +9464 +9465 +9466 +9467 +9468 +9469 +9470 +9471 +9472 +9473 +9474 +9475 +9476 +9477 +9478 +9479 +9480 +9481 +9482 +9483 +9484 +9485 +9486 +9487 +9488 +9489 +9490 +9491 +9492 +9493 +9494 +9495 +9496 +9497 +9498 +9499 +9500 +9501 +9502 +9503 +9504 +9505 +9506 +9507 +9508 +9509 +9510 +9511 +9512 +9513 +9514 +9515 +9516 +9517 +9518 +9519 +9520 +9521 +9522 +9523 +9524 +9525 +9526 +9527 +9528 +9529 +9530 +9531 +9532 +9533 +9534 +9535 +9536 +9537 +9538 +9539 +9540 +9541 +9542 +9543 +9544 +9545 +9546 +9547 +9548 +9549 +9550 +9551 +9552 +9553 +9554 +9555 +9556 +9557 +9558 +9559 +9560 +9561 +9562 +9563 +9564 +9565 +9566 +9567 +9568 +9569 +9570 +9571 +9572 +9573 +9574 +9575 +9576 +9577 +9578 +9579 +9580 +9581 +9582 +9583 +9584 +9585 +9586 +9587 +9588 +9589 +9590 +9591 +9592 +9593 +9594 +9595 +9596 +9597 +9598 +9599 +9600 +9601 +9602 +9603 +9604 +9605 +9606 +9607 +9608 +9609 +9610 +9611 +9612 +9613 +9614 +9615 +9616 +9617 +9618 +9619 +9620 +9621 +9622 +9623 +9624 +9625 +9626 +9627 +9628 +9629 +9630 +9631 +9632 +9633 +9634 +9635 +9636 +9637 +9638 +9639 +9640 +9641 +9642 +9643 +9644 +9645 +9646 +9647 +9648 +9649 +9650 +9651 +9652 +9653 +9654 +9655 +9656 +9657 +9658 +9659 +9660 +9661 +9662 +9663 +9664 +9665 +9666 +9667 +9668 +9669 +9670 +9671 +9672 +9673 +9674 +9675 +9676 +9677 +9678 +9679 +9680 +9681 +9682 +9683 +9684 +9685 +9686 +9687 +9688 +9689 +9690 +9691 +9692 +9693 +9694 +9695 +9696 +9697 +9698 +9699 +9700 +9701 +9702 +9703 +9704 +9705 +9706 +9707 +9708 +9709 +9710 +9711 +9712 +9713 +9714 +9715 +9716 +9717 +9718 +9719 +9720 +9721 +9722 +9723 +9724 +9725 +9726 +9727 +9728 +9729 +9730 +9731 +9732 +9733 +9734 +9735 +9736 +9737 +9738 +9739 +9740 +9741 +9742 +9743 +9744 +9745 +9746 +9747 +9748 +9749 +9750 +9751 +9752 +9753 +9754 +9755 +9756 +9757 +9758 +9759 +9760 +9761 +9762 +9763 +9764 +9765 +9766 +9767 +9768 +9769 +9770 +9771 +9772 +9773 +9774 +9775 +9776 +9777 +9778 +9779 +9780 +9781 +9782 +9783 +9784 +9785 +9786 +9787 +9788 +9789 +9790 +9791 +9792 +9793 +9794 +9795 +9796 +9797 +9798 +9799 +9800 +9801 +9802 +9803 +9804 +9805 +9806 +9807 +9808 +9809 +9810 +9811 +9812 +9813 +9814 +9815 +9816 +9817 +9818 +9819 +9820 +9821 +9822 +9823 +9824 +9825 +9826 +9827 +9828 +9829 +9830 +9831 +9832 +9833 +9834 +9835 +9836 +9837 +9838 +9839 +9840 +9841 +9842 +9843 +9844 +9845 +9846 +9847 +9848 +9849 +9850 +9851 +9852 +9853 +9854 +9855 +9856 +9857 +9858 +9859 +9860 +9861 +9862 +9863 +9864 +9865 +9866 +9867 +9868 +9869 +9870 +9871 +9872 +9873 +9874 +9875 +9876 +9877 +9878 +9879 +9880 +9881 +9882 +9883 +9884 +9885 +9886 +9887 +9888 +9889 +9890 +9891 +9892 +9893 +9894 +9895 +9896 +9897 +9898 +9899 +9900 +9901 +9902 +9903 +9904 +9905 +9906 +9907 +9908 +9909 +9910 +9911 +9912 +9913 +9914 +9915 +9916 +9917 +9918 +9919 +9920 +9921 +9922 +9923 +9924 +9925 +9926 +9927 +9928 +9929 +9930 +9931 +9932 +9933 +9934 +9935 +9936 +9937 +9938 +9939 +9940 +9941 +9942 +9943 +9944 +9945 +9946 +9947 +9948 +9949 +9950 +9951 +9952 +9953 +9954 +9955 +9956 +9957 +9958 +9959 +9960 +9961 +9962 +9963 +9964 +9965 +9966 +9967 +9968 +9969 +9970 +9971 +9972 +9973 +9974 +9975 +9976 +9977 +9978 +9979 +9980 +9981 +9982 +9983 +9984 +9985 +9986 +9987 +9988 +9989 +9990 +9991 +9992 +9993 +9994 +9995 +9996 +9997 +9998 +9999 diff --git a/core-java-jvm/README.md b/core-java-modules/core-java-jvm/README.md similarity index 100% rename from core-java-jvm/README.md rename to core-java-modules/core-java-jvm/README.md diff --git a/core-java-jvm/pom.xml b/core-java-modules/core-java-jvm/pom.xml similarity index 96% rename from core-java-jvm/pom.xml rename to core-java-modules/core-java-jvm/pom.xml index 752b26f03f..6c700cd005 100644 --- a/core-java-jvm/pom.xml +++ b/core-java-modules/core-java-jvm/pom.xml @@ -11,6 +11,7 @@ com.baeldung parent-modules 1.0.0-SNAPSHOT + ../../ diff --git a/core-java-jvm/src/main/java/com/baeldung/inlining/ConsecutiveNumbersSum.java b/core-java-modules/core-java-jvm/src/main/java/com/baeldung/inlining/ConsecutiveNumbersSum.java similarity index 100% rename from core-java-jvm/src/main/java/com/baeldung/inlining/ConsecutiveNumbersSum.java rename to core-java-modules/core-java-jvm/src/main/java/com/baeldung/inlining/ConsecutiveNumbersSum.java diff --git a/core-java-jvm/src/main/java/com/baeldung/inlining/InliningExample.java b/core-java-modules/core-java-jvm/src/main/java/com/baeldung/inlining/InliningExample.java similarity index 100% rename from core-java-jvm/src/main/java/com/baeldung/inlining/InliningExample.java rename to core-java-modules/core-java-jvm/src/main/java/com/baeldung/inlining/InliningExample.java diff --git a/core-java-jvm/src/test/java/com/baeldung/inlining/ConsecutiveNumbersSumUnitTest.java b/core-java-modules/core-java-jvm/src/test/java/com/baeldung/inlining/ConsecutiveNumbersSumUnitTest.java similarity index 100% rename from core-java-jvm/src/test/java/com/baeldung/inlining/ConsecutiveNumbersSumUnitTest.java rename to core-java-modules/core-java-jvm/src/test/java/com/baeldung/inlining/ConsecutiveNumbersSumUnitTest.java diff --git a/core-java-lambdas/pom.xml b/core-java-modules/core-java-lambdas/pom.xml similarity index 91% rename from core-java-lambdas/pom.xml rename to core-java-modules/core-java-lambdas/pom.xml index 25538a3524..d6158c2946 100644 --- a/core-java-lambdas/pom.xml +++ b/core-java-modules/core-java-lambdas/pom.xml @@ -12,7 +12,7 @@ com.baeldung parent-java 0.0.1-SNAPSHOT - ../parent-java + ../../parent-java diff --git a/core-java-lambdas/src/main/java/com/baeldung/lambdas/LambdaVariables.java b/core-java-modules/core-java-lambdas/src/main/java/com/baeldung/lambdas/LambdaVariables.java similarity index 100% rename from core-java-lambdas/src/main/java/com/baeldung/lambdas/LambdaVariables.java rename to core-java-modules/core-java-lambdas/src/main/java/com/baeldung/lambdas/LambdaVariables.java diff --git a/core-java-lang-oop-2/.gitignore b/core-java-modules/core-java-lang-oop-2/.gitignore similarity index 100% rename from core-java-lang-oop-2/.gitignore rename to core-java-modules/core-java-lang-oop-2/.gitignore diff --git a/core-java-lang-oop-2/README.md b/core-java-modules/core-java-lang-oop-2/README.md similarity index 100% rename from core-java-lang-oop-2/README.md rename to core-java-modules/core-java-lang-oop-2/README.md diff --git a/core-java-lang-oop-2/pom.xml b/core-java-modules/core-java-lang-oop-2/pom.xml similarity index 94% rename from core-java-lang-oop-2/pom.xml rename to core-java-modules/core-java-lang-oop-2/pom.xml index 3faf9fe6ee..669a37b0f5 100644 --- a/core-java-lang-oop-2/pom.xml +++ b/core-java-modules/core-java-lang-oop-2/pom.xml @@ -11,7 +11,7 @@ com.baeldung parent-java 0.0.1-SNAPSHOT - ../parent-java + ../../parent-java diff --git a/core-java-lang-oop-2/src/main/java/com/baeldung/anonymous/Book.java b/core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/anonymous/Book.java similarity index 100% rename from core-java-lang-oop-2/src/main/java/com/baeldung/anonymous/Book.java rename to core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/anonymous/Book.java diff --git a/core-java-lang-oop-2/src/main/java/com/baeldung/anonymous/Main.java b/core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/anonymous/Main.java similarity index 100% rename from core-java-lang-oop-2/src/main/java/com/baeldung/anonymous/Main.java rename to core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/anonymous/Main.java diff --git a/core-java-lang-oop-2/src/main/java/com/baeldung/generics/Entry.java b/core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/generics/Entry.java similarity index 100% rename from core-java-lang-oop-2/src/main/java/com/baeldung/generics/Entry.java rename to core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/generics/Entry.java diff --git a/core-java-lang-oop-2/src/main/java/com/baeldung/generics/GenericEntry.java b/core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/generics/GenericEntry.java similarity index 100% rename from core-java-lang-oop-2/src/main/java/com/baeldung/generics/GenericEntry.java rename to core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/generics/GenericEntry.java diff --git a/core-java-lang-oop-2/src/main/java/com/baeldung/generics/MapEntry.java b/core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/generics/MapEntry.java similarity index 100% rename from core-java-lang-oop-2/src/main/java/com/baeldung/generics/MapEntry.java rename to core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/generics/MapEntry.java diff --git a/core-java-lang-oop-2/src/main/java/com/baeldung/generics/Product.java b/core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/generics/Product.java similarity index 100% rename from core-java-lang-oop-2/src/main/java/com/baeldung/generics/Product.java rename to core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/generics/Product.java diff --git a/core-java-lang-oop-2/src/main/java/com/baeldung/generics/Rankable.java b/core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/generics/Rankable.java similarity index 100% rename from core-java-lang-oop-2/src/main/java/com/baeldung/generics/Rankable.java rename to core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/generics/Rankable.java diff --git a/core-java-lang-oop-2/src/main/java/com/baeldung/supertypecompilerexception/MyClass.java b/core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/supertypecompilerexception/MyClass.java similarity index 100% rename from core-java-lang-oop-2/src/main/java/com/baeldung/supertypecompilerexception/MyClass.java rename to core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/supertypecompilerexception/MyClass.java diff --git a/core-java-lang-oop-2/src/main/java/com/baeldung/supertypecompilerexception/MyClassSolution1.java b/core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/supertypecompilerexception/MyClassSolution1.java similarity index 100% rename from core-java-lang-oop-2/src/main/java/com/baeldung/supertypecompilerexception/MyClassSolution1.java rename to core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/supertypecompilerexception/MyClassSolution1.java diff --git a/core-java-lang-oop-2/src/main/java/com/baeldung/supertypecompilerexception/MyClassSolution2.java b/core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/supertypecompilerexception/MyClassSolution2.java similarity index 100% rename from core-java-lang-oop-2/src/main/java/com/baeldung/supertypecompilerexception/MyClassSolution2.java rename to core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/supertypecompilerexception/MyClassSolution2.java diff --git a/core-java-lang-oop-2/src/main/java/com/baeldung/supertypecompilerexception/MyClassSolution3.java b/core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/supertypecompilerexception/MyClassSolution3.java similarity index 100% rename from core-java-lang-oop-2/src/main/java/com/baeldung/supertypecompilerexception/MyClassSolution3.java rename to core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/supertypecompilerexception/MyClassSolution3.java diff --git a/core-java-lang-oop-2/src/main/java/com/baeldung/supertypecompilerexception/MyException.java b/core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/supertypecompilerexception/MyException.java similarity index 100% rename from core-java-lang-oop-2/src/main/java/com/baeldung/supertypecompilerexception/MyException.java rename to core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/supertypecompilerexception/MyException.java diff --git a/core-java-lang-oop-2/src/test/java/com/baeldung/generics/GenericConstructorUnitTest.java b/core-java-modules/core-java-lang-oop-2/src/test/java/com/baeldung/generics/GenericConstructorUnitTest.java similarity index 100% rename from core-java-lang-oop-2/src/test/java/com/baeldung/generics/GenericConstructorUnitTest.java rename to core-java-modules/core-java-lang-oop-2/src/test/java/com/baeldung/generics/GenericConstructorUnitTest.java diff --git a/core-java-lang-oop/.gitignore b/core-java-modules/core-java-lang-oop/.gitignore similarity index 100% rename from core-java-lang-oop/.gitignore rename to core-java-modules/core-java-lang-oop/.gitignore diff --git a/core-java-lang-oop/README.md b/core-java-modules/core-java-lang-oop/README.md similarity index 100% rename from core-java-lang-oop/README.md rename to core-java-modules/core-java-lang-oop/README.md diff --git a/core-java-lang-oop/pom.xml b/core-java-modules/core-java-lang-oop/pom.xml similarity index 98% rename from core-java-lang-oop/pom.xml rename to core-java-modules/core-java-lang-oop/pom.xml index 6763bbb26d..c9bb3b3e5a 100644 --- a/core-java-lang-oop/pom.xml +++ b/core-java-modules/core-java-lang-oop/pom.xml @@ -11,7 +11,7 @@ com.baeldung parent-java 0.0.1-SNAPSHOT - ../parent-java + ../../parent-java diff --git a/core-java-lang-oop/src/main/java/com/baeldung/accessmodifiers/Public.java b/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/accessmodifiers/Public.java similarity index 100% rename from core-java-lang-oop/src/main/java/com/baeldung/accessmodifiers/Public.java rename to core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/accessmodifiers/Public.java diff --git a/core-java-lang-oop/src/main/java/com/baeldung/accessmodifiers/SubClass.java b/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/accessmodifiers/SubClass.java similarity index 100% rename from core-java-lang-oop/src/main/java/com/baeldung/accessmodifiers/SubClass.java rename to core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/accessmodifiers/SubClass.java diff --git a/core-java-lang-oop/src/main/java/com/baeldung/accessmodifiers/SuperPublic.java b/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/accessmodifiers/SuperPublic.java similarity index 100% rename from core-java-lang-oop/src/main/java/com/baeldung/accessmodifiers/SuperPublic.java rename to core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/accessmodifiers/SuperPublic.java diff --git a/core-java-lang-oop/src/main/java/com/baeldung/accessmodifiers/another/AnotherPublic.java b/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/accessmodifiers/another/AnotherPublic.java similarity index 100% rename from core-java-lang-oop/src/main/java/com/baeldung/accessmodifiers/another/AnotherPublic.java rename to core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/accessmodifiers/another/AnotherPublic.java diff --git a/core-java-lang-oop/src/main/java/com/baeldung/accessmodifiers/another/AnotherSubClass.java b/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/accessmodifiers/another/AnotherSubClass.java similarity index 100% rename from core-java-lang-oop/src/main/java/com/baeldung/accessmodifiers/another/AnotherSubClass.java rename to core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/accessmodifiers/another/AnotherSubClass.java diff --git a/core-java-lang-oop/src/main/java/com/baeldung/accessmodifiers/another/AnotherSuperPublic.java b/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/accessmodifiers/another/AnotherSuperPublic.java similarity index 100% rename from core-java-lang-oop/src/main/java/com/baeldung/accessmodifiers/another/AnotherSuperPublic.java rename to core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/accessmodifiers/another/AnotherSuperPublic.java diff --git a/core-java-lang-oop/src/main/java/com/baeldung/casting/Animal.java b/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/casting/Animal.java similarity index 100% rename from core-java-lang-oop/src/main/java/com/baeldung/casting/Animal.java rename to core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/casting/Animal.java diff --git a/core-java-lang-oop/src/main/java/com/baeldung/casting/AnimalFeeder.java b/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/casting/AnimalFeeder.java similarity index 100% rename from core-java-lang-oop/src/main/java/com/baeldung/casting/AnimalFeeder.java rename to core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/casting/AnimalFeeder.java diff --git a/core-java-lang-oop/src/main/java/com/baeldung/casting/AnimalFeederGeneric.java b/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/casting/AnimalFeederGeneric.java similarity index 100% rename from core-java-lang-oop/src/main/java/com/baeldung/casting/AnimalFeederGeneric.java rename to core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/casting/AnimalFeederGeneric.java diff --git a/core-java-lang-oop/src/main/java/com/baeldung/casting/Cat.java b/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/casting/Cat.java similarity index 100% rename from core-java-lang-oop/src/main/java/com/baeldung/casting/Cat.java rename to core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/casting/Cat.java diff --git a/core-java-lang-oop/src/main/java/com/baeldung/casting/Dog.java b/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/casting/Dog.java similarity index 100% rename from core-java-lang-oop/src/main/java/com/baeldung/casting/Dog.java rename to core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/casting/Dog.java diff --git a/core-java-lang-oop/src/main/java/com/baeldung/casting/Mew.java b/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/casting/Mew.java similarity index 100% rename from core-java-lang-oop/src/main/java/com/baeldung/casting/Mew.java rename to core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/casting/Mew.java diff --git a/core-java-lang-oop/src/main/java/com/baeldung/constructors/BankAccount.java b/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/constructors/BankAccount.java similarity index 100% rename from core-java-lang-oop/src/main/java/com/baeldung/constructors/BankAccount.java rename to core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/constructors/BankAccount.java diff --git a/core-java-lang-oop/src/main/java/com/baeldung/constructors/Transaction.java b/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/constructors/Transaction.java similarity index 100% rename from core-java-lang-oop/src/main/java/com/baeldung/constructors/Transaction.java rename to core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/constructors/Transaction.java diff --git a/core-java-lang-oop/src/main/java/com/baeldung/deepcopy/Address.java b/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/deepcopy/Address.java similarity index 100% rename from core-java-lang-oop/src/main/java/com/baeldung/deepcopy/Address.java rename to core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/deepcopy/Address.java diff --git a/core-java-lang-oop/src/main/java/com/baeldung/deepcopy/User.java b/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/deepcopy/User.java similarity index 100% rename from core-java-lang-oop/src/main/java/com/baeldung/deepcopy/User.java rename to core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/deepcopy/User.java diff --git a/core-java-lang-oop/src/main/java/com/baeldung/equalshashcode/Money.java b/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/equalshashcode/Money.java similarity index 100% rename from core-java-lang-oop/src/main/java/com/baeldung/equalshashcode/Money.java rename to core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/equalshashcode/Money.java diff --git a/core-java-lang-oop/src/main/java/com/baeldung/equalshashcode/Team.java b/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/equalshashcode/Team.java similarity index 100% rename from core-java-lang-oop/src/main/java/com/baeldung/equalshashcode/Team.java rename to core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/equalshashcode/Team.java diff --git a/core-java-lang-oop/src/main/java/com/baeldung/equalshashcode/Voucher.java b/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/equalshashcode/Voucher.java similarity index 100% rename from core-java-lang-oop/src/main/java/com/baeldung/equalshashcode/Voucher.java rename to core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/equalshashcode/Voucher.java diff --git a/core-java-lang-oop/src/main/java/com/baeldung/equalshashcode/WrongTeam.java b/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/equalshashcode/WrongTeam.java similarity index 100% rename from core-java-lang-oop/src/main/java/com/baeldung/equalshashcode/WrongTeam.java rename to core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/equalshashcode/WrongTeam.java diff --git a/core-java-lang-oop/src/main/java/com/baeldung/equalshashcode/WrongVoucher.java b/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/equalshashcode/WrongVoucher.java similarity index 100% rename from core-java-lang-oop/src/main/java/com/baeldung/equalshashcode/WrongVoucher.java rename to core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/equalshashcode/WrongVoucher.java diff --git a/core-java-lang-oop/src/main/java/com/baeldung/equalshashcode/entities/ComplexClass.java b/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/equalshashcode/entities/ComplexClass.java similarity index 100% rename from core-java-lang-oop/src/main/java/com/baeldung/equalshashcode/entities/ComplexClass.java rename to core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/equalshashcode/entities/ComplexClass.java diff --git a/core-java-lang-oop/src/main/java/com/baeldung/equalshashcode/entities/PrimitiveClass.java b/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/equalshashcode/entities/PrimitiveClass.java similarity index 100% rename from core-java-lang-oop/src/main/java/com/baeldung/equalshashcode/entities/PrimitiveClass.java rename to core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/equalshashcode/entities/PrimitiveClass.java diff --git a/core-java-lang-oop/src/main/java/com/baeldung/equalshashcode/entities/Rectangle.java b/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/equalshashcode/entities/Rectangle.java similarity index 100% rename from core-java-lang-oop/src/main/java/com/baeldung/equalshashcode/entities/Rectangle.java rename to core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/equalshashcode/entities/Rectangle.java diff --git a/core-java-lang-oop/src/main/java/com/baeldung/equalshashcode/entities/Shape.java b/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/equalshashcode/entities/Shape.java similarity index 100% rename from core-java-lang-oop/src/main/java/com/baeldung/equalshashcode/entities/Shape.java rename to core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/equalshashcode/entities/Shape.java diff --git a/core-java-lang-oop/src/main/java/com/baeldung/equalshashcode/entities/Square.java b/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/equalshashcode/entities/Square.java similarity index 100% rename from core-java-lang-oop/src/main/java/com/baeldung/equalshashcode/entities/Square.java rename to core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/equalshashcode/entities/Square.java diff --git a/core-java-lang-oop/src/main/java/com/baeldung/finalkeyword/BlackCat.java b/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/finalkeyword/BlackCat.java similarity index 100% rename from core-java-lang-oop/src/main/java/com/baeldung/finalkeyword/BlackCat.java rename to core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/finalkeyword/BlackCat.java diff --git a/core-java-lang-oop/src/main/java/com/baeldung/finalkeyword/BlackDog.java b/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/finalkeyword/BlackDog.java similarity index 100% rename from core-java-lang-oop/src/main/java/com/baeldung/finalkeyword/BlackDog.java rename to core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/finalkeyword/BlackDog.java diff --git a/core-java-lang-oop/src/main/java/com/baeldung/finalkeyword/Cat.java b/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/finalkeyword/Cat.java similarity index 100% rename from core-java-lang-oop/src/main/java/com/baeldung/finalkeyword/Cat.java rename to core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/finalkeyword/Cat.java diff --git a/core-java-lang-oop/src/main/java/com/baeldung/finalkeyword/Dog.java b/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/finalkeyword/Dog.java similarity index 100% rename from core-java-lang-oop/src/main/java/com/baeldung/finalkeyword/Dog.java rename to core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/finalkeyword/Dog.java diff --git a/core-java-lang-oop/src/main/java/com/baeldung/hashcode/entities/User.java b/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/hashcode/entities/User.java similarity index 100% rename from core-java-lang-oop/src/main/java/com/baeldung/hashcode/entities/User.java rename to core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/hashcode/entities/User.java diff --git a/core-java-lang-oop/src/main/java/com/baeldung/immutableobjects/Currency.java b/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/immutableobjects/Currency.java similarity index 100% rename from core-java-lang-oop/src/main/java/com/baeldung/immutableobjects/Currency.java rename to core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/immutableobjects/Currency.java diff --git a/core-java-lang-oop/src/main/java/com/baeldung/immutableobjects/Money.java b/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/immutableobjects/Money.java similarity index 100% rename from core-java-lang-oop/src/main/java/com/baeldung/immutableobjects/Money.java rename to core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/immutableobjects/Money.java diff --git a/core-java-lang-oop/src/main/java/com/baeldung/inheritance/ArmoredCar.java b/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/inheritance/ArmoredCar.java similarity index 96% rename from core-java-lang-oop/src/main/java/com/baeldung/inheritance/ArmoredCar.java rename to core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/inheritance/ArmoredCar.java index b6bb5181b8..ad654ba31a 100644 --- a/core-java-lang-oop/src/main/java/com/baeldung/inheritance/ArmoredCar.java +++ b/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/inheritance/ArmoredCar.java @@ -1,43 +1,43 @@ -package com.baeldung.inheritance; - -public class ArmoredCar extends Car implements Floatable, Flyable{ - private int bulletProofWindows; - private String model; - - public void remoteStartCar() { - // this vehicle can be started by using a remote control - } - - public String registerModel() { - return model; - } - - public String getAValue() { - return super.model; // returns value of model defined in base class Car - // return this.model; // will return value of model defined in ArmoredCar - // return model; // will return value of model defined in ArmoredCar - } - - public static String msg() { - // return super.msg(); // this won't compile. - return "ArmoredCar"; - } - - @Override - public void floatOnWater() { - System.out.println("I can float!"); - } - - @Override - public void fly() { - System.out.println("I can fly!"); - } - - public void aMethod() { - // System.out.println(duration); // Won't compile - System.out.println(Floatable.duration); // outputs 10 - System.out.println(Flyable.duration); // outputs 20 - } - - -} +package com.baeldung.inheritance; + +public class ArmoredCar extends Car implements Floatable, Flyable{ + private int bulletProofWindows; + private String model; + + public void remoteStartCar() { + // this vehicle can be started by using a remote control + } + + public String registerModel() { + return model; + } + + public String getAValue() { + return super.model; // returns value of model defined in base class Car + // return this.model; // will return value of model defined in ArmoredCar + // return model; // will return value of model defined in ArmoredCar + } + + public static String msg() { + // return super.msg(); // this won't compile. + return "ArmoredCar"; + } + + @Override + public void floatOnWater() { + System.out.println("I can float!"); + } + + @Override + public void fly() { + System.out.println("I can fly!"); + } + + public void aMethod() { + // System.out.println(duration); // Won't compile + System.out.println(Floatable.duration); // outputs 10 + System.out.println(Flyable.duration); // outputs 20 + } + + +} diff --git a/core-java-lang-oop/src/main/java/com/baeldung/inheritance/BMW.java b/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/inheritance/BMW.java similarity index 93% rename from core-java-lang-oop/src/main/java/com/baeldung/inheritance/BMW.java rename to core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/inheritance/BMW.java index 8ad3bb683f..8eb6198203 100644 --- a/core-java-lang-oop/src/main/java/com/baeldung/inheritance/BMW.java +++ b/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/inheritance/BMW.java @@ -1,12 +1,12 @@ -package com.baeldung.inheritance; - -public class BMW extends Car { - public BMW() { - super(5, "BMW"); - } - - @Override - public String toString() { - return model; - } -} +package com.baeldung.inheritance; + +public class BMW extends Car { + public BMW() { + super(5, "BMW"); + } + + @Override + public String toString() { + return model; + } +} diff --git a/core-java-lang-oop/src/main/java/com/baeldung/inheritance/Car.java b/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/inheritance/Car.java similarity index 95% rename from core-java-lang-oop/src/main/java/com/baeldung/inheritance/Car.java rename to core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/inheritance/Car.java index 21ea9ea569..ddb06dcf08 100644 --- a/core-java-lang-oop/src/main/java/com/baeldung/inheritance/Car.java +++ b/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/inheritance/Car.java @@ -1,32 +1,32 @@ -package com.baeldung.inheritance; - -public class Car { - private final int DEFAULT_WHEEL_COUNT = 5; - private final String DEFAULT_MODEL = "Basic"; - - protected int wheels; - protected String model; - - public Car() { - this.wheels = DEFAULT_WHEEL_COUNT; - this.model = DEFAULT_MODEL; - } - - public Car(int wheels, String model) { - this.wheels = wheels; - this.model = model; - } - - public void start() { - // Check essential parts - // If okay, start. - } - public static int count = 10; - public static String msg() { - return "Car"; - } - - public String toString() { - return model; - } +package com.baeldung.inheritance; + +public class Car { + private final int DEFAULT_WHEEL_COUNT = 5; + private final String DEFAULT_MODEL = "Basic"; + + protected int wheels; + protected String model; + + public Car() { + this.wheels = DEFAULT_WHEEL_COUNT; + this.model = DEFAULT_MODEL; + } + + public Car(int wheels, String model) { + this.wheels = wheels; + this.model = model; + } + + public void start() { + // Check essential parts + // If okay, start. + } + public static int count = 10; + public static String msg() { + return "Car"; + } + + public String toString() { + return model; + } } \ No newline at end of file diff --git a/core-java-lang-oop/src/main/java/com/baeldung/inheritance/Employee.java b/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/inheritance/Employee.java similarity index 94% rename from core-java-lang-oop/src/main/java/com/baeldung/inheritance/Employee.java rename to core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/inheritance/Employee.java index 599a1d7331..9018382087 100644 --- a/core-java-lang-oop/src/main/java/com/baeldung/inheritance/Employee.java +++ b/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/inheritance/Employee.java @@ -1,15 +1,15 @@ -package com.baeldung.inheritance; - -public class Employee { - private String name; - private Car car; - - public Employee(String name, Car car) { - this.name = name; - this.car = car; - } - - public Car getCar() { - return car; - } +package com.baeldung.inheritance; + +public class Employee { + private String name; + private Car car; + + public Employee(String name, Car car) { + this.name = name; + this.car = car; + } + + public Car getCar() { + return car; + } } \ No newline at end of file diff --git a/core-java-lang-oop/src/main/java/com/baeldung/inheritance/Floatable.java b/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/inheritance/Floatable.java similarity index 95% rename from core-java-lang-oop/src/main/java/com/baeldung/inheritance/Floatable.java rename to core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/inheritance/Floatable.java index c0b456dffb..b90163487a 100644 --- a/core-java-lang-oop/src/main/java/com/baeldung/inheritance/Floatable.java +++ b/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/inheritance/Floatable.java @@ -1,10 +1,10 @@ -package com.baeldung.inheritance; - -public interface Floatable { - int duration = 10; - void floatOnWater(); - - default void repair() { - System.out.println("Repairing Floatable object"); - } -} +package com.baeldung.inheritance; + +public interface Floatable { + int duration = 10; + void floatOnWater(); + + default void repair() { + System.out.println("Repairing Floatable object"); + } +} diff --git a/core-java-lang-oop/src/main/java/com/baeldung/inheritance/Flyable.java b/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/inheritance/Flyable.java similarity index 94% rename from core-java-lang-oop/src/main/java/com/baeldung/inheritance/Flyable.java rename to core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/inheritance/Flyable.java index cb8244cf5b..a25ce6f91b 100644 --- a/core-java-lang-oop/src/main/java/com/baeldung/inheritance/Flyable.java +++ b/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/inheritance/Flyable.java @@ -1,13 +1,13 @@ -package com.baeldung.inheritance; - -public interface Flyable { - int duration = 10; - void fly(); - - /* - * Commented - */ - //default void repair() { - // System.out.println("Repairing Flyable object"); - //} -} +package com.baeldung.inheritance; + +public interface Flyable { + int duration = 10; + void fly(); + + /* + * Commented + */ + //default void repair() { + // System.out.println("Repairing Flyable object"); + //} +} diff --git a/core-java-lang-oop/src/main/java/com/baeldung/inheritance/SpaceCar.java b/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/inheritance/SpaceCar.java similarity index 95% rename from core-java-lang-oop/src/main/java/com/baeldung/inheritance/SpaceCar.java rename to core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/inheritance/SpaceCar.java index 8c23b26da9..76a44411db 100644 --- a/core-java-lang-oop/src/main/java/com/baeldung/inheritance/SpaceCar.java +++ b/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/inheritance/SpaceCar.java @@ -1,18 +1,18 @@ -package com.baeldung.inheritance; - -public class SpaceCar extends Car implements SpaceTraveller { - @Override - public void floatOnWater() { - System.out.println("SpaceCar floating!"); - } - - @Override - public void fly() { - System.out.println("SpaceCar flying!"); - } - - @Override - public void remoteControl() { - System.out.println("SpaceCar being controlled remotely!"); - } -} +package com.baeldung.inheritance; + +public class SpaceCar extends Car implements SpaceTraveller { + @Override + public void floatOnWater() { + System.out.println("SpaceCar floating!"); + } + + @Override + public void fly() { + System.out.println("SpaceCar flying!"); + } + + @Override + public void remoteControl() { + System.out.println("SpaceCar being controlled remotely!"); + } +} diff --git a/core-java-lang-oop/src/main/java/com/baeldung/inheritance/SpaceTraveller.java b/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/inheritance/SpaceTraveller.java similarity index 96% rename from core-java-lang-oop/src/main/java/com/baeldung/inheritance/SpaceTraveller.java rename to core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/inheritance/SpaceTraveller.java index 9b66441791..3a473af093 100644 --- a/core-java-lang-oop/src/main/java/com/baeldung/inheritance/SpaceTraveller.java +++ b/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/inheritance/SpaceTraveller.java @@ -1,6 +1,6 @@ -package com.baeldung.inheritance; - -public interface SpaceTraveller extends Floatable, Flyable { - int duration = 10; - void remoteControl(); +package com.baeldung.inheritance; + +public interface SpaceTraveller extends Floatable, Flyable { + int duration = 10; + void remoteControl(); } \ No newline at end of file diff --git a/core-java-lang-oop/src/main/java/com/baeldung/inheritancecomposition/application/Application.java b/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/inheritancecomposition/application/Application.java similarity index 100% rename from core-java-lang-oop/src/main/java/com/baeldung/inheritancecomposition/application/Application.java rename to core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/inheritancecomposition/application/Application.java diff --git a/core-java-lang-oop/src/main/java/com/baeldung/inheritancecomposition/model/Actress.java b/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/inheritancecomposition/model/Actress.java similarity index 100% rename from core-java-lang-oop/src/main/java/com/baeldung/inheritancecomposition/model/Actress.java rename to core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/inheritancecomposition/model/Actress.java diff --git a/core-java-lang-oop/src/main/java/com/baeldung/inheritancecomposition/model/Computer.java b/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/inheritancecomposition/model/Computer.java similarity index 100% rename from core-java-lang-oop/src/main/java/com/baeldung/inheritancecomposition/model/Computer.java rename to core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/inheritancecomposition/model/Computer.java diff --git a/core-java-lang-oop/src/main/java/com/baeldung/inheritancecomposition/model/Memory.java b/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/inheritancecomposition/model/Memory.java similarity index 100% rename from core-java-lang-oop/src/main/java/com/baeldung/inheritancecomposition/model/Memory.java rename to core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/inheritancecomposition/model/Memory.java diff --git a/core-java-lang-oop/src/main/java/com/baeldung/inheritancecomposition/model/Person.java b/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/inheritancecomposition/model/Person.java similarity index 100% rename from core-java-lang-oop/src/main/java/com/baeldung/inheritancecomposition/model/Person.java rename to core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/inheritancecomposition/model/Person.java diff --git a/core-java-lang-oop/src/main/java/com/baeldung/inheritancecomposition/model/Processor.java b/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/inheritancecomposition/model/Processor.java similarity index 100% rename from core-java-lang-oop/src/main/java/com/baeldung/inheritancecomposition/model/Processor.java rename to core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/inheritancecomposition/model/Processor.java diff --git a/core-java-lang-oop/src/main/java/com/baeldung/inheritancecomposition/model/SoundCard.java b/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/inheritancecomposition/model/SoundCard.java similarity index 100% rename from core-java-lang-oop/src/main/java/com/baeldung/inheritancecomposition/model/SoundCard.java rename to core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/inheritancecomposition/model/SoundCard.java diff --git a/core-java-lang-oop/src/main/java/com/baeldung/inheritancecomposition/model/StandardMemory.java b/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/inheritancecomposition/model/StandardMemory.java similarity index 100% rename from core-java-lang-oop/src/main/java/com/baeldung/inheritancecomposition/model/StandardMemory.java rename to core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/inheritancecomposition/model/StandardMemory.java diff --git a/core-java-lang-oop/src/main/java/com/baeldung/inheritancecomposition/model/StandardProcessor.java b/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/inheritancecomposition/model/StandardProcessor.java similarity index 100% rename from core-java-lang-oop/src/main/java/com/baeldung/inheritancecomposition/model/StandardProcessor.java rename to core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/inheritancecomposition/model/StandardProcessor.java diff --git a/core-java-lang-oop/src/main/java/com/baeldung/inheritancecomposition/model/StandardSoundCard.java b/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/inheritancecomposition/model/StandardSoundCard.java similarity index 100% rename from core-java-lang-oop/src/main/java/com/baeldung/inheritancecomposition/model/StandardSoundCard.java rename to core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/inheritancecomposition/model/StandardSoundCard.java diff --git a/core-java-lang-oop/src/main/java/com/baeldung/inheritancecomposition/model/Waitress.java b/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/inheritancecomposition/model/Waitress.java similarity index 100% rename from core-java-lang-oop/src/main/java/com/baeldung/inheritancecomposition/model/Waitress.java rename to core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/inheritancecomposition/model/Waitress.java diff --git a/core-java-lang-syntax/src/main/java/com/baeldung/initializationguide/User.java b/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/initializationguide/User.java similarity index 94% rename from core-java-lang-syntax/src/main/java/com/baeldung/initializationguide/User.java rename to core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/initializationguide/User.java index e2e3f051dd..1d9a872d69 100644 --- a/core-java-lang-syntax/src/main/java/com/baeldung/initializationguide/User.java +++ b/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/initializationguide/User.java @@ -1,53 +1,53 @@ -package com.baeldung.initializationguide; - -import java.io.Serializable; - -public class User implements Serializable, Cloneable { - private static final long serialVersionUID = 1L; - static String forum; - private String name; - private int id; - - { - id = 0; - System.out.println("Instance Initializer"); - } - - static { - forum = "Java"; - System.out.println("Static Initializer"); - } - - public User(String name, int id) { - super(); - this.name = name; - this.id = id; - } - - public User() { - System.out.println("Constructor"); - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public int getId() { - return id; - } - - public void setId(int id) { - this.id = id; - } - - @Override - protected Object clone() throws CloneNotSupportedException { - return this; - } - -} - +package com.baeldung.initializationguide; + +import java.io.Serializable; + +public class User implements Serializable, Cloneable { + private static final long serialVersionUID = 1L; + static String forum; + private String name; + private int id; + + { + id = 0; + System.out.println("Instance Initializer"); + } + + static { + forum = "Java"; + System.out.println("Static Initializer"); + } + + public User(String name, int id) { + super(); + this.name = name; + this.id = id; + } + + public User() { + System.out.println("Constructor"); + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + @Override + protected Object clone() throws CloneNotSupportedException { + return this; + } + +} + diff --git a/core-java-lang-oop/src/main/java/com/baeldung/keyword/KeywordDemo.java b/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/keyword/KeywordDemo.java similarity index 100% rename from core-java-lang-oop/src/main/java/com/baeldung/keyword/KeywordDemo.java rename to core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/keyword/KeywordDemo.java diff --git a/core-java-lang-oop/src/main/java/com/baeldung/keyword/superkeyword/SuperBase.java b/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/keyword/superkeyword/SuperBase.java similarity index 100% rename from core-java-lang-oop/src/main/java/com/baeldung/keyword/superkeyword/SuperBase.java rename to core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/keyword/superkeyword/SuperBase.java diff --git a/core-java-lang-oop/src/main/java/com/baeldung/keyword/superkeyword/SuperSub.java b/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/keyword/superkeyword/SuperSub.java similarity index 100% rename from core-java-lang-oop/src/main/java/com/baeldung/keyword/superkeyword/SuperSub.java rename to core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/keyword/superkeyword/SuperSub.java diff --git a/core-java-lang-oop/src/main/java/com/baeldung/keyword/thiskeyword/KeywordUnitTest.java b/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/keyword/thiskeyword/KeywordUnitTest.java similarity index 100% rename from core-java-lang-oop/src/main/java/com/baeldung/keyword/thiskeyword/KeywordUnitTest.java rename to core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/keyword/thiskeyword/KeywordUnitTest.java diff --git a/core-java-lang-oop/src/main/java/com/baeldung/markerinterface/DeletableShape.java b/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/markerinterface/DeletableShape.java similarity index 94% rename from core-java-lang-oop/src/main/java/com/baeldung/markerinterface/DeletableShape.java rename to core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/markerinterface/DeletableShape.java index 7674407da8..800ba6f46c 100644 --- a/core-java-lang-oop/src/main/java/com/baeldung/markerinterface/DeletableShape.java +++ b/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/markerinterface/DeletableShape.java @@ -1,5 +1,5 @@ -package com.baeldung.markerinterface; - -public interface DeletableShape extends Shape { - -} +package com.baeldung.markerinterface; + +public interface DeletableShape extends Shape { + +} diff --git a/core-java-lang-oop/src/main/java/com/baeldung/markerinterface/Rectangle.java b/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/markerinterface/Rectangle.java similarity index 95% rename from core-java-lang-oop/src/main/java/com/baeldung/markerinterface/Rectangle.java rename to core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/markerinterface/Rectangle.java index d64ffad0a2..659f2af2ee 100644 --- a/core-java-lang-oop/src/main/java/com/baeldung/markerinterface/Rectangle.java +++ b/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/markerinterface/Rectangle.java @@ -1,22 +1,22 @@ -package com.baeldung.markerinterface; - -public class Rectangle implements DeletableShape { - - private double width; - private double height; - - public Rectangle(double width, double height) { - this.width = width; - this.height = height; - } - - @Override - public double getArea() { - return width * height; - } - - @Override - public double getCircumference() { - return 2 * (width + height); - } -} +package com.baeldung.markerinterface; + +public class Rectangle implements DeletableShape { + + private double width; + private double height; + + public Rectangle(double width, double height) { + this.width = width; + this.height = height; + } + + @Override + public double getArea() { + return width * height; + } + + @Override + public double getCircumference() { + return 2 * (width + height); + } +} diff --git a/core-java-lang-oop/src/main/java/com/baeldung/markerinterface/Shape.java b/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/markerinterface/Shape.java similarity index 95% rename from core-java-lang-oop/src/main/java/com/baeldung/markerinterface/Shape.java rename to core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/markerinterface/Shape.java index 2e53aefc03..b1db906087 100644 --- a/core-java-lang-oop/src/main/java/com/baeldung/markerinterface/Shape.java +++ b/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/markerinterface/Shape.java @@ -1,6 +1,6 @@ -package com.baeldung.markerinterface; - -public interface Shape { - double getArea(); - double getCircumference(); +package com.baeldung.markerinterface; + +public interface Shape { + double getArea(); + double getCircumference(); } \ No newline at end of file diff --git a/core-java-lang-oop/src/main/java/com/baeldung/markerinterface/ShapeDao.java b/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/markerinterface/ShapeDao.java similarity index 95% rename from core-java-lang-oop/src/main/java/com/baeldung/markerinterface/ShapeDao.java rename to core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/markerinterface/ShapeDao.java index bc988a793d..1b95c7b307 100644 --- a/core-java-lang-oop/src/main/java/com/baeldung/markerinterface/ShapeDao.java +++ b/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/markerinterface/ShapeDao.java @@ -1,14 +1,14 @@ -package com.baeldung.markerinterface; - -public class ShapeDao { - - public boolean delete(Object object) { - if (!(object instanceof DeletableShape)) { - return false; - } - // Calling the code that deletes the entity from the database - - return true; - } - -} +package com.baeldung.markerinterface; + +public class ShapeDao { + + public boolean delete(Object object) { + if (!(object instanceof DeletableShape)) { + return false; + } + // Calling the code that deletes the entity from the database + + return true; + } + +} diff --git a/core-java-lang-oop/src/main/java/com/baeldung/methodoverloadingoverriding/application/Application.java b/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/methodoverloadingoverriding/application/Application.java similarity index 100% rename from core-java-lang-oop/src/main/java/com/baeldung/methodoverloadingoverriding/application/Application.java rename to core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/methodoverloadingoverriding/application/Application.java diff --git a/core-java-lang-oop/src/main/java/com/baeldung/methodoverloadingoverriding/model/Car.java b/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/methodoverloadingoverriding/model/Car.java similarity index 100% rename from core-java-lang-oop/src/main/java/com/baeldung/methodoverloadingoverriding/model/Car.java rename to core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/methodoverloadingoverriding/model/Car.java diff --git a/core-java-lang-oop/src/main/java/com/baeldung/methodoverloadingoverriding/model/Vehicle.java b/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/methodoverloadingoverriding/model/Vehicle.java similarity index 100% rename from core-java-lang-oop/src/main/java/com/baeldung/methodoverloadingoverriding/model/Vehicle.java rename to core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/methodoverloadingoverriding/model/Vehicle.java diff --git a/core-java-lang-oop/src/main/java/com/baeldung/methodoverloadingoverriding/util/Multiplier.java b/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/methodoverloadingoverriding/util/Multiplier.java similarity index 100% rename from core-java-lang-oop/src/main/java/com/baeldung/methodoverloadingoverriding/util/Multiplier.java rename to core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/methodoverloadingoverriding/util/Multiplier.java diff --git a/core-java-lang-oop/src/main/java/com/baeldung/polymorphism/FileManager.java b/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/polymorphism/FileManager.java similarity index 100% rename from core-java-lang-oop/src/main/java/com/baeldung/polymorphism/FileManager.java rename to core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/polymorphism/FileManager.java diff --git a/core-java-lang-oop/src/main/java/com/baeldung/polymorphism/GenericFile.java b/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/polymorphism/GenericFile.java similarity index 100% rename from core-java-lang-oop/src/main/java/com/baeldung/polymorphism/GenericFile.java rename to core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/polymorphism/GenericFile.java diff --git a/core-java-lang-oop/src/main/java/com/baeldung/polymorphism/ImageFile.java b/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/polymorphism/ImageFile.java similarity index 100% rename from core-java-lang-oop/src/main/java/com/baeldung/polymorphism/ImageFile.java rename to core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/polymorphism/ImageFile.java diff --git a/core-java-lang-oop/src/main/java/com/baeldung/polymorphism/TextFile.java b/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/polymorphism/TextFile.java similarity index 100% rename from core-java-lang-oop/src/main/java/com/baeldung/polymorphism/TextFile.java rename to core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/polymorphism/TextFile.java diff --git a/core-java-lang-oop/src/main/java/com/baeldung/scope/method/BaseMethodClass.java b/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/scope/method/BaseMethodClass.java similarity index 100% rename from core-java-lang-oop/src/main/java/com/baeldung/scope/method/BaseMethodClass.java rename to core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/scope/method/BaseMethodClass.java diff --git a/core-java-lang-oop/src/main/java/com/baeldung/scope/method/ChildMethodClass.java b/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/scope/method/ChildMethodClass.java similarity index 100% rename from core-java-lang-oop/src/main/java/com/baeldung/scope/method/ChildMethodClass.java rename to core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/scope/method/ChildMethodClass.java diff --git a/core-java-lang-oop/src/main/java/com/baeldung/scope/method/MethodHidingDemo.java b/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/scope/method/MethodHidingDemo.java similarity index 100% rename from core-java-lang-oop/src/main/java/com/baeldung/scope/method/MethodHidingDemo.java rename to core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/scope/method/MethodHidingDemo.java diff --git a/core-java-lang-oop/src/main/java/com/baeldung/scope/variable/ChildVariable.java b/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/scope/variable/ChildVariable.java similarity index 100% rename from core-java-lang-oop/src/main/java/com/baeldung/scope/variable/ChildVariable.java rename to core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/scope/variable/ChildVariable.java diff --git a/core-java-lang-oop/src/main/java/com/baeldung/scope/variable/HideVariable.java b/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/scope/variable/HideVariable.java similarity index 100% rename from core-java-lang-oop/src/main/java/com/baeldung/scope/variable/HideVariable.java rename to core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/scope/variable/HideVariable.java diff --git a/core-java-lang-oop/src/main/java/com/baeldung/scope/variable/ParentVariable.java b/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/scope/variable/ParentVariable.java similarity index 100% rename from core-java-lang-oop/src/main/java/com/baeldung/scope/variable/ParentVariable.java rename to core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/scope/variable/ParentVariable.java diff --git a/core-java-lang-oop/src/main/java/com/baeldung/scope/variable/VariableHidingDemo.java b/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/scope/variable/VariableHidingDemo.java similarity index 100% rename from core-java-lang-oop/src/main/java/com/baeldung/scope/variable/VariableHidingDemo.java rename to core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/scope/variable/VariableHidingDemo.java diff --git a/core-java-lang-oop/src/main/java/com/baeldung/staticdemo/Car.java b/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/staticdemo/Car.java similarity index 100% rename from core-java-lang-oop/src/main/java/com/baeldung/staticdemo/Car.java rename to core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/staticdemo/Car.java diff --git a/core-java-lang-oop/src/main/java/com/baeldung/staticdemo/Singleton.java b/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/staticdemo/Singleton.java similarity index 100% rename from core-java-lang-oop/src/main/java/com/baeldung/staticdemo/Singleton.java rename to core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/staticdemo/Singleton.java diff --git a/core-java-lang-oop/src/main/java/com/baeldung/staticdemo/StaticBlock.java b/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/staticdemo/StaticBlock.java similarity index 100% rename from core-java-lang-oop/src/main/java/com/baeldung/staticdemo/StaticBlock.java rename to core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/staticdemo/StaticBlock.java diff --git a/core-java-lang-oop/src/main/java/com/baeldung/typeerasure/ArrayContentPrintUtil.java b/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/typeerasure/ArrayContentPrintUtil.java similarity index 100% rename from core-java-lang-oop/src/main/java/com/baeldung/typeerasure/ArrayContentPrintUtil.java rename to core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/typeerasure/ArrayContentPrintUtil.java diff --git a/core-java-lang-oop/src/main/java/com/baeldung/typeerasure/BoundStack.java b/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/typeerasure/BoundStack.java similarity index 100% rename from core-java-lang-oop/src/main/java/com/baeldung/typeerasure/BoundStack.java rename to core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/typeerasure/BoundStack.java diff --git a/core-java-lang-oop/src/main/java/com/baeldung/typeerasure/IntegerStack.java b/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/typeerasure/IntegerStack.java similarity index 100% rename from core-java-lang-oop/src/main/java/com/baeldung/typeerasure/IntegerStack.java rename to core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/typeerasure/IntegerStack.java diff --git a/core-java-lang-oop/src/main/java/com/baeldung/typeerasure/Stack.java b/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/typeerasure/Stack.java similarity index 100% rename from core-java-lang-oop/src/main/java/com/baeldung/typeerasure/Stack.java rename to core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/typeerasure/Stack.java diff --git a/core-java-lang-oop/src/main/resources/logback.xml b/core-java-modules/core-java-lang-oop/src/main/resources/logback.xml similarity index 100% rename from core-java-lang-oop/src/main/resources/logback.xml rename to core-java-modules/core-java-lang-oop/src/main/resources/logback.xml diff --git a/core-java-lang-oop/src/test/java/com/baeldung/casting/CastingUnitTest.java b/core-java-modules/core-java-lang-oop/src/test/java/com/baeldung/casting/CastingUnitTest.java similarity index 100% rename from core-java-lang-oop/src/test/java/com/baeldung/casting/CastingUnitTest.java rename to core-java-modules/core-java-lang-oop/src/test/java/com/baeldung/casting/CastingUnitTest.java diff --git a/core-java-lang-oop/src/test/java/com/baeldung/constructors/ConstructorUnitTest.java b/core-java-modules/core-java-lang-oop/src/test/java/com/baeldung/constructors/ConstructorUnitTest.java similarity index 100% rename from core-java-lang-oop/src/test/java/com/baeldung/constructors/ConstructorUnitTest.java rename to core-java-modules/core-java-lang-oop/src/test/java/com/baeldung/constructors/ConstructorUnitTest.java diff --git a/core-java-lang-oop/src/test/java/com/baeldung/deepcopy/DeepCopyUnitTest.java b/core-java-modules/core-java-lang-oop/src/test/java/com/baeldung/deepcopy/DeepCopyUnitTest.java similarity index 100% rename from core-java-lang-oop/src/test/java/com/baeldung/deepcopy/DeepCopyUnitTest.java rename to core-java-modules/core-java-lang-oop/src/test/java/com/baeldung/deepcopy/DeepCopyUnitTest.java diff --git a/core-java-lang-oop/src/test/java/com/baeldung/deepcopy/ShallowCopyUnitTest.java b/core-java-modules/core-java-lang-oop/src/test/java/com/baeldung/deepcopy/ShallowCopyUnitTest.java similarity index 100% rename from core-java-lang-oop/src/test/java/com/baeldung/deepcopy/ShallowCopyUnitTest.java rename to core-java-modules/core-java-lang-oop/src/test/java/com/baeldung/deepcopy/ShallowCopyUnitTest.java diff --git a/core-java-lang-oop/src/test/java/com/baeldung/equalshashcode/MoneyUnitTest.java b/core-java-modules/core-java-lang-oop/src/test/java/com/baeldung/equalshashcode/MoneyUnitTest.java similarity index 100% rename from core-java-lang-oop/src/test/java/com/baeldung/equalshashcode/MoneyUnitTest.java rename to core-java-modules/core-java-lang-oop/src/test/java/com/baeldung/equalshashcode/MoneyUnitTest.java diff --git a/core-java-lang-oop/src/test/java/com/baeldung/equalshashcode/TeamUnitTest.java b/core-java-modules/core-java-lang-oop/src/test/java/com/baeldung/equalshashcode/TeamUnitTest.java similarity index 100% rename from core-java-lang-oop/src/test/java/com/baeldung/equalshashcode/TeamUnitTest.java rename to core-java-modules/core-java-lang-oop/src/test/java/com/baeldung/equalshashcode/TeamUnitTest.java diff --git a/core-java-lang-oop/src/test/java/com/baeldung/equalshashcode/entities/ComplexClassUnitTest.java b/core-java-modules/core-java-lang-oop/src/test/java/com/baeldung/equalshashcode/entities/ComplexClassUnitTest.java similarity index 100% rename from core-java-lang-oop/src/test/java/com/baeldung/equalshashcode/entities/ComplexClassUnitTest.java rename to core-java-modules/core-java-lang-oop/src/test/java/com/baeldung/equalshashcode/entities/ComplexClassUnitTest.java diff --git a/core-java-lang-oop/src/test/java/com/baeldung/equalshashcode/entities/PrimitiveClassUnitTest.java b/core-java-modules/core-java-lang-oop/src/test/java/com/baeldung/equalshashcode/entities/PrimitiveClassUnitTest.java similarity index 100% rename from core-java-lang-oop/src/test/java/com/baeldung/equalshashcode/entities/PrimitiveClassUnitTest.java rename to core-java-modules/core-java-lang-oop/src/test/java/com/baeldung/equalshashcode/entities/PrimitiveClassUnitTest.java diff --git a/core-java-lang-oop/src/test/java/com/baeldung/equalshashcode/entities/SquareClassUnitTest.java b/core-java-modules/core-java-lang-oop/src/test/java/com/baeldung/equalshashcode/entities/SquareClassUnitTest.java similarity index 100% rename from core-java-lang-oop/src/test/java/com/baeldung/equalshashcode/entities/SquareClassUnitTest.java rename to core-java-modules/core-java-lang-oop/src/test/java/com/baeldung/equalshashcode/entities/SquareClassUnitTest.java diff --git a/core-java-lang-oop/src/test/java/com/baeldung/finalkeyword/FinalUnitTest.java b/core-java-modules/core-java-lang-oop/src/test/java/com/baeldung/finalkeyword/FinalUnitTest.java similarity index 100% rename from core-java-lang-oop/src/test/java/com/baeldung/finalkeyword/FinalUnitTest.java rename to core-java-modules/core-java-lang-oop/src/test/java/com/baeldung/finalkeyword/FinalUnitTest.java diff --git a/core-java-lang-oop/src/test/java/com/baeldung/hashcode/application/ApplicationUnitTest.java b/core-java-modules/core-java-lang-oop/src/test/java/com/baeldung/hashcode/application/ApplicationUnitTest.java similarity index 100% rename from core-java-lang-oop/src/test/java/com/baeldung/hashcode/application/ApplicationUnitTest.java rename to core-java-modules/core-java-lang-oop/src/test/java/com/baeldung/hashcode/application/ApplicationUnitTest.java diff --git a/core-java-lang-oop/src/test/java/com/baeldung/hashcode/entities/UserUnitTest.java b/core-java-modules/core-java-lang-oop/src/test/java/com/baeldung/hashcode/entities/UserUnitTest.java similarity index 100% rename from core-java-lang-oop/src/test/java/com/baeldung/hashcode/entities/UserUnitTest.java rename to core-java-modules/core-java-lang-oop/src/test/java/com/baeldung/hashcode/entities/UserUnitTest.java diff --git a/core-java-lang-oop/src/test/java/com/baeldung/immutableobjects/ImmutableObjectsUnitTest.java b/core-java-modules/core-java-lang-oop/src/test/java/com/baeldung/immutableobjects/ImmutableObjectsUnitTest.java similarity index 100% rename from core-java-lang-oop/src/test/java/com/baeldung/immutableobjects/ImmutableObjectsUnitTest.java rename to core-java-modules/core-java-lang-oop/src/test/java/com/baeldung/immutableobjects/ImmutableObjectsUnitTest.java diff --git a/core-java-lang-oop/src/test/java/com/baeldung/inheritance/AppUnitTest.java b/core-java-modules/core-java-lang-oop/src/test/java/com/baeldung/inheritance/AppUnitTest.java similarity index 96% rename from core-java-lang-oop/src/test/java/com/baeldung/inheritance/AppUnitTest.java rename to core-java-modules/core-java-lang-oop/src/test/java/com/baeldung/inheritance/AppUnitTest.java index 1c3c2fff35..0d9dfed27a 100644 --- a/core-java-lang-oop/src/test/java/com/baeldung/inheritance/AppUnitTest.java +++ b/core-java-modules/core-java-lang-oop/src/test/java/com/baeldung/inheritance/AppUnitTest.java @@ -1,46 +1,46 @@ -package com.baeldung.inheritance; - -import com.baeldung.inheritance.*; - -import junit.framework.Test; -import junit.framework.TestCase; -import junit.framework.TestSuite; - -public class AppUnitTest extends TestCase { - - public AppUnitTest(String testName) { - super( testName ); - } - - public static Test suite() { - return new TestSuite(AppUnitTest.class); - } - - @SuppressWarnings("static-access") - public void testStaticMethodUsingBaseClassVariable() { - Car first = new ArmoredCar(); - assertEquals("Car", first.msg()); - } - - @SuppressWarnings("static-access") - public void testStaticMethodUsingDerivedClassVariable() { - ArmoredCar second = new ArmoredCar(); - assertEquals("ArmoredCar", second.msg()); - } - - public void testAssignArmoredCarToCar() { - Employee e1 = new Employee("Shreya", new ArmoredCar()); - assertNotNull(e1.getCar()); - } - - public void testAssignSpaceCarToCar() { - Employee e2 = new Employee("Paul", new SpaceCar()); - assertNotNull(e2.getCar()); - } - - public void testBMWToCar() { - Employee e3 = new Employee("Pavni", new BMW()); - assertNotNull(e3.getCar()); - } - -} +package com.baeldung.inheritance; + +import com.baeldung.inheritance.*; + +import junit.framework.Test; +import junit.framework.TestCase; +import junit.framework.TestSuite; + +public class AppUnitTest extends TestCase { + + public AppUnitTest(String testName) { + super( testName ); + } + + public static Test suite() { + return new TestSuite(AppUnitTest.class); + } + + @SuppressWarnings("static-access") + public void testStaticMethodUsingBaseClassVariable() { + Car first = new ArmoredCar(); + assertEquals("Car", first.msg()); + } + + @SuppressWarnings("static-access") + public void testStaticMethodUsingDerivedClassVariable() { + ArmoredCar second = new ArmoredCar(); + assertEquals("ArmoredCar", second.msg()); + } + + public void testAssignArmoredCarToCar() { + Employee e1 = new Employee("Shreya", new ArmoredCar()); + assertNotNull(e1.getCar()); + } + + public void testAssignSpaceCarToCar() { + Employee e2 = new Employee("Paul", new SpaceCar()); + assertNotNull(e2.getCar()); + } + + public void testBMWToCar() { + Employee e3 = new Employee("Pavni", new BMW()); + assertNotNull(e3.getCar()); + } + +} diff --git a/core-java-lang-oop/src/test/java/com/baeldung/inheritancecomposition/test/ActressUnitTest.java b/core-java-modules/core-java-lang-oop/src/test/java/com/baeldung/inheritancecomposition/test/ActressUnitTest.java similarity index 100% rename from core-java-lang-oop/src/test/java/com/baeldung/inheritancecomposition/test/ActressUnitTest.java rename to core-java-modules/core-java-lang-oop/src/test/java/com/baeldung/inheritancecomposition/test/ActressUnitTest.java diff --git a/core-java-lang-oop/src/test/java/com/baeldung/inheritancecomposition/test/CompositionUnitTest.java b/core-java-modules/core-java-lang-oop/src/test/java/com/baeldung/inheritancecomposition/test/CompositionUnitTest.java similarity index 100% rename from core-java-lang-oop/src/test/java/com/baeldung/inheritancecomposition/test/CompositionUnitTest.java rename to core-java-modules/core-java-lang-oop/src/test/java/com/baeldung/inheritancecomposition/test/CompositionUnitTest.java diff --git a/core-java-lang-oop/src/test/java/com/baeldung/inheritancecomposition/test/InheritanceUnitTest.java b/core-java-modules/core-java-lang-oop/src/test/java/com/baeldung/inheritancecomposition/test/InheritanceUnitTest.java similarity index 100% rename from core-java-lang-oop/src/test/java/com/baeldung/inheritancecomposition/test/InheritanceUnitTest.java rename to core-java-modules/core-java-lang-oop/src/test/java/com/baeldung/inheritancecomposition/test/InheritanceUnitTest.java diff --git a/core-java-lang-oop/src/test/java/com/baeldung/inheritancecomposition/test/PersonUnitTest.java b/core-java-modules/core-java-lang-oop/src/test/java/com/baeldung/inheritancecomposition/test/PersonUnitTest.java similarity index 100% rename from core-java-lang-oop/src/test/java/com/baeldung/inheritancecomposition/test/PersonUnitTest.java rename to core-java-modules/core-java-lang-oop/src/test/java/com/baeldung/inheritancecomposition/test/PersonUnitTest.java diff --git a/core-java-lang-oop/src/test/java/com/baeldung/inheritancecomposition/test/WaitressUnitTest.java b/core-java-modules/core-java-lang-oop/src/test/java/com/baeldung/inheritancecomposition/test/WaitressUnitTest.java similarity index 100% rename from core-java-lang-oop/src/test/java/com/baeldung/inheritancecomposition/test/WaitressUnitTest.java rename to core-java-modules/core-java-lang-oop/src/test/java/com/baeldung/inheritancecomposition/test/WaitressUnitTest.java diff --git a/core-java-lang-syntax/src/test/java/com/baeldung/initializationguide/UserUnitTest.java b/core-java-modules/core-java-lang-oop/src/test/java/com/baeldung/initializationguide/UserUnitTest.java similarity index 97% rename from core-java-lang-syntax/src/test/java/com/baeldung/initializationguide/UserUnitTest.java rename to core-java-modules/core-java-lang-oop/src/test/java/com/baeldung/initializationguide/UserUnitTest.java index f74384e6f7..a26b602609 100644 --- a/core-java-lang-syntax/src/test/java/com/baeldung/initializationguide/UserUnitTest.java +++ b/core-java-modules/core-java-lang-oop/src/test/java/com/baeldung/initializationguide/UserUnitTest.java @@ -1,37 +1,37 @@ -package com.baeldung.initializationguide; -import org.junit.Before; -import org.junit.Test; - -import static org.assertj.core.api.Assertions.*; - -import java.lang.reflect.InvocationTargetException; - -public class UserUnitTest { - - @Test - public void givenUserInstance_whenIntializedWithNew_thenInstanceIsNotNull() { - User user = new User("Alice", 1); - assertThat(user).isNotNull(); - } - - @Test - public void givenUserInstance_whenInitializedWithReflection_thenInstanceIsNotNull() throws InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException { - User user = User.class.getConstructor(String.class, int.class) - .newInstance("Alice", 2); - assertThat(user).isNotNull(); - } - - @Test - public void givenUserInstance_whenCopiedWithClone_thenExactMatchIsCreated() throws CloneNotSupportedException { - User user = new User("Alice", 3); - User clonedUser = (User) user.clone(); - assertThat(clonedUser).isEqualTo(user); - } - - @Test - public void givenUserInstance_whenValuesAreNotInitialized_thenUserNameAndIdReturnDefault() { - User user = new User(); - assertThat(user.getName()).isNull(); - assertThat(user.getId() == 0); - } -} +package com.baeldung.initializationguide; +import org.junit.Before; +import org.junit.Test; + +import static org.assertj.core.api.Assertions.*; + +import java.lang.reflect.InvocationTargetException; + +public class UserUnitTest { + + @Test + public void givenUserInstance_whenIntializedWithNew_thenInstanceIsNotNull() { + User user = new User("Alice", 1); + assertThat(user).isNotNull(); + } + + @Test + public void givenUserInstance_whenInitializedWithReflection_thenInstanceIsNotNull() throws InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException { + User user = User.class.getConstructor(String.class, int.class) + .newInstance("Alice", 2); + assertThat(user).isNotNull(); + } + + @Test + public void givenUserInstance_whenCopiedWithClone_thenExactMatchIsCreated() throws CloneNotSupportedException { + User user = new User("Alice", 3); + User clonedUser = (User) user.clone(); + assertThat(clonedUser).isEqualTo(user); + } + + @Test + public void givenUserInstance_whenValuesAreNotInitialized_thenUserNameAndIdReturnDefault() { + User user = new User(); + assertThat(user.getName()).isNull(); + assertThat(user.getId() == 0); + } +} diff --git a/core-java-lang-oop/src/test/java/com/baeldung/markerinterface/MarkerInterfaceUnitTest.java b/core-java-modules/core-java-lang-oop/src/test/java/com/baeldung/markerinterface/MarkerInterfaceUnitTest.java similarity index 96% rename from core-java-lang-oop/src/test/java/com/baeldung/markerinterface/MarkerInterfaceUnitTest.java rename to core-java-modules/core-java-lang-oop/src/test/java/com/baeldung/markerinterface/MarkerInterfaceUnitTest.java index 70d32ba253..81cd51ce51 100644 --- a/core-java-lang-oop/src/test/java/com/baeldung/markerinterface/MarkerInterfaceUnitTest.java +++ b/core-java-modules/core-java-lang-oop/src/test/java/com/baeldung/markerinterface/MarkerInterfaceUnitTest.java @@ -1,26 +1,26 @@ -package com.baeldung.markerinterface; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -import org.junit.jupiter.api.Test; - -public class MarkerInterfaceUnitTest { - - @Test - public void givenDeletableObjectThenTrueReturned() { - ShapeDao shapeDao = new ShapeDao(); - Object rectangle = new Rectangle(2, 3); - - boolean result = shapeDao.delete(rectangle); - assertEquals(true, result); - } - - @Test - public void givenNonDeletableObjectThenFalseReturned() { - ShapeDao shapeDao = new ShapeDao(); - Object object = new Object(); - - boolean result = shapeDao.delete(object); - assertEquals(false, result); - } -} +package com.baeldung.markerinterface; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import org.junit.jupiter.api.Test; + +public class MarkerInterfaceUnitTest { + + @Test + public void givenDeletableObjectThenTrueReturned() { + ShapeDao shapeDao = new ShapeDao(); + Object rectangle = new Rectangle(2, 3); + + boolean result = shapeDao.delete(rectangle); + assertEquals(true, result); + } + + @Test + public void givenNonDeletableObjectThenFalseReturned() { + ShapeDao shapeDao = new ShapeDao(); + Object object = new Object(); + + boolean result = shapeDao.delete(object); + assertEquals(false, result); + } +} diff --git a/core-java-lang-oop/src/test/java/com/baeldung/methodoverloadingoverriding/test/MethodOverloadingUnitTest.java b/core-java-modules/core-java-lang-oop/src/test/java/com/baeldung/methodoverloadingoverriding/test/MethodOverloadingUnitTest.java similarity index 100% rename from core-java-lang-oop/src/test/java/com/baeldung/methodoverloadingoverriding/test/MethodOverloadingUnitTest.java rename to core-java-modules/core-java-lang-oop/src/test/java/com/baeldung/methodoverloadingoverriding/test/MethodOverloadingUnitTest.java diff --git a/core-java-lang-oop/src/test/java/com/baeldung/methodoverloadingoverriding/test/MethodOverridingUnitTest.java b/core-java-modules/core-java-lang-oop/src/test/java/com/baeldung/methodoverloadingoverriding/test/MethodOverridingUnitTest.java similarity index 100% rename from core-java-lang-oop/src/test/java/com/baeldung/methodoverloadingoverriding/test/MethodOverridingUnitTest.java rename to core-java-modules/core-java-lang-oop/src/test/java/com/baeldung/methodoverloadingoverriding/test/MethodOverridingUnitTest.java diff --git a/core-java-lang-oop/src/test/java/com/baeldung/parameterpassing/NonPrimitivesUnitTest.java b/core-java-modules/core-java-lang-oop/src/test/java/com/baeldung/parameterpassing/NonPrimitivesUnitTest.java similarity index 100% rename from core-java-lang-oop/src/test/java/com/baeldung/parameterpassing/NonPrimitivesUnitTest.java rename to core-java-modules/core-java-lang-oop/src/test/java/com/baeldung/parameterpassing/NonPrimitivesUnitTest.java diff --git a/core-java-lang-oop/src/test/java/com/baeldung/parameterpassing/PrimitivesUnitTest.java b/core-java-modules/core-java-lang-oop/src/test/java/com/baeldung/parameterpassing/PrimitivesUnitTest.java similarity index 100% rename from core-java-lang-oop/src/test/java/com/baeldung/parameterpassing/PrimitivesUnitTest.java rename to core-java-modules/core-java-lang-oop/src/test/java/com/baeldung/parameterpassing/PrimitivesUnitTest.java diff --git a/core-java-lang-oop/src/test/java/com/baeldung/polymorphism/PolymorphismUnitTest.java b/core-java-modules/core-java-lang-oop/src/test/java/com/baeldung/polymorphism/PolymorphismUnitTest.java similarity index 100% rename from core-java-lang-oop/src/test/java/com/baeldung/polymorphism/PolymorphismUnitTest.java rename to core-java-modules/core-java-lang-oop/src/test/java/com/baeldung/polymorphism/PolymorphismUnitTest.java diff --git a/core-java-lang-oop/src/test/java/com/baeldung/staticdemo/CarIntegrationTest.java b/core-java-modules/core-java-lang-oop/src/test/java/com/baeldung/staticdemo/CarIntegrationTest.java similarity index 100% rename from core-java-lang-oop/src/test/java/com/baeldung/staticdemo/CarIntegrationTest.java rename to core-java-modules/core-java-lang-oop/src/test/java/com/baeldung/staticdemo/CarIntegrationTest.java diff --git a/core-java-lang-oop/src/test/java/com/baeldung/staticdemo/SingletonIntegrationTest.java b/core-java-modules/core-java-lang-oop/src/test/java/com/baeldung/staticdemo/SingletonIntegrationTest.java similarity index 100% rename from core-java-lang-oop/src/test/java/com/baeldung/staticdemo/SingletonIntegrationTest.java rename to core-java-modules/core-java-lang-oop/src/test/java/com/baeldung/staticdemo/SingletonIntegrationTest.java diff --git a/core-java-lang-oop/src/test/java/com/baeldung/staticdemo/StaticBlockIntegrationTest.java b/core-java-modules/core-java-lang-oop/src/test/java/com/baeldung/staticdemo/StaticBlockIntegrationTest.java similarity index 100% rename from core-java-lang-oop/src/test/java/com/baeldung/staticdemo/StaticBlockIntegrationTest.java rename to core-java-modules/core-java-lang-oop/src/test/java/com/baeldung/staticdemo/StaticBlockIntegrationTest.java diff --git a/core-java-lang-oop/src/test/java/com/baeldung/typeerasure/TypeErasureUnitTest.java b/core-java-modules/core-java-lang-oop/src/test/java/com/baeldung/typeerasure/TypeErasureUnitTest.java similarity index 100% rename from core-java-lang-oop/src/test/java/com/baeldung/typeerasure/TypeErasureUnitTest.java rename to core-java-modules/core-java-lang-oop/src/test/java/com/baeldung/typeerasure/TypeErasureUnitTest.java diff --git a/core-java-lang-oop/src/test/resources/.gitignore b/core-java-modules/core-java-lang-oop/src/test/resources/.gitignore similarity index 100% rename from core-java-lang-oop/src/test/resources/.gitignore rename to core-java-modules/core-java-lang-oop/src/test/resources/.gitignore diff --git a/core-java-lang/.gitignore b/core-java-modules/core-java-lang-syntax/.gitignore similarity index 100% rename from core-java-lang/.gitignore rename to core-java-modules/core-java-lang-syntax/.gitignore diff --git a/core-java-lang-syntax/README.md b/core-java-modules/core-java-lang-syntax/README.md similarity index 100% rename from core-java-lang-syntax/README.md rename to core-java-modules/core-java-lang-syntax/README.md diff --git a/core-java-lang-syntax/pom.xml b/core-java-modules/core-java-lang-syntax/pom.xml similarity index 96% rename from core-java-lang-syntax/pom.xml rename to core-java-modules/core-java-lang-syntax/pom.xml index 9a9df01057..46fa8d1206 100644 --- a/core-java-lang-syntax/pom.xml +++ b/core-java-modules/core-java-lang-syntax/pom.xml @@ -11,7 +11,7 @@ com.baeldung parent-java 0.0.1-SNAPSHOT - ../parent-java + ../../parent-java diff --git a/core-java-lang-syntax/src/main/java/com/baeldung/breakcontinue/BreakContinue.java b/core-java-modules/core-java-lang-syntax/src/main/java/com/baeldung/breakcontinue/BreakContinue.java similarity index 100% rename from core-java-lang-syntax/src/main/java/com/baeldung/breakcontinue/BreakContinue.java rename to core-java-modules/core-java-lang-syntax/src/main/java/com/baeldung/breakcontinue/BreakContinue.java diff --git a/core-java-lang-syntax/src/main/java/com/baeldung/enums/Pizza.java b/core-java-modules/core-java-lang-syntax/src/main/java/com/baeldung/enums/Pizza.java similarity index 100% rename from core-java-lang-syntax/src/main/java/com/baeldung/enums/Pizza.java rename to core-java-modules/core-java-lang-syntax/src/main/java/com/baeldung/enums/Pizza.java diff --git a/core-java-lang-syntax/src/main/java/com/baeldung/enums/PizzaDeliveryStrategy.java b/core-java-modules/core-java-lang-syntax/src/main/java/com/baeldung/enums/PizzaDeliveryStrategy.java similarity index 100% rename from core-java-lang-syntax/src/main/java/com/baeldung/enums/PizzaDeliveryStrategy.java rename to core-java-modules/core-java-lang-syntax/src/main/java/com/baeldung/enums/PizzaDeliveryStrategy.java diff --git a/core-java-lang-syntax/src/main/java/com/baeldung/enums/PizzaDeliverySystemConfiguration.java b/core-java-modules/core-java-lang-syntax/src/main/java/com/baeldung/enums/PizzaDeliverySystemConfiguration.java similarity index 100% rename from core-java-lang-syntax/src/main/java/com/baeldung/enums/PizzaDeliverySystemConfiguration.java rename to core-java-modules/core-java-lang-syntax/src/main/java/com/baeldung/enums/PizzaDeliverySystemConfiguration.java diff --git a/core-java-lang-syntax/src/main/java/com/baeldung/generics/Building.java b/core-java-modules/core-java-lang-syntax/src/main/java/com/baeldung/generics/Building.java similarity index 100% rename from core-java-lang-syntax/src/main/java/com/baeldung/generics/Building.java rename to core-java-modules/core-java-lang-syntax/src/main/java/com/baeldung/generics/Building.java diff --git a/core-java-lang-syntax/src/main/java/com/baeldung/generics/Generics.java b/core-java-modules/core-java-lang-syntax/src/main/java/com/baeldung/generics/Generics.java similarity index 100% rename from core-java-lang-syntax/src/main/java/com/baeldung/generics/Generics.java rename to core-java-modules/core-java-lang-syntax/src/main/java/com/baeldung/generics/Generics.java diff --git a/core-java-lang-syntax/src/main/java/com/baeldung/generics/House.java b/core-java-modules/core-java-lang-syntax/src/main/java/com/baeldung/generics/House.java similarity index 100% rename from core-java-lang-syntax/src/main/java/com/baeldung/generics/House.java rename to core-java-modules/core-java-lang-syntax/src/main/java/com/baeldung/generics/House.java diff --git a/core-java-lang-oop/src/main/java/com/baeldung/initializationguide/User.java b/core-java-modules/core-java-lang-syntax/src/main/java/com/baeldung/initializationguide/User.java similarity index 94% rename from core-java-lang-oop/src/main/java/com/baeldung/initializationguide/User.java rename to core-java-modules/core-java-lang-syntax/src/main/java/com/baeldung/initializationguide/User.java index e2e3f051dd..1d9a872d69 100644 --- a/core-java-lang-oop/src/main/java/com/baeldung/initializationguide/User.java +++ b/core-java-modules/core-java-lang-syntax/src/main/java/com/baeldung/initializationguide/User.java @@ -1,53 +1,53 @@ -package com.baeldung.initializationguide; - -import java.io.Serializable; - -public class User implements Serializable, Cloneable { - private static final long serialVersionUID = 1L; - static String forum; - private String name; - private int id; - - { - id = 0; - System.out.println("Instance Initializer"); - } - - static { - forum = "Java"; - System.out.println("Static Initializer"); - } - - public User(String name, int id) { - super(); - this.name = name; - this.id = id; - } - - public User() { - System.out.println("Constructor"); - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public int getId() { - return id; - } - - public void setId(int id) { - this.id = id; - } - - @Override - protected Object clone() throws CloneNotSupportedException { - return this; - } - -} - +package com.baeldung.initializationguide; + +import java.io.Serializable; + +public class User implements Serializable, Cloneable { + private static final long serialVersionUID = 1L; + static String forum; + private String name; + private int id; + + { + id = 0; + System.out.println("Instance Initializer"); + } + + static { + forum = "Java"; + System.out.println("Static Initializer"); + } + + public User(String name, int id) { + super(); + this.name = name; + this.id = id; + } + + public User() { + System.out.println("Constructor"); + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + @Override + protected Object clone() throws CloneNotSupportedException { + return this; + } + +} + diff --git a/core-java-lang-syntax/src/main/java/com/baeldung/keyword/Circle.java b/core-java-modules/core-java-lang-syntax/src/main/java/com/baeldung/keyword/Circle.java similarity index 94% rename from core-java-lang-syntax/src/main/java/com/baeldung/keyword/Circle.java rename to core-java-modules/core-java-lang-syntax/src/main/java/com/baeldung/keyword/Circle.java index 231b2f5a59..807020d267 100644 --- a/core-java-lang-syntax/src/main/java/com/baeldung/keyword/Circle.java +++ b/core-java-modules/core-java-lang-syntax/src/main/java/com/baeldung/keyword/Circle.java @@ -1,5 +1,5 @@ -package com.baeldung.keyword; - -public class Circle extends Round implements Shape { - -} +package com.baeldung.keyword; + +public class Circle extends Round implements Shape { + +} diff --git a/core-java-lang-syntax/src/main/java/com/baeldung/keyword/Ring.java b/core-java-modules/core-java-lang-syntax/src/main/java/com/baeldung/keyword/Ring.java similarity index 94% rename from core-java-lang-syntax/src/main/java/com/baeldung/keyword/Ring.java rename to core-java-modules/core-java-lang-syntax/src/main/java/com/baeldung/keyword/Ring.java index 99873f9640..64274cbb6b 100644 --- a/core-java-lang-syntax/src/main/java/com/baeldung/keyword/Ring.java +++ b/core-java-modules/core-java-lang-syntax/src/main/java/com/baeldung/keyword/Ring.java @@ -1,4 +1,4 @@ -package com.baeldung.keyword; - -public class Ring extends Round { -} +package com.baeldung.keyword; + +public class Ring extends Round { +} diff --git a/core-java-lang-syntax/src/main/java/com/baeldung/keyword/Round.java b/core-java-modules/core-java-lang-syntax/src/main/java/com/baeldung/keyword/Round.java similarity index 93% rename from core-java-lang-syntax/src/main/java/com/baeldung/keyword/Round.java rename to core-java-modules/core-java-lang-syntax/src/main/java/com/baeldung/keyword/Round.java index 0e2cc2c8c7..37008de09c 100644 --- a/core-java-lang-syntax/src/main/java/com/baeldung/keyword/Round.java +++ b/core-java-modules/core-java-lang-syntax/src/main/java/com/baeldung/keyword/Round.java @@ -1,4 +1,4 @@ -package com.baeldung.keyword; - -public class Round { -} +package com.baeldung.keyword; + +public class Round { +} diff --git a/core-java-lang-syntax/src/main/java/com/baeldung/keyword/Shape.java b/core-java-modules/core-java-lang-syntax/src/main/java/com/baeldung/keyword/Shape.java similarity index 93% rename from core-java-lang-syntax/src/main/java/com/baeldung/keyword/Shape.java rename to core-java-modules/core-java-lang-syntax/src/main/java/com/baeldung/keyword/Shape.java index 8d00c165a3..437917c29e 100644 --- a/core-java-lang-syntax/src/main/java/com/baeldung/keyword/Shape.java +++ b/core-java-modules/core-java-lang-syntax/src/main/java/com/baeldung/keyword/Shape.java @@ -1,4 +1,4 @@ -package com.baeldung.keyword; - -public interface Shape { -} +package com.baeldung.keyword; + +public interface Shape { +} diff --git a/core-java-lang-syntax/src/main/java/com/baeldung/keyword/Triangle.java b/core-java-modules/core-java-lang-syntax/src/main/java/com/baeldung/keyword/Triangle.java similarity index 94% rename from core-java-lang-syntax/src/main/java/com/baeldung/keyword/Triangle.java rename to core-java-modules/core-java-lang-syntax/src/main/java/com/baeldung/keyword/Triangle.java index 406b8f23e5..4cb6ed72ba 100644 --- a/core-java-lang-syntax/src/main/java/com/baeldung/keyword/Triangle.java +++ b/core-java-modules/core-java-lang-syntax/src/main/java/com/baeldung/keyword/Triangle.java @@ -1,4 +1,4 @@ -package com.baeldung.keyword; - -public class Triangle implements Shape { -} +package com.baeldung.keyword; + +public class Triangle implements Shape { +} diff --git a/core-java-lang-syntax/src/main/java/com/baeldung/loops/InfiniteLoops.java b/core-java-modules/core-java-lang-syntax/src/main/java/com/baeldung/loops/InfiniteLoops.java similarity index 95% rename from core-java-lang-syntax/src/main/java/com/baeldung/loops/InfiniteLoops.java rename to core-java-modules/core-java-lang-syntax/src/main/java/com/baeldung/loops/InfiniteLoops.java index 0706c85db8..4952fd7b35 100644 --- a/core-java-lang-syntax/src/main/java/com/baeldung/loops/InfiniteLoops.java +++ b/core-java-modules/core-java-lang-syntax/src/main/java/com/baeldung/loops/InfiniteLoops.java @@ -1,23 +1,23 @@ -package com.baeldung.loops; - -public class InfiniteLoops { - - public void infiniteLoopUsingWhile() { - while (true) { - System.out.println("Infinite loop using while"); - } - } - - public void infiniteLoopUsingFor() { - for (;;) { - System.out.println("Infinite loop using for"); - } - } - - public void infiniteLoopUsingDoWhile() { - do { - System.out.println("Infinite loop using do-while"); - } while (true); - } - -} +package com.baeldung.loops; + +public class InfiniteLoops { + + public void infiniteLoopUsingWhile() { + while (true) { + System.out.println("Infinite loop using while"); + } + } + + public void infiniteLoopUsingFor() { + for (;;) { + System.out.println("Infinite loop using for"); + } + } + + public void infiniteLoopUsingDoWhile() { + do { + System.out.println("Infinite loop using do-while"); + } while (true); + } + +} diff --git a/core-java-lang-syntax/src/main/java/com/baeldung/loops/LoopsInJava.java b/core-java-modules/core-java-lang-syntax/src/main/java/com/baeldung/loops/LoopsInJava.java similarity index 100% rename from core-java-lang-syntax/src/main/java/com/baeldung/loops/LoopsInJava.java rename to core-java-modules/core-java-lang-syntax/src/main/java/com/baeldung/loops/LoopsInJava.java diff --git a/core-java-lang-syntax/src/main/java/com/baeldung/switchstatement/SwitchStatement.java b/core-java-modules/core-java-lang-syntax/src/main/java/com/baeldung/switchstatement/SwitchStatement.java similarity index 100% rename from core-java-lang-syntax/src/main/java/com/baeldung/switchstatement/SwitchStatement.java rename to core-java-modules/core-java-lang-syntax/src/main/java/com/baeldung/switchstatement/SwitchStatement.java diff --git a/core-java-lang-syntax/src/main/java/com/baeldung/system/ChatWindow.java b/core-java-modules/core-java-lang-syntax/src/main/java/com/baeldung/system/ChatWindow.java similarity index 100% rename from core-java-lang-syntax/src/main/java/com/baeldung/system/ChatWindow.java rename to core-java-modules/core-java-lang-syntax/src/main/java/com/baeldung/system/ChatWindow.java diff --git a/core-java-lang-syntax/src/main/java/com/baeldung/system/DateTimeService.java b/core-java-modules/core-java-lang-syntax/src/main/java/com/baeldung/system/DateTimeService.java similarity index 100% rename from core-java-lang-syntax/src/main/java/com/baeldung/system/DateTimeService.java rename to core-java-modules/core-java-lang-syntax/src/main/java/com/baeldung/system/DateTimeService.java diff --git a/core-java-lang-syntax/src/main/java/com/baeldung/system/EnvironmentVariables.java b/core-java-modules/core-java-lang-syntax/src/main/java/com/baeldung/system/EnvironmentVariables.java similarity index 100% rename from core-java-lang-syntax/src/main/java/com/baeldung/system/EnvironmentVariables.java rename to core-java-modules/core-java-lang-syntax/src/main/java/com/baeldung/system/EnvironmentVariables.java diff --git a/core-java-lang-syntax/src/main/java/com/baeldung/system/SystemErrDemo.java b/core-java-modules/core-java-lang-syntax/src/main/java/com/baeldung/system/SystemErrDemo.java similarity index 100% rename from core-java-lang-syntax/src/main/java/com/baeldung/system/SystemErrDemo.java rename to core-java-modules/core-java-lang-syntax/src/main/java/com/baeldung/system/SystemErrDemo.java diff --git a/core-java-lang-syntax/src/main/java/com/baeldung/system/SystemExitDemo.java b/core-java-modules/core-java-lang-syntax/src/main/java/com/baeldung/system/SystemExitDemo.java similarity index 100% rename from core-java-lang-syntax/src/main/java/com/baeldung/system/SystemExitDemo.java rename to core-java-modules/core-java-lang-syntax/src/main/java/com/baeldung/system/SystemExitDemo.java diff --git a/core-java-lang-syntax/src/main/java/com/baeldung/system/SystemOutDemo.java b/core-java-modules/core-java-lang-syntax/src/main/java/com/baeldung/system/SystemOutDemo.java similarity index 100% rename from core-java-lang-syntax/src/main/java/com/baeldung/system/SystemOutDemo.java rename to core-java-modules/core-java-lang-syntax/src/main/java/com/baeldung/system/SystemOutDemo.java diff --git a/core-java-lang-syntax/src/main/java/com/baeldung/system/UserCredentials.java b/core-java-modules/core-java-lang-syntax/src/main/java/com/baeldung/system/UserCredentials.java similarity index 100% rename from core-java-lang-syntax/src/main/java/com/baeldung/system/UserCredentials.java rename to core-java-modules/core-java-lang-syntax/src/main/java/com/baeldung/system/UserCredentials.java diff --git a/core-java-lang-syntax/src/test/java/com/baeldung/breakcontinue/BreakContinueUnitTest.java b/core-java-modules/core-java-lang-syntax/src/test/java/com/baeldung/breakcontinue/BreakContinueUnitTest.java similarity index 100% rename from core-java-lang-syntax/src/test/java/com/baeldung/breakcontinue/BreakContinueUnitTest.java rename to core-java-modules/core-java-lang-syntax/src/test/java/com/baeldung/breakcontinue/BreakContinueUnitTest.java diff --git a/core-java-lang-syntax/src/test/java/com/baeldung/enums/PizzaUnitTest.java b/core-java-modules/core-java-lang-syntax/src/test/java/com/baeldung/enums/PizzaUnitTest.java similarity index 100% rename from core-java-lang-syntax/src/test/java/com/baeldung/enums/PizzaUnitTest.java rename to core-java-modules/core-java-lang-syntax/src/test/java/com/baeldung/enums/PizzaUnitTest.java diff --git a/core-java-lang-syntax/src/test/java/com/baeldung/generics/GenericsUnitTest.java b/core-java-modules/core-java-lang-syntax/src/test/java/com/baeldung/generics/GenericsUnitTest.java similarity index 100% rename from core-java-lang-syntax/src/test/java/com/baeldung/generics/GenericsUnitTest.java rename to core-java-modules/core-java-lang-syntax/src/test/java/com/baeldung/generics/GenericsUnitTest.java diff --git a/core-java-lang-oop/src/test/java/com/baeldung/initializationguide/UserUnitTest.java b/core-java-modules/core-java-lang-syntax/src/test/java/com/baeldung/initializationguide/UserUnitTest.java similarity index 97% rename from core-java-lang-oop/src/test/java/com/baeldung/initializationguide/UserUnitTest.java rename to core-java-modules/core-java-lang-syntax/src/test/java/com/baeldung/initializationguide/UserUnitTest.java index f74384e6f7..a26b602609 100644 --- a/core-java-lang-oop/src/test/java/com/baeldung/initializationguide/UserUnitTest.java +++ b/core-java-modules/core-java-lang-syntax/src/test/java/com/baeldung/initializationguide/UserUnitTest.java @@ -1,37 +1,37 @@ -package com.baeldung.initializationguide; -import org.junit.Before; -import org.junit.Test; - -import static org.assertj.core.api.Assertions.*; - -import java.lang.reflect.InvocationTargetException; - -public class UserUnitTest { - - @Test - public void givenUserInstance_whenIntializedWithNew_thenInstanceIsNotNull() { - User user = new User("Alice", 1); - assertThat(user).isNotNull(); - } - - @Test - public void givenUserInstance_whenInitializedWithReflection_thenInstanceIsNotNull() throws InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException { - User user = User.class.getConstructor(String.class, int.class) - .newInstance("Alice", 2); - assertThat(user).isNotNull(); - } - - @Test - public void givenUserInstance_whenCopiedWithClone_thenExactMatchIsCreated() throws CloneNotSupportedException { - User user = new User("Alice", 3); - User clonedUser = (User) user.clone(); - assertThat(clonedUser).isEqualTo(user); - } - - @Test - public void givenUserInstance_whenValuesAreNotInitialized_thenUserNameAndIdReturnDefault() { - User user = new User(); - assertThat(user.getName()).isNull(); - assertThat(user.getId() == 0); - } -} +package com.baeldung.initializationguide; +import org.junit.Before; +import org.junit.Test; + +import static org.assertj.core.api.Assertions.*; + +import java.lang.reflect.InvocationTargetException; + +public class UserUnitTest { + + @Test + public void givenUserInstance_whenIntializedWithNew_thenInstanceIsNotNull() { + User user = new User("Alice", 1); + assertThat(user).isNotNull(); + } + + @Test + public void givenUserInstance_whenInitializedWithReflection_thenInstanceIsNotNull() throws InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException { + User user = User.class.getConstructor(String.class, int.class) + .newInstance("Alice", 2); + assertThat(user).isNotNull(); + } + + @Test + public void givenUserInstance_whenCopiedWithClone_thenExactMatchIsCreated() throws CloneNotSupportedException { + User user = new User("Alice", 3); + User clonedUser = (User) user.clone(); + assertThat(clonedUser).isEqualTo(user); + } + + @Test + public void givenUserInstance_whenValuesAreNotInitialized_thenUserNameAndIdReturnDefault() { + User user = new User(); + assertThat(user.getName()).isNull(); + assertThat(user.getId() == 0); + } +} diff --git a/core-java-lang-syntax/src/test/java/com/baeldung/java/diamond/Car.java b/core-java-modules/core-java-lang-syntax/src/test/java/com/baeldung/java/diamond/Car.java similarity index 100% rename from core-java-lang-syntax/src/test/java/com/baeldung/java/diamond/Car.java rename to core-java-modules/core-java-lang-syntax/src/test/java/com/baeldung/java/diamond/Car.java diff --git a/core-java-lang-syntax/src/test/java/com/baeldung/java/diamond/DiamondOperatorUnitTest.java b/core-java-modules/core-java-lang-syntax/src/test/java/com/baeldung/java/diamond/DiamondOperatorUnitTest.java similarity index 100% rename from core-java-lang-syntax/src/test/java/com/baeldung/java/diamond/DiamondOperatorUnitTest.java rename to core-java-modules/core-java-lang-syntax/src/test/java/com/baeldung/java/diamond/DiamondOperatorUnitTest.java diff --git a/core-java-lang-syntax/src/test/java/com/baeldung/java/diamond/Diesel.java b/core-java-modules/core-java-lang-syntax/src/test/java/com/baeldung/java/diamond/Diesel.java similarity index 100% rename from core-java-lang-syntax/src/test/java/com/baeldung/java/diamond/Diesel.java rename to core-java-modules/core-java-lang-syntax/src/test/java/com/baeldung/java/diamond/Diesel.java diff --git a/core-java-lang-syntax/src/test/java/com/baeldung/java/diamond/Engine.java b/core-java-modules/core-java-lang-syntax/src/test/java/com/baeldung/java/diamond/Engine.java similarity index 100% rename from core-java-lang-syntax/src/test/java/com/baeldung/java/diamond/Engine.java rename to core-java-modules/core-java-lang-syntax/src/test/java/com/baeldung/java/diamond/Engine.java diff --git a/core-java-lang-syntax/src/test/java/com/baeldung/java/diamond/Vehicle.java b/core-java-modules/core-java-lang-syntax/src/test/java/com/baeldung/java/diamond/Vehicle.java similarity index 100% rename from core-java-lang-syntax/src/test/java/com/baeldung/java/diamond/Vehicle.java rename to core-java-modules/core-java-lang-syntax/src/test/java/com/baeldung/java/diamond/Vehicle.java diff --git a/core-java-lang-syntax/src/test/java/com/baeldung/java/doublebrace/DoubleBraceUnitTest.java b/core-java-modules/core-java-lang-syntax/src/test/java/com/baeldung/java/doublebrace/DoubleBraceUnitTest.java similarity index 100% rename from core-java-lang-syntax/src/test/java/com/baeldung/java/doublebrace/DoubleBraceUnitTest.java rename to core-java-modules/core-java-lang-syntax/src/test/java/com/baeldung/java/doublebrace/DoubleBraceUnitTest.java diff --git a/core-java-lang-syntax/src/test/java/com/baeldung/keyword/test/InstanceOfUnitTest.java b/core-java-modules/core-java-lang-syntax/src/test/java/com/baeldung/keyword/test/InstanceOfUnitTest.java similarity index 96% rename from core-java-lang-syntax/src/test/java/com/baeldung/keyword/test/InstanceOfUnitTest.java rename to core-java-modules/core-java-lang-syntax/src/test/java/com/baeldung/keyword/test/InstanceOfUnitTest.java index 4c010e3a16..6966fa3944 100644 --- a/core-java-lang-syntax/src/test/java/com/baeldung/keyword/test/InstanceOfUnitTest.java +++ b/core-java-modules/core-java-lang-syntax/src/test/java/com/baeldung/keyword/test/InstanceOfUnitTest.java @@ -1,55 +1,55 @@ -package com.baeldung.keyword.test; - -import org.junit.Assert; -import org.junit.jupiter.api.Test; - -import com.baeldung.keyword.Circle; -import com.baeldung.keyword.Ring; -import com.baeldung.keyword.Round; -import com.baeldung.keyword.Shape; -import com.baeldung.keyword.Triangle; - -public class InstanceOfUnitTest { - - @Test - public void giveWhenInstanceIsCorrect_thenReturnTrue() { - Ring ring = new Ring(); - Assert.assertTrue("ring is instance of Round ", ring instanceof Round); - } - - @Test - public void giveWhenObjectIsInstanceOfType_thenReturnTrue() { - Circle circle = new Circle(); - Assert.assertTrue("circle is instance of Circle ", circle instanceof Circle); - } - - - @Test - public void giveWhenInstanceIsOfSubtype_thenReturnTrue() { - Circle circle = new Circle(); - Assert.assertTrue("circle is instance of Round", circle instanceof Round); - } - - @Test - public void giveWhenTypeIsInterface_thenReturnTrue() { - Circle circle = new Circle(); - Assert.assertTrue("circle is instance of Shape", circle instanceof Shape); - } - - @Test - public void giveWhenTypeIsOfObjectType_thenReturnTrue() { - Thread thread = new Thread(); - Assert.assertTrue("thread is instance of Object", thread instanceof Object); - } - - @Test - public void giveWhenInstanceValueIsNull_thenReturnFalse() { - Circle circle = null; - Assert.assertFalse("circle is instance of Round", circle instanceof Round); - } - - @Test - public void giveWhenComparingClassInDiffHierarchy_thenCompilationError() { - // Assert.assertFalse("circle is instance of Triangle", circle instanceof Triangle); - } -} +package com.baeldung.keyword.test; + +import org.junit.Assert; +import org.junit.jupiter.api.Test; + +import com.baeldung.keyword.Circle; +import com.baeldung.keyword.Ring; +import com.baeldung.keyword.Round; +import com.baeldung.keyword.Shape; +import com.baeldung.keyword.Triangle; + +public class InstanceOfUnitTest { + + @Test + public void giveWhenInstanceIsCorrect_thenReturnTrue() { + Ring ring = new Ring(); + Assert.assertTrue("ring is instance of Round ", ring instanceof Round); + } + + @Test + public void giveWhenObjectIsInstanceOfType_thenReturnTrue() { + Circle circle = new Circle(); + Assert.assertTrue("circle is instance of Circle ", circle instanceof Circle); + } + + + @Test + public void giveWhenInstanceIsOfSubtype_thenReturnTrue() { + Circle circle = new Circle(); + Assert.assertTrue("circle is instance of Round", circle instanceof Round); + } + + @Test + public void giveWhenTypeIsInterface_thenReturnTrue() { + Circle circle = new Circle(); + Assert.assertTrue("circle is instance of Shape", circle instanceof Shape); + } + + @Test + public void giveWhenTypeIsOfObjectType_thenReturnTrue() { + Thread thread = new Thread(); + Assert.assertTrue("thread is instance of Object", thread instanceof Object); + } + + @Test + public void giveWhenInstanceValueIsNull_thenReturnFalse() { + Circle circle = null; + Assert.assertFalse("circle is instance of Round", circle instanceof Round); + } + + @Test + public void giveWhenComparingClassInDiffHierarchy_thenCompilationError() { + // Assert.assertFalse("circle is instance of Triangle", circle instanceof Triangle); + } +} diff --git a/core-java-lang-syntax/src/test/java/com/baeldung/loops/WhenUsingLoops.java b/core-java-modules/core-java-lang-syntax/src/test/java/com/baeldung/loops/WhenUsingLoops.java similarity index 100% rename from core-java-lang-syntax/src/test/java/com/baeldung/loops/WhenUsingLoops.java rename to core-java-modules/core-java-lang-syntax/src/test/java/com/baeldung/loops/WhenUsingLoops.java diff --git a/core-java-lang-syntax/src/test/java/com/baeldung/modulo/ModuloUnitTest.java b/core-java-modules/core-java-lang-syntax/src/test/java/com/baeldung/modulo/ModuloUnitTest.java similarity index 100% rename from core-java-lang-syntax/src/test/java/com/baeldung/modulo/ModuloUnitTest.java rename to core-java-modules/core-java-lang-syntax/src/test/java/com/baeldung/modulo/ModuloUnitTest.java diff --git a/core-java-lang-syntax/src/test/java/com/baeldung/primitiveconversion/PrimitiveConversionsJUnitTest.java b/core-java-modules/core-java-lang-syntax/src/test/java/com/baeldung/primitiveconversion/PrimitiveConversionsJUnitTest.java similarity index 100% rename from core-java-lang-syntax/src/test/java/com/baeldung/primitiveconversion/PrimitiveConversionsJUnitTest.java rename to core-java-modules/core-java-lang-syntax/src/test/java/com/baeldung/primitiveconversion/PrimitiveConversionsJUnitTest.java diff --git a/core-java-lang-syntax/src/test/java/com/baeldung/switchstatement/SwitchStatementUnitTest.java b/core-java-modules/core-java-lang-syntax/src/test/java/com/baeldung/switchstatement/SwitchStatementUnitTest.java similarity index 100% rename from core-java-lang-syntax/src/test/java/com/baeldung/switchstatement/SwitchStatementUnitTest.java rename to core-java-modules/core-java-lang-syntax/src/test/java/com/baeldung/switchstatement/SwitchStatementUnitTest.java diff --git a/core-java-lang-syntax/src/test/java/com/baeldung/system/DateTimeServiceUnitTest.java b/core-java-modules/core-java-lang-syntax/src/test/java/com/baeldung/system/DateTimeServiceUnitTest.java similarity index 100% rename from core-java-lang-syntax/src/test/java/com/baeldung/system/DateTimeServiceUnitTest.java rename to core-java-modules/core-java-lang-syntax/src/test/java/com/baeldung/system/DateTimeServiceUnitTest.java diff --git a/core-java-lang-syntax/src/test/java/com/baeldung/system/EnvironmentVariablesUnitTest.java b/core-java-modules/core-java-lang-syntax/src/test/java/com/baeldung/system/EnvironmentVariablesUnitTest.java similarity index 100% rename from core-java-lang-syntax/src/test/java/com/baeldung/system/EnvironmentVariablesUnitTest.java rename to core-java-modules/core-java-lang-syntax/src/test/java/com/baeldung/system/EnvironmentVariablesUnitTest.java diff --git a/core-java-lang-syntax/src/test/java/com/baeldung/system/SystemArrayCopyUnitTest.java b/core-java-modules/core-java-lang-syntax/src/test/java/com/baeldung/system/SystemArrayCopyUnitTest.java similarity index 100% rename from core-java-lang-syntax/src/test/java/com/baeldung/system/SystemArrayCopyUnitTest.java rename to core-java-modules/core-java-lang-syntax/src/test/java/com/baeldung/system/SystemArrayCopyUnitTest.java diff --git a/core-java-lang-syntax/src/test/java/com/baeldung/system/SystemNanoUnitTest.java b/core-java-modules/core-java-lang-syntax/src/test/java/com/baeldung/system/SystemNanoUnitTest.java similarity index 100% rename from core-java-lang-syntax/src/test/java/com/baeldung/system/SystemNanoUnitTest.java rename to core-java-modules/core-java-lang-syntax/src/test/java/com/baeldung/system/SystemNanoUnitTest.java diff --git a/core-java-lang-syntax/src/test/java/com/baeldung/system/SystemPropertiesUnitTest.java b/core-java-modules/core-java-lang-syntax/src/test/java/com/baeldung/system/SystemPropertiesUnitTest.java similarity index 100% rename from core-java-lang-syntax/src/test/java/com/baeldung/system/SystemPropertiesUnitTest.java rename to core-java-modules/core-java-lang-syntax/src/test/java/com/baeldung/system/SystemPropertiesUnitTest.java diff --git a/core-java-lang-syntax/src/test/java/com/baeldung/ternaryoperator/TernaryOperatorUnitTest.java b/core-java-modules/core-java-lang-syntax/src/test/java/com/baeldung/ternaryoperator/TernaryOperatorUnitTest.java similarity index 100% rename from core-java-lang-syntax/src/test/java/com/baeldung/ternaryoperator/TernaryOperatorUnitTest.java rename to core-java-modules/core-java-lang-syntax/src/test/java/com/baeldung/ternaryoperator/TernaryOperatorUnitTest.java diff --git a/core-java-lang-syntax/src/test/java/com/baeldung/varargs/FormatterUnitTest.java b/core-java-modules/core-java-lang-syntax/src/test/java/com/baeldung/varargs/FormatterUnitTest.java similarity index 100% rename from core-java-lang-syntax/src/test/java/com/baeldung/varargs/FormatterUnitTest.java rename to core-java-modules/core-java-lang-syntax/src/test/java/com/baeldung/varargs/FormatterUnitTest.java diff --git a/core-java-networking/.gitignore b/core-java-modules/core-java-lang/.gitignore similarity index 100% rename from core-java-networking/.gitignore rename to core-java-modules/core-java-lang/.gitignore diff --git a/core-java-lang/README.md b/core-java-modules/core-java-lang/README.md similarity index 100% rename from core-java-lang/README.md rename to core-java-modules/core-java-lang/README.md diff --git a/core-java-lang/pom.xml b/core-java-modules/core-java-lang/pom.xml similarity index 98% rename from core-java-lang/pom.xml rename to core-java-modules/core-java-lang/pom.xml index 551c8e8505..45ccc8d0f5 100644 --- a/core-java-lang/pom.xml +++ b/core-java-modules/core-java-lang/pom.xml @@ -11,7 +11,7 @@ com.baeldung parent-java 0.0.1-SNAPSHOT - ../parent-java + ../../parent-java diff --git a/core-java-lang/src/main/java/com/baeldung/assertion/Assertion.java b/core-java-modules/core-java-lang/src/main/java/com/baeldung/assertion/Assertion.java similarity index 100% rename from core-java-lang/src/main/java/com/baeldung/assertion/Assertion.java rename to core-java-modules/core-java-lang/src/main/java/com/baeldung/assertion/Assertion.java diff --git a/core-java-lang/src/main/java/com/baeldung/binding/Animal.java b/core-java-modules/core-java-lang/src/main/java/com/baeldung/binding/Animal.java similarity index 100% rename from core-java-lang/src/main/java/com/baeldung/binding/Animal.java rename to core-java-modules/core-java-lang/src/main/java/com/baeldung/binding/Animal.java diff --git a/core-java-lang/src/main/java/com/baeldung/binding/AnimalActivity.java b/core-java-modules/core-java-lang/src/main/java/com/baeldung/binding/AnimalActivity.java similarity index 100% rename from core-java-lang/src/main/java/com/baeldung/binding/AnimalActivity.java rename to core-java-modules/core-java-lang/src/main/java/com/baeldung/binding/AnimalActivity.java diff --git a/core-java-lang/src/main/java/com/baeldung/binding/Cat.java b/core-java-modules/core-java-lang/src/main/java/com/baeldung/binding/Cat.java similarity index 100% rename from core-java-lang/src/main/java/com/baeldung/binding/Cat.java rename to core-java-modules/core-java-lang/src/main/java/com/baeldung/binding/Cat.java diff --git a/core-java-lang/src/main/java/com/baeldung/chainedexception/LogWithChain.java b/core-java-modules/core-java-lang/src/main/java/com/baeldung/chainedexception/LogWithChain.java similarity index 100% rename from core-java-lang/src/main/java/com/baeldung/chainedexception/LogWithChain.java rename to core-java-modules/core-java-lang/src/main/java/com/baeldung/chainedexception/LogWithChain.java diff --git a/core-java-lang/src/main/java/com/baeldung/chainedexception/LogWithoutChain.java b/core-java-modules/core-java-lang/src/main/java/com/baeldung/chainedexception/LogWithoutChain.java similarity index 100% rename from core-java-lang/src/main/java/com/baeldung/chainedexception/LogWithoutChain.java rename to core-java-modules/core-java-lang/src/main/java/com/baeldung/chainedexception/LogWithoutChain.java diff --git a/core-java-lang/src/main/java/com/baeldung/chainedexception/exceptions/GirlFriendOfManagerUpsetException.java b/core-java-modules/core-java-lang/src/main/java/com/baeldung/chainedexception/exceptions/GirlFriendOfManagerUpsetException.java similarity index 100% rename from core-java-lang/src/main/java/com/baeldung/chainedexception/exceptions/GirlFriendOfManagerUpsetException.java rename to core-java-modules/core-java-lang/src/main/java/com/baeldung/chainedexception/exceptions/GirlFriendOfManagerUpsetException.java diff --git a/core-java-lang/src/main/java/com/baeldung/chainedexception/exceptions/ManagerUpsetException.java b/core-java-modules/core-java-lang/src/main/java/com/baeldung/chainedexception/exceptions/ManagerUpsetException.java similarity index 100% rename from core-java-lang/src/main/java/com/baeldung/chainedexception/exceptions/ManagerUpsetException.java rename to core-java-modules/core-java-lang/src/main/java/com/baeldung/chainedexception/exceptions/ManagerUpsetException.java diff --git a/core-java-lang/src/main/java/com/baeldung/chainedexception/exceptions/NoLeaveGrantedException.java b/core-java-modules/core-java-lang/src/main/java/com/baeldung/chainedexception/exceptions/NoLeaveGrantedException.java similarity index 100% rename from core-java-lang/src/main/java/com/baeldung/chainedexception/exceptions/NoLeaveGrantedException.java rename to core-java-modules/core-java-lang/src/main/java/com/baeldung/chainedexception/exceptions/NoLeaveGrantedException.java diff --git a/core-java-lang/src/main/java/com/baeldung/chainedexception/exceptions/TeamLeadUpsetException.java b/core-java-modules/core-java-lang/src/main/java/com/baeldung/chainedexception/exceptions/TeamLeadUpsetException.java similarity index 100% rename from core-java-lang/src/main/java/com/baeldung/chainedexception/exceptions/TeamLeadUpsetException.java rename to core-java-modules/core-java-lang/src/main/java/com/baeldung/chainedexception/exceptions/TeamLeadUpsetException.java diff --git a/core-java-lang/src/main/java/com/baeldung/className/RetrievingClassName.java b/core-java-modules/core-java-lang/src/main/java/com/baeldung/className/RetrievingClassName.java similarity index 100% rename from core-java-lang/src/main/java/com/baeldung/className/RetrievingClassName.java rename to core-java-modules/core-java-lang/src/main/java/com/baeldung/className/RetrievingClassName.java diff --git a/core-java-lang/src/main/java/com/baeldung/comparable/Player.java b/core-java-modules/core-java-lang/src/main/java/com/baeldung/comparable/Player.java similarity index 100% rename from core-java-lang/src/main/java/com/baeldung/comparable/Player.java rename to core-java-modules/core-java-lang/src/main/java/com/baeldung/comparable/Player.java diff --git a/core-java-lang/src/main/java/com/baeldung/comparable/PlayerSorter.java b/core-java-modules/core-java-lang/src/main/java/com/baeldung/comparable/PlayerSorter.java similarity index 100% rename from core-java-lang/src/main/java/com/baeldung/comparable/PlayerSorter.java rename to core-java-modules/core-java-lang/src/main/java/com/baeldung/comparable/PlayerSorter.java diff --git a/core-java-lang/src/main/java/com/baeldung/comparator/Player.java b/core-java-modules/core-java-lang/src/main/java/com/baeldung/comparator/Player.java similarity index 100% rename from core-java-lang/src/main/java/com/baeldung/comparator/Player.java rename to core-java-modules/core-java-lang/src/main/java/com/baeldung/comparator/Player.java diff --git a/core-java-lang/src/main/java/com/baeldung/comparator/PlayerAgeComparator.java b/core-java-modules/core-java-lang/src/main/java/com/baeldung/comparator/PlayerAgeComparator.java similarity index 100% rename from core-java-lang/src/main/java/com/baeldung/comparator/PlayerAgeComparator.java rename to core-java-modules/core-java-lang/src/main/java/com/baeldung/comparator/PlayerAgeComparator.java diff --git a/core-java-lang/src/main/java/com/baeldung/comparator/PlayerAgeSorter.java b/core-java-modules/core-java-lang/src/main/java/com/baeldung/comparator/PlayerAgeSorter.java similarity index 100% rename from core-java-lang/src/main/java/com/baeldung/comparator/PlayerAgeSorter.java rename to core-java-modules/core-java-lang/src/main/java/com/baeldung/comparator/PlayerAgeSorter.java diff --git a/core-java-lang/src/main/java/com/baeldung/comparator/PlayerRankingComparator.java b/core-java-modules/core-java-lang/src/main/java/com/baeldung/comparator/PlayerRankingComparator.java similarity index 100% rename from core-java-lang/src/main/java/com/baeldung/comparator/PlayerRankingComparator.java rename to core-java-modules/core-java-lang/src/main/java/com/baeldung/comparator/PlayerRankingComparator.java diff --git a/core-java-lang/src/main/java/com/baeldung/comparator/PlayerRankingSorter.java b/core-java-modules/core-java-lang/src/main/java/com/baeldung/comparator/PlayerRankingSorter.java similarity index 100% rename from core-java-lang/src/main/java/com/baeldung/comparator/PlayerRankingSorter.java rename to core-java-modules/core-java-lang/src/main/java/com/baeldung/comparator/PlayerRankingSorter.java diff --git a/core-java-lang/src/main/java/com/baeldung/controlstructures/ConditionalBranches.java b/core-java-modules/core-java-lang/src/main/java/com/baeldung/controlstructures/ConditionalBranches.java similarity index 100% rename from core-java-lang/src/main/java/com/baeldung/controlstructures/ConditionalBranches.java rename to core-java-modules/core-java-lang/src/main/java/com/baeldung/controlstructures/ConditionalBranches.java diff --git a/core-java-lang/src/main/java/com/baeldung/controlstructures/Loops.java b/core-java-modules/core-java-lang/src/main/java/com/baeldung/controlstructures/Loops.java similarity index 100% rename from core-java-lang/src/main/java/com/baeldung/controlstructures/Loops.java rename to core-java-modules/core-java-lang/src/main/java/com/baeldung/controlstructures/Loops.java diff --git a/core-java-lang/src/main/java/com/baeldung/customexception/FileManager.java b/core-java-modules/core-java-lang/src/main/java/com/baeldung/customexception/FileManager.java similarity index 100% rename from core-java-lang/src/main/java/com/baeldung/customexception/FileManager.java rename to core-java-modules/core-java-lang/src/main/java/com/baeldung/customexception/FileManager.java diff --git a/core-java-lang/src/main/java/com/baeldung/customexception/IncorrectFileExtensionException.java b/core-java-modules/core-java-lang/src/main/java/com/baeldung/customexception/IncorrectFileExtensionException.java similarity index 100% rename from core-java-lang/src/main/java/com/baeldung/customexception/IncorrectFileExtensionException.java rename to core-java-modules/core-java-lang/src/main/java/com/baeldung/customexception/IncorrectFileExtensionException.java diff --git a/core-java-lang/src/main/java/com/baeldung/customexception/IncorrectFileNameException.java b/core-java-modules/core-java-lang/src/main/java/com/baeldung/customexception/IncorrectFileNameException.java similarity index 100% rename from core-java-lang/src/main/java/com/baeldung/customexception/IncorrectFileNameException.java rename to core-java-modules/core-java-lang/src/main/java/com/baeldung/customexception/IncorrectFileNameException.java diff --git a/core-java-lang/src/main/java/com/baeldung/doubles/SplitFloatingPointNumbers.java b/core-java-modules/core-java-lang/src/main/java/com/baeldung/doubles/SplitFloatingPointNumbers.java similarity index 100% rename from core-java-lang/src/main/java/com/baeldung/doubles/SplitFloatingPointNumbers.java rename to core-java-modules/core-java-lang/src/main/java/com/baeldung/doubles/SplitFloatingPointNumbers.java diff --git a/core-java-lang/src/main/java/com/baeldung/dynamicproxy/DynamicInvocationHandler.java b/core-java-modules/core-java-lang/src/main/java/com/baeldung/dynamicproxy/DynamicInvocationHandler.java similarity index 100% rename from core-java-lang/src/main/java/com/baeldung/dynamicproxy/DynamicInvocationHandler.java rename to core-java-modules/core-java-lang/src/main/java/com/baeldung/dynamicproxy/DynamicInvocationHandler.java diff --git a/core-java-lang/src/main/java/com/baeldung/dynamicproxy/TimingDynamicInvocationHandler.java b/core-java-modules/core-java-lang/src/main/java/com/baeldung/dynamicproxy/TimingDynamicInvocationHandler.java similarity index 100% rename from core-java-lang/src/main/java/com/baeldung/dynamicproxy/TimingDynamicInvocationHandler.java rename to core-java-modules/core-java-lang/src/main/java/com/baeldung/dynamicproxy/TimingDynamicInvocationHandler.java diff --git a/core-java-lang/src/main/java/com/baeldung/enums/values/Element1.java b/core-java-modules/core-java-lang/src/main/java/com/baeldung/enums/values/Element1.java similarity index 100% rename from core-java-lang/src/main/java/com/baeldung/enums/values/Element1.java rename to core-java-modules/core-java-lang/src/main/java/com/baeldung/enums/values/Element1.java diff --git a/core-java-lang/src/main/java/com/baeldung/enums/values/Element2.java b/core-java-modules/core-java-lang/src/main/java/com/baeldung/enums/values/Element2.java similarity index 100% rename from core-java-lang/src/main/java/com/baeldung/enums/values/Element2.java rename to core-java-modules/core-java-lang/src/main/java/com/baeldung/enums/values/Element2.java diff --git a/core-java-lang/src/main/java/com/baeldung/enums/values/Element3.java b/core-java-modules/core-java-lang/src/main/java/com/baeldung/enums/values/Element3.java similarity index 100% rename from core-java-lang/src/main/java/com/baeldung/enums/values/Element3.java rename to core-java-modules/core-java-lang/src/main/java/com/baeldung/enums/values/Element3.java diff --git a/core-java-lang/src/main/java/com/baeldung/enums/values/Element4.java b/core-java-modules/core-java-lang/src/main/java/com/baeldung/enums/values/Element4.java similarity index 100% rename from core-java-lang/src/main/java/com/baeldung/enums/values/Element4.java rename to core-java-modules/core-java-lang/src/main/java/com/baeldung/enums/values/Element4.java diff --git a/core-java-lang/src/main/java/com/baeldung/enums/values/Labeled.java b/core-java-modules/core-java-lang/src/main/java/com/baeldung/enums/values/Labeled.java similarity index 100% rename from core-java-lang/src/main/java/com/baeldung/enums/values/Labeled.java rename to core-java-modules/core-java-lang/src/main/java/com/baeldung/enums/values/Labeled.java diff --git a/core-java-lang/src/main/java/com/baeldung/exceptionhandling/Exceptions.java b/core-java-modules/core-java-lang/src/main/java/com/baeldung/exceptionhandling/Exceptions.java similarity index 96% rename from core-java-lang/src/main/java/com/baeldung/exceptionhandling/Exceptions.java rename to core-java-modules/core-java-lang/src/main/java/com/baeldung/exceptionhandling/Exceptions.java index 9690648386..32d88cfd12 100644 --- a/core-java-lang/src/main/java/com/baeldung/exceptionhandling/Exceptions.java +++ b/core-java-modules/core-java-lang/src/main/java/com/baeldung/exceptionhandling/Exceptions.java @@ -1,212 +1,212 @@ -package com.baeldung.exceptionhandling; - -import java.io.File; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.util.List; -import java.util.Scanner; -import java.util.logging.Logger; -import java.util.stream.Collectors; - -public class Exceptions { - - private final static Logger logger = Logger.getLogger("ExceptionLogging"); - - public static List getPlayers() throws IOException { - Path path = Paths.get("players.dat"); - List players = Files.readAllLines(path); - - return players.stream() - .map(Player::new) - .collect(Collectors.toList()); - } - - public List loadAllPlayers(String playersFile) throws IOException{ - try { - throw new IOException(); - } catch(IOException ex) { - throw new IllegalStateException(); - } - } - - public int getPlayerScoreThrows(String playerFile) throws FileNotFoundException { - Scanner contents = new Scanner(new File(playerFile)); - return Integer.parseInt(contents.nextLine()); - } - - public int getPlayerScoreTryCatch(String playerFile) { - try { - Scanner contents = new Scanner(new File(playerFile)); - return Integer.parseInt(contents.nextLine()); - } catch (FileNotFoundException noFile) { - throw new IllegalArgumentException("File not found"); - } - } - - public int getPlayerScoreTryCatchRecovery(String playerFile) { - try { - Scanner contents = new Scanner(new File(playerFile)); - return Integer.parseInt(contents.nextLine()); - } catch ( FileNotFoundException noFile ) { - logger.warning("File not found, resetting score."); - return 0; - } - } - - public int getPlayerScoreFinally(String playerFile) throws FileNotFoundException { - Scanner contents = null; - try { - contents = new Scanner(new File(playerFile)); - return Integer.parseInt(contents.nextLine()); - } finally { - if (contents != null) { - contents.close(); - } - } - } - - public int getPlayerScoreTryWithResources(String playerFile) { - try (Scanner contents = new Scanner(new File(playerFile))) { - return Integer.parseInt(contents.nextLine()); - } catch (FileNotFoundException e ) { - logger.warning("File not found, resetting score."); - return 0; - } - } - - public int getPlayerScoreMultipleCatchBlocks(String playerFile) { - try (Scanner contents = new Scanner(new File(playerFile))) { - return Integer.parseInt(contents.nextLine()); - } catch (IOException e) { - logger.warning("Player file wouldn't load!"); - return 0; - } catch (NumberFormatException e) { - logger.warning("Player file was corrupted!"); - return 0; - } - } - - public int getPlayerScoreMultipleCatchBlocksAlternative(String playerFile) { - try (Scanner contents = new Scanner(new File(playerFile)) ) { - return Integer.parseInt(contents.nextLine()); - } catch (FileNotFoundException e) { - logger.warning("Player file not found!"); - return 0; - } catch (IOException e) { - logger.warning("Player file wouldn't load!"); - return 0; - } catch (NumberFormatException e) { - logger.warning("Player file was corrupted!"); - return 0; - } - } - - public int getPlayerScoreUnionCatchBlocks(String playerFile) { - try (Scanner contents = new Scanner(new File(playerFile))) { - return Integer.parseInt(contents.nextLine()); - } catch (IOException | NumberFormatException e) { - logger.warning("Failed to load score!"); - return 0; - } - } - - public List loadAllPlayersThrowingChecked(String playersFile) throws TimeoutException { - boolean tooLong = true; - - while (!tooLong) { - // ... potentially long operation - } - throw new TimeoutException("This operation took too long"); - } - - public List loadAllPlayersThrowingUnchecked(String playersFile) throws TimeoutException { - if(!isFilenameValid(playersFile)) { - throw new IllegalArgumentException("Filename isn't valid!"); - } - return null; - - // ... - } - - public List loadAllPlayersWrapping(String playersFile) throws IOException { - try { - throw new IOException(); - } catch (IOException io) { - throw io; - } - } - - public List loadAllPlayersRethrowing(String playersFile) throws PlayerLoadException { - try { - throw new IOException(); - } catch (IOException io) { - throw new PlayerLoadException(io); - } - } - - public List loadAllPlayersThrowable(String playersFile) { - try { - throw new NullPointerException(); - } catch ( Throwable t ) { - throw t; - } - } - - class FewerExceptions extends Exceptions { - @Override - public List loadAllPlayers(String playersFile) { //can't add "throws MyCheckedException - return null; - // overridden - } - } - - public void throwAsGotoAntiPattern() throws MyException { - try { - // bunch of code - throw new MyException(); - // second bunch of code - } catch ( MyException e ) { - // third bunch of code - } - } - - public int getPlayerScoreSwallowingExceptionAntiPattern(String playerFile) { - try { - // ... - } catch (Exception e) {} // <== catch and swallow - return 0; - } - - public int getPlayerScoreSwallowingExceptionAntiPatternAlternative(String playerFile) { - try { - // ... - } catch (Exception e) { - e.printStackTrace(); - } - return 0; - } - - public int getPlayerScoreSwallowingExceptionAntiPatternAlternative2(String playerFile) throws PlayerScoreException { - try { - throw new IOException(); - } catch (IOException e) { - throw new PlayerScoreException(e); - } - } - - public int getPlayerScoreReturnInFinallyAntiPattern(String playerFile) { - int score = 0; - try { - throw new IOException(); - } finally { - return score; // <== the IOException is dropped - } - } - - private boolean isFilenameValid(String name) { - return false; - } -} +package com.baeldung.exceptionhandling; + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.List; +import java.util.Scanner; +import java.util.logging.Logger; +import java.util.stream.Collectors; + +public class Exceptions { + + private final static Logger logger = Logger.getLogger("ExceptionLogging"); + + public static List getPlayers() throws IOException { + Path path = Paths.get("players.dat"); + List players = Files.readAllLines(path); + + return players.stream() + .map(Player::new) + .collect(Collectors.toList()); + } + + public List loadAllPlayers(String playersFile) throws IOException{ + try { + throw new IOException(); + } catch(IOException ex) { + throw new IllegalStateException(); + } + } + + public int getPlayerScoreThrows(String playerFile) throws FileNotFoundException { + Scanner contents = new Scanner(new File(playerFile)); + return Integer.parseInt(contents.nextLine()); + } + + public int getPlayerScoreTryCatch(String playerFile) { + try { + Scanner contents = new Scanner(new File(playerFile)); + return Integer.parseInt(contents.nextLine()); + } catch (FileNotFoundException noFile) { + throw new IllegalArgumentException("File not found"); + } + } + + public int getPlayerScoreTryCatchRecovery(String playerFile) { + try { + Scanner contents = new Scanner(new File(playerFile)); + return Integer.parseInt(contents.nextLine()); + } catch ( FileNotFoundException noFile ) { + logger.warning("File not found, resetting score."); + return 0; + } + } + + public int getPlayerScoreFinally(String playerFile) throws FileNotFoundException { + Scanner contents = null; + try { + contents = new Scanner(new File(playerFile)); + return Integer.parseInt(contents.nextLine()); + } finally { + if (contents != null) { + contents.close(); + } + } + } + + public int getPlayerScoreTryWithResources(String playerFile) { + try (Scanner contents = new Scanner(new File(playerFile))) { + return Integer.parseInt(contents.nextLine()); + } catch (FileNotFoundException e ) { + logger.warning("File not found, resetting score."); + return 0; + } + } + + public int getPlayerScoreMultipleCatchBlocks(String playerFile) { + try (Scanner contents = new Scanner(new File(playerFile))) { + return Integer.parseInt(contents.nextLine()); + } catch (IOException e) { + logger.warning("Player file wouldn't load!"); + return 0; + } catch (NumberFormatException e) { + logger.warning("Player file was corrupted!"); + return 0; + } + } + + public int getPlayerScoreMultipleCatchBlocksAlternative(String playerFile) { + try (Scanner contents = new Scanner(new File(playerFile)) ) { + return Integer.parseInt(contents.nextLine()); + } catch (FileNotFoundException e) { + logger.warning("Player file not found!"); + return 0; + } catch (IOException e) { + logger.warning("Player file wouldn't load!"); + return 0; + } catch (NumberFormatException e) { + logger.warning("Player file was corrupted!"); + return 0; + } + } + + public int getPlayerScoreUnionCatchBlocks(String playerFile) { + try (Scanner contents = new Scanner(new File(playerFile))) { + return Integer.parseInt(contents.nextLine()); + } catch (IOException | NumberFormatException e) { + logger.warning("Failed to load score!"); + return 0; + } + } + + public List loadAllPlayersThrowingChecked(String playersFile) throws TimeoutException { + boolean tooLong = true; + + while (!tooLong) { + // ... potentially long operation + } + throw new TimeoutException("This operation took too long"); + } + + public List loadAllPlayersThrowingUnchecked(String playersFile) throws TimeoutException { + if(!isFilenameValid(playersFile)) { + throw new IllegalArgumentException("Filename isn't valid!"); + } + return null; + + // ... + } + + public List loadAllPlayersWrapping(String playersFile) throws IOException { + try { + throw new IOException(); + } catch (IOException io) { + throw io; + } + } + + public List loadAllPlayersRethrowing(String playersFile) throws PlayerLoadException { + try { + throw new IOException(); + } catch (IOException io) { + throw new PlayerLoadException(io); + } + } + + public List loadAllPlayersThrowable(String playersFile) { + try { + throw new NullPointerException(); + } catch ( Throwable t ) { + throw t; + } + } + + class FewerExceptions extends Exceptions { + @Override + public List loadAllPlayers(String playersFile) { //can't add "throws MyCheckedException + return null; + // overridden + } + } + + public void throwAsGotoAntiPattern() throws MyException { + try { + // bunch of code + throw new MyException(); + // second bunch of code + } catch ( MyException e ) { + // third bunch of code + } + } + + public int getPlayerScoreSwallowingExceptionAntiPattern(String playerFile) { + try { + // ... + } catch (Exception e) {} // <== catch and swallow + return 0; + } + + public int getPlayerScoreSwallowingExceptionAntiPatternAlternative(String playerFile) { + try { + // ... + } catch (Exception e) { + e.printStackTrace(); + } + return 0; + } + + public int getPlayerScoreSwallowingExceptionAntiPatternAlternative2(String playerFile) throws PlayerScoreException { + try { + throw new IOException(); + } catch (IOException e) { + throw new PlayerScoreException(e); + } + } + + public int getPlayerScoreReturnInFinallyAntiPattern(String playerFile) { + int score = 0; + try { + throw new IOException(); + } finally { + return score; // <== the IOException is dropped + } + } + + private boolean isFilenameValid(String name) { + return false; + } +} diff --git a/core-java-lang/src/main/java/com/baeldung/exceptionhandling/MyException.java b/core-java-modules/core-java-lang/src/main/java/com/baeldung/exceptionhandling/MyException.java similarity index 94% rename from core-java-lang/src/main/java/com/baeldung/exceptionhandling/MyException.java rename to core-java-modules/core-java-lang/src/main/java/com/baeldung/exceptionhandling/MyException.java index 5a50acc4de..c2908b7278 100644 --- a/core-java-lang/src/main/java/com/baeldung/exceptionhandling/MyException.java +++ b/core-java-modules/core-java-lang/src/main/java/com/baeldung/exceptionhandling/MyException.java @@ -1,5 +1,5 @@ -package com.baeldung.exceptionhandling; - -public class MyException extends Throwable { - -} +package com.baeldung.exceptionhandling; + +public class MyException extends Throwable { + +} diff --git a/core-java-lang/src/main/java/com/baeldung/exceptionhandling/Player.java b/core-java-modules/core-java-lang/src/main/java/com/baeldung/exceptionhandling/Player.java similarity index 93% rename from core-java-lang/src/main/java/com/baeldung/exceptionhandling/Player.java rename to core-java-modules/core-java-lang/src/main/java/com/baeldung/exceptionhandling/Player.java index 4efd37134f..e866802fe3 100644 --- a/core-java-lang/src/main/java/com/baeldung/exceptionhandling/Player.java +++ b/core-java-modules/core-java-lang/src/main/java/com/baeldung/exceptionhandling/Player.java @@ -1,12 +1,12 @@ -package com.baeldung.exceptionhandling; - -public class Player { - - public int id; - public String name; - - public Player(String name) { - this.name = name; - } - -} +package com.baeldung.exceptionhandling; + +public class Player { + + public int id; + public String name; + + public Player(String name) { + this.name = name; + } + +} diff --git a/core-java-lang/src/main/java/com/baeldung/exceptionhandling/PlayerLoadException.java b/core-java-modules/core-java-lang/src/main/java/com/baeldung/exceptionhandling/PlayerLoadException.java similarity index 94% rename from core-java-lang/src/main/java/com/baeldung/exceptionhandling/PlayerLoadException.java rename to core-java-modules/core-java-lang/src/main/java/com/baeldung/exceptionhandling/PlayerLoadException.java index 5302fd8e7d..d92edeebbd 100644 --- a/core-java-lang/src/main/java/com/baeldung/exceptionhandling/PlayerLoadException.java +++ b/core-java-modules/core-java-lang/src/main/java/com/baeldung/exceptionhandling/PlayerLoadException.java @@ -1,11 +1,11 @@ -package com.baeldung.exceptionhandling; - -import java.io.IOException; - -public class PlayerLoadException extends Exception { - - public PlayerLoadException(IOException io) { - super(io); - } - -} +package com.baeldung.exceptionhandling; + +import java.io.IOException; + +public class PlayerLoadException extends Exception { + + public PlayerLoadException(IOException io) { + super(io); + } + +} diff --git a/core-java-lang/src/main/java/com/baeldung/exceptionhandling/PlayerScoreException.java b/core-java-modules/core-java-lang/src/main/java/com/baeldung/exceptionhandling/PlayerScoreException.java similarity index 95% rename from core-java-lang/src/main/java/com/baeldung/exceptionhandling/PlayerScoreException.java rename to core-java-modules/core-java-lang/src/main/java/com/baeldung/exceptionhandling/PlayerScoreException.java index d11159217e..299370ee86 100644 --- a/core-java-lang/src/main/java/com/baeldung/exceptionhandling/PlayerScoreException.java +++ b/core-java-modules/core-java-lang/src/main/java/com/baeldung/exceptionhandling/PlayerScoreException.java @@ -1,8 +1,8 @@ -package com.baeldung.exceptionhandling; - -public class PlayerScoreException extends Exception { - - public PlayerScoreException(Exception e) { - super(e); - } -} +package com.baeldung.exceptionhandling; + +public class PlayerScoreException extends Exception { + + public PlayerScoreException(Exception e) { + super(e); + } +} diff --git a/core-java-lang/src/main/java/com/baeldung/exceptionhandling/TimeoutException.java b/core-java-modules/core-java-lang/src/main/java/com/baeldung/exceptionhandling/TimeoutException.java similarity index 95% rename from core-java-lang/src/main/java/com/baeldung/exceptionhandling/TimeoutException.java rename to core-java-modules/core-java-lang/src/main/java/com/baeldung/exceptionhandling/TimeoutException.java index 294ad542d3..0211284e5d 100644 --- a/core-java-lang/src/main/java/com/baeldung/exceptionhandling/TimeoutException.java +++ b/core-java-modules/core-java-lang/src/main/java/com/baeldung/exceptionhandling/TimeoutException.java @@ -1,8 +1,8 @@ -package com.baeldung.exceptionhandling; - -public class TimeoutException extends Exception { - - public TimeoutException(String message) { - super(message); - } -} +package com.baeldung.exceptionhandling; + +public class TimeoutException extends Exception { + + public TimeoutException(String message) { + super(message); + } +} diff --git a/core-java-lang/src/main/java/com/baeldung/finalize/CloseableResource.java b/core-java-modules/core-java-lang/src/main/java/com/baeldung/finalize/CloseableResource.java similarity index 100% rename from core-java-lang/src/main/java/com/baeldung/finalize/CloseableResource.java rename to core-java-modules/core-java-lang/src/main/java/com/baeldung/finalize/CloseableResource.java diff --git a/core-java-lang/src/main/java/com/baeldung/finalize/Finalizable.java b/core-java-modules/core-java-lang/src/main/java/com/baeldung/finalize/Finalizable.java similarity index 100% rename from core-java-lang/src/main/java/com/baeldung/finalize/Finalizable.java rename to core-java-modules/core-java-lang/src/main/java/com/baeldung/finalize/Finalizable.java diff --git a/core-java-lang/src/main/java/com/baeldung/interfaces/Box.java b/core-java-modules/core-java-lang/src/main/java/com/baeldung/interfaces/Box.java similarity index 100% rename from core-java-lang/src/main/java/com/baeldung/interfaces/Box.java rename to core-java-modules/core-java-lang/src/main/java/com/baeldung/interfaces/Box.java diff --git a/core-java-lang/src/main/java/com/baeldung/interfaces/CommaSeparatedCustomers.java b/core-java-modules/core-java-lang/src/main/java/com/baeldung/interfaces/CommaSeparatedCustomers.java similarity index 100% rename from core-java-lang/src/main/java/com/baeldung/interfaces/CommaSeparatedCustomers.java rename to core-java-modules/core-java-lang/src/main/java/com/baeldung/interfaces/CommaSeparatedCustomers.java diff --git a/core-java-lang/src/main/java/com/baeldung/interfaces/Customer.java b/core-java-modules/core-java-lang/src/main/java/com/baeldung/interfaces/Customer.java similarity index 100% rename from core-java-lang/src/main/java/com/baeldung/interfaces/Customer.java rename to core-java-modules/core-java-lang/src/main/java/com/baeldung/interfaces/Customer.java diff --git a/core-java-lang/src/main/java/com/baeldung/interfaces/Employee.java b/core-java-modules/core-java-lang/src/main/java/com/baeldung/interfaces/Employee.java similarity index 100% rename from core-java-lang/src/main/java/com/baeldung/interfaces/Employee.java rename to core-java-modules/core-java-lang/src/main/java/com/baeldung/interfaces/Employee.java diff --git a/core-java-lang/src/main/java/com/baeldung/interfaces/EmployeeSalaryComparator.java b/core-java-modules/core-java-lang/src/main/java/com/baeldung/interfaces/EmployeeSalaryComparator.java similarity index 100% rename from core-java-lang/src/main/java/com/baeldung/interfaces/EmployeeSalaryComparator.java rename to core-java-modules/core-java-lang/src/main/java/com/baeldung/interfaces/EmployeeSalaryComparator.java diff --git a/core-java-lang/src/main/java/com/baeldung/interfaces/HasColor.java b/core-java-modules/core-java-lang/src/main/java/com/baeldung/interfaces/HasColor.java similarity index 100% rename from core-java-lang/src/main/java/com/baeldung/interfaces/HasColor.java rename to core-java-modules/core-java-lang/src/main/java/com/baeldung/interfaces/HasColor.java diff --git a/core-java-lang/src/main/java/com/baeldung/interfaces/multiinheritance/Car.java b/core-java-modules/core-java-lang/src/main/java/com/baeldung/interfaces/multiinheritance/Car.java similarity index 100% rename from core-java-lang/src/main/java/com/baeldung/interfaces/multiinheritance/Car.java rename to core-java-modules/core-java-lang/src/main/java/com/baeldung/interfaces/multiinheritance/Car.java diff --git a/core-java-lang/src/main/java/com/baeldung/interfaces/multiinheritance/Fly.java b/core-java-modules/core-java-lang/src/main/java/com/baeldung/interfaces/multiinheritance/Fly.java similarity index 100% rename from core-java-lang/src/main/java/com/baeldung/interfaces/multiinheritance/Fly.java rename to core-java-modules/core-java-lang/src/main/java/com/baeldung/interfaces/multiinheritance/Fly.java diff --git a/core-java-lang/src/main/java/com/baeldung/interfaces/multiinheritance/Transform.java b/core-java-modules/core-java-lang/src/main/java/com/baeldung/interfaces/multiinheritance/Transform.java similarity index 100% rename from core-java-lang/src/main/java/com/baeldung/interfaces/multiinheritance/Transform.java rename to core-java-modules/core-java-lang/src/main/java/com/baeldung/interfaces/multiinheritance/Transform.java diff --git a/core-java-lang/src/main/java/com/baeldung/interfaces/multiinheritance/Vehicle.java b/core-java-modules/core-java-lang/src/main/java/com/baeldung/interfaces/multiinheritance/Vehicle.java similarity index 100% rename from core-java-lang/src/main/java/com/baeldung/interfaces/multiinheritance/Vehicle.java rename to core-java-modules/core-java-lang/src/main/java/com/baeldung/interfaces/multiinheritance/Vehicle.java diff --git a/core-java-lang/src/main/java/com/baeldung/interfaces/polymorphysim/Circle.java b/core-java-modules/core-java-lang/src/main/java/com/baeldung/interfaces/polymorphysim/Circle.java similarity index 100% rename from core-java-lang/src/main/java/com/baeldung/interfaces/polymorphysim/Circle.java rename to core-java-modules/core-java-lang/src/main/java/com/baeldung/interfaces/polymorphysim/Circle.java diff --git a/core-java-lang/src/main/java/com/baeldung/interfaces/polymorphysim/MainTestClass.java b/core-java-modules/core-java-lang/src/main/java/com/baeldung/interfaces/polymorphysim/MainTestClass.java similarity index 100% rename from core-java-lang/src/main/java/com/baeldung/interfaces/polymorphysim/MainTestClass.java rename to core-java-modules/core-java-lang/src/main/java/com/baeldung/interfaces/polymorphysim/MainTestClass.java diff --git a/core-java-lang/src/main/java/com/baeldung/interfaces/polymorphysim/Shape.java b/core-java-modules/core-java-lang/src/main/java/com/baeldung/interfaces/polymorphysim/Shape.java similarity index 100% rename from core-java-lang/src/main/java/com/baeldung/interfaces/polymorphysim/Shape.java rename to core-java-modules/core-java-lang/src/main/java/com/baeldung/interfaces/polymorphysim/Shape.java diff --git a/core-java-lang/src/main/java/com/baeldung/interfaces/polymorphysim/Square.java b/core-java-modules/core-java-lang/src/main/java/com/baeldung/interfaces/polymorphysim/Square.java similarity index 100% rename from core-java-lang/src/main/java/com/baeldung/interfaces/polymorphysim/Square.java rename to core-java-modules/core-java-lang/src/main/java/com/baeldung/interfaces/polymorphysim/Square.java diff --git a/core-java-lang/src/main/java/com/baeldung/java/reflection/Animal.java b/core-java-modules/core-java-lang/src/main/java/com/baeldung/java/reflection/Animal.java similarity index 100% rename from core-java-lang/src/main/java/com/baeldung/java/reflection/Animal.java rename to core-java-modules/core-java-lang/src/main/java/com/baeldung/java/reflection/Animal.java diff --git a/core-java-lang/src/main/java/com/baeldung/java/reflection/Bird.java b/core-java-modules/core-java-lang/src/main/java/com/baeldung/java/reflection/Bird.java similarity index 100% rename from core-java-lang/src/main/java/com/baeldung/java/reflection/Bird.java rename to core-java-modules/core-java-lang/src/main/java/com/baeldung/java/reflection/Bird.java diff --git a/core-java-lang/src/main/java/com/baeldung/java/reflection/DynamicGreeter.java b/core-java-modules/core-java-lang/src/main/java/com/baeldung/java/reflection/DynamicGreeter.java similarity index 100% rename from core-java-lang/src/main/java/com/baeldung/java/reflection/DynamicGreeter.java rename to core-java-modules/core-java-lang/src/main/java/com/baeldung/java/reflection/DynamicGreeter.java diff --git a/core-java-lang/src/main/java/com/baeldung/java/reflection/Eating.java b/core-java-modules/core-java-lang/src/main/java/com/baeldung/java/reflection/Eating.java similarity index 100% rename from core-java-lang/src/main/java/com/baeldung/java/reflection/Eating.java rename to core-java-modules/core-java-lang/src/main/java/com/baeldung/java/reflection/Eating.java diff --git a/core-java-lang/src/main/java/com/baeldung/java/reflection/Goat.java b/core-java-modules/core-java-lang/src/main/java/com/baeldung/java/reflection/Goat.java similarity index 100% rename from core-java-lang/src/main/java/com/baeldung/java/reflection/Goat.java rename to core-java-modules/core-java-lang/src/main/java/com/baeldung/java/reflection/Goat.java diff --git a/core-java-lang/src/main/java/com/baeldung/java/reflection/Greeter.java b/core-java-modules/core-java-lang/src/main/java/com/baeldung/java/reflection/Greeter.java similarity index 100% rename from core-java-lang/src/main/java/com/baeldung/java/reflection/Greeter.java rename to core-java-modules/core-java-lang/src/main/java/com/baeldung/java/reflection/Greeter.java diff --git a/core-java-lang/src/main/java/com/baeldung/java/reflection/GreetingAnnotation.java b/core-java-modules/core-java-lang/src/main/java/com/baeldung/java/reflection/GreetingAnnotation.java similarity index 100% rename from core-java-lang/src/main/java/com/baeldung/java/reflection/GreetingAnnotation.java rename to core-java-modules/core-java-lang/src/main/java/com/baeldung/java/reflection/GreetingAnnotation.java diff --git a/core-java-lang/src/main/java/com/baeldung/java/reflection/Greetings.java b/core-java-modules/core-java-lang/src/main/java/com/baeldung/java/reflection/Greetings.java similarity index 100% rename from core-java-lang/src/main/java/com/baeldung/java/reflection/Greetings.java rename to core-java-modules/core-java-lang/src/main/java/com/baeldung/java/reflection/Greetings.java diff --git a/core-java-lang/src/main/java/com/baeldung/java/reflection/Locomotion.java b/core-java-modules/core-java-lang/src/main/java/com/baeldung/java/reflection/Locomotion.java similarity index 100% rename from core-java-lang/src/main/java/com/baeldung/java/reflection/Locomotion.java rename to core-java-modules/core-java-lang/src/main/java/com/baeldung/java/reflection/Locomotion.java diff --git a/core-java-lang/src/main/java/com/baeldung/java/reflection/Operations.java b/core-java-modules/core-java-lang/src/main/java/com/baeldung/java/reflection/Operations.java similarity index 100% rename from core-java-lang/src/main/java/com/baeldung/java/reflection/Operations.java rename to core-java-modules/core-java-lang/src/main/java/com/baeldung/java/reflection/Operations.java diff --git a/core-java-lang/src/main/java/com/baeldung/java/reflection/Person.java b/core-java-modules/core-java-lang/src/main/java/com/baeldung/java/reflection/Person.java similarity index 100% rename from core-java-lang/src/main/java/com/baeldung/java/reflection/Person.java rename to core-java-modules/core-java-lang/src/main/java/com/baeldung/java/reflection/Person.java diff --git a/core-java-lang/src/main/java/com/baeldung/keywords/finalize/FinalizeObject.java b/core-java-modules/core-java-lang/src/main/java/com/baeldung/keywords/finalize/FinalizeObject.java similarity index 100% rename from core-java-lang/src/main/java/com/baeldung/keywords/finalize/FinalizeObject.java rename to core-java-modules/core-java-lang/src/main/java/com/baeldung/keywords/finalize/FinalizeObject.java diff --git a/core-java-lang/src/main/java/com/baeldung/keywords/finalkeyword/Child.java b/core-java-modules/core-java-lang/src/main/java/com/baeldung/keywords/finalkeyword/Child.java similarity index 100% rename from core-java-lang/src/main/java/com/baeldung/keywords/finalkeyword/Child.java rename to core-java-modules/core-java-lang/src/main/java/com/baeldung/keywords/finalkeyword/Child.java diff --git a/core-java-lang/src/main/java/com/baeldung/keywords/finalkeyword/GrandChild.java b/core-java-modules/core-java-lang/src/main/java/com/baeldung/keywords/finalkeyword/GrandChild.java similarity index 100% rename from core-java-lang/src/main/java/com/baeldung/keywords/finalkeyword/GrandChild.java rename to core-java-modules/core-java-lang/src/main/java/com/baeldung/keywords/finalkeyword/GrandChild.java diff --git a/core-java-lang/src/main/java/com/baeldung/keywords/finalkeyword/Parent.java b/core-java-modules/core-java-lang/src/main/java/com/baeldung/keywords/finalkeyword/Parent.java similarity index 100% rename from core-java-lang/src/main/java/com/baeldung/keywords/finalkeyword/Parent.java rename to core-java-modules/core-java-lang/src/main/java/com/baeldung/keywords/finalkeyword/Parent.java diff --git a/core-java-lang/src/main/java/com/baeldung/keywords/finallykeyword/FinallyExample.java b/core-java-modules/core-java-lang/src/main/java/com/baeldung/keywords/finallykeyword/FinallyExample.java similarity index 100% rename from core-java-lang/src/main/java/com/baeldung/keywords/finallykeyword/FinallyExample.java rename to core-java-modules/core-java-lang/src/main/java/com/baeldung/keywords/finallykeyword/FinallyExample.java diff --git a/core-java-lang/src/main/java/com/baeldung/nativekeyword/DateTimeUtils.java b/core-java-modules/core-java-lang/src/main/java/com/baeldung/nativekeyword/DateTimeUtils.java similarity index 100% rename from core-java-lang/src/main/java/com/baeldung/nativekeyword/DateTimeUtils.java rename to core-java-modules/core-java-lang/src/main/java/com/baeldung/nativekeyword/DateTimeUtils.java diff --git a/core-java-lang/src/main/java/com/baeldung/nativekeyword/NativeMainApp.java b/core-java-modules/core-java-lang/src/main/java/com/baeldung/nativekeyword/NativeMainApp.java similarity index 100% rename from core-java-lang/src/main/java/com/baeldung/nativekeyword/NativeMainApp.java rename to core-java-modules/core-java-lang/src/main/java/com/baeldung/nativekeyword/NativeMainApp.java diff --git a/core-java-lang/src/main/java/com/baeldung/noclassdeffounderror/ClassWithInitErrors.java b/core-java-modules/core-java-lang/src/main/java/com/baeldung/noclassdeffounderror/ClassWithInitErrors.java similarity index 95% rename from core-java-lang/src/main/java/com/baeldung/noclassdeffounderror/ClassWithInitErrors.java rename to core-java-modules/core-java-lang/src/main/java/com/baeldung/noclassdeffounderror/ClassWithInitErrors.java index 2b19f3496d..b5b357a322 100644 --- a/core-java-lang/src/main/java/com/baeldung/noclassdeffounderror/ClassWithInitErrors.java +++ b/core-java-modules/core-java-lang/src/main/java/com/baeldung/noclassdeffounderror/ClassWithInitErrors.java @@ -1,5 +1,5 @@ -package com.baeldung.noclassdeffounderror; - -public class ClassWithInitErrors { - static int data = 1 / 0; -} +package com.baeldung.noclassdeffounderror; + +public class ClassWithInitErrors { + static int data = 1 / 0; +} diff --git a/core-java-lang/src/main/java/com/baeldung/noclassdeffounderror/NoClassDefFoundErrorExample.java b/core-java-modules/core-java-lang/src/main/java/com/baeldung/noclassdeffounderror/NoClassDefFoundErrorExample.java similarity index 96% rename from core-java-lang/src/main/java/com/baeldung/noclassdeffounderror/NoClassDefFoundErrorExample.java rename to core-java-modules/core-java-lang/src/main/java/com/baeldung/noclassdeffounderror/NoClassDefFoundErrorExample.java index 0d02391a73..7bcefbdbd3 100644 --- a/core-java-lang/src/main/java/com/baeldung/noclassdeffounderror/NoClassDefFoundErrorExample.java +++ b/core-java-modules/core-java-lang/src/main/java/com/baeldung/noclassdeffounderror/NoClassDefFoundErrorExample.java @@ -1,14 +1,14 @@ -package com.baeldung.noclassdeffounderror; - -public class NoClassDefFoundErrorExample { - public ClassWithInitErrors getClassWithInitErrors() { - ClassWithInitErrors test; - try { - test = new ClassWithInitErrors(); - } catch (Throwable t) { - System.out.println(t); - } - test = new ClassWithInitErrors(); - return test; - } +package com.baeldung.noclassdeffounderror; + +public class NoClassDefFoundErrorExample { + public ClassWithInitErrors getClassWithInitErrors() { + ClassWithInitErrors test; + try { + test = new ClassWithInitErrors(); + } catch (Throwable t) { + System.out.println(t); + } + test = new ClassWithInitErrors(); + return test; + } } \ No newline at end of file diff --git a/core-java-lang/src/main/java/com/baeldung/objects/Car.java b/core-java-modules/core-java-lang/src/main/java/com/baeldung/objects/Car.java similarity index 100% rename from core-java-lang/src/main/java/com/baeldung/objects/Car.java rename to core-java-modules/core-java-lang/src/main/java/com/baeldung/objects/Car.java diff --git a/core-java-lang/src/main/java/com/baeldung/packages/TodoApp.java b/core-java-modules/core-java-lang/src/main/java/com/baeldung/packages/TodoApp.java similarity index 100% rename from core-java-lang/src/main/java/com/baeldung/packages/TodoApp.java rename to core-java-modules/core-java-lang/src/main/java/com/baeldung/packages/TodoApp.java diff --git a/core-java-lang/src/main/java/com/baeldung/packages/TodoList.java b/core-java-modules/core-java-lang/src/main/java/com/baeldung/packages/TodoList.java similarity index 100% rename from core-java-lang/src/main/java/com/baeldung/packages/TodoList.java rename to core-java-modules/core-java-lang/src/main/java/com/baeldung/packages/TodoList.java diff --git a/core-java-lang/src/main/java/com/baeldung/packages/domain/TodoItem.java b/core-java-modules/core-java-lang/src/main/java/com/baeldung/packages/domain/TodoItem.java similarity index 100% rename from core-java-lang/src/main/java/com/baeldung/packages/domain/TodoItem.java rename to core-java-modules/core-java-lang/src/main/java/com/baeldung/packages/domain/TodoItem.java diff --git a/core-java-lang/src/main/java/com/baeldung/parameterpassing/NonPrimitives.java b/core-java-modules/core-java-lang/src/main/java/com/baeldung/parameterpassing/NonPrimitives.java similarity index 100% rename from core-java-lang/src/main/java/com/baeldung/parameterpassing/NonPrimitives.java rename to core-java-modules/core-java-lang/src/main/java/com/baeldung/parameterpassing/NonPrimitives.java diff --git a/core-java-lang/src/main/java/com/baeldung/parameterpassing/Primitives.java b/core-java-modules/core-java-lang/src/main/java/com/baeldung/parameterpassing/Primitives.java similarity index 100% rename from core-java-lang/src/main/java/com/baeldung/parameterpassing/Primitives.java rename to core-java-modules/core-java-lang/src/main/java/com/baeldung/parameterpassing/Primitives.java diff --git a/core-java-lang/src/main/java/com/baeldung/recursion/BinaryNode.java b/core-java-modules/core-java-lang/src/main/java/com/baeldung/recursion/BinaryNode.java similarity index 95% rename from core-java-lang/src/main/java/com/baeldung/recursion/BinaryNode.java rename to core-java-modules/core-java-lang/src/main/java/com/baeldung/recursion/BinaryNode.java index 0c3f0ecc40..c5dd746a4c 100644 --- a/core-java-lang/src/main/java/com/baeldung/recursion/BinaryNode.java +++ b/core-java-modules/core-java-lang/src/main/java/com/baeldung/recursion/BinaryNode.java @@ -1,31 +1,31 @@ -package com.baeldung.recursion; - -public class BinaryNode { - int value; - BinaryNode left; - BinaryNode right; - - public BinaryNode(int value){ - this.value = value; - } - - public int getValue() { - return value; - } - public void setValue(int value) { - this.value = value; - } - public BinaryNode getLeft() { - return left; - } - public void setLeft(BinaryNode left) { - this.left = left; - } - public BinaryNode getRight() { - return right; - } - public void setRight(BinaryNode right) { - this.right = right; - } - -} +package com.baeldung.recursion; + +public class BinaryNode { + int value; + BinaryNode left; + BinaryNode right; + + public BinaryNode(int value){ + this.value = value; + } + + public int getValue() { + return value; + } + public void setValue(int value) { + this.value = value; + } + public BinaryNode getLeft() { + return left; + } + public void setLeft(BinaryNode left) { + this.left = left; + } + public BinaryNode getRight() { + return right; + } + public void setRight(BinaryNode right) { + this.right = right; + } + +} diff --git a/core-java-lang/src/main/java/com/baeldung/recursion/RecursionExample.java b/core-java-modules/core-java-lang/src/main/java/com/baeldung/recursion/RecursionExample.java similarity index 95% rename from core-java-lang/src/main/java/com/baeldung/recursion/RecursionExample.java rename to core-java-modules/core-java-lang/src/main/java/com/baeldung/recursion/RecursionExample.java index 649c0e0587..b6800d2e7e 100644 --- a/core-java-lang/src/main/java/com/baeldung/recursion/RecursionExample.java +++ b/core-java-modules/core-java-lang/src/main/java/com/baeldung/recursion/RecursionExample.java @@ -1,64 +1,64 @@ -package com.baeldung.recursion; - -public class RecursionExample { - - public int sum(int n){ - if (n >= 1){ - return sum(n - 1) + n; - } - return n; - } - - public int tailSum(int currentSum, int n){ - if (n <= 1) { - return currentSum + n; - } - return tailSum(currentSum + n, n - 1); - } - - public int iterativeSum(int n){ - int sum = 0; - if(n < 0){ - return -1; - } - for(int i=0; i<=n; i++){ - sum += i; - } - return sum; - } - - public int powerOf10(int n){ - if (n == 0){ - return 1; - } - return powerOf10(n-1)*10; - } - - public int fibonacci(int n){ - if (n <=1 ){ - return n; - } - return fibonacci(n-1) + fibonacci(n-2); - } - - public String toBinary(int n){ - if (n <= 1 ){ - return String.valueOf(n); - } - return toBinary(n / 2) + String.valueOf(n % 2); - } - - public int calculateTreeHeight(BinaryNode root){ - if (root!= null){ - if (root.getLeft() != null || root.getRight() != null){ - return 1 + max(calculateTreeHeight(root.left) , calculateTreeHeight(root.right)); - } - } - return 0; - } - - public int max(int a,int b){ - return a>b ? a:b; - } - -} +package com.baeldung.recursion; + +public class RecursionExample { + + public int sum(int n){ + if (n >= 1){ + return sum(n - 1) + n; + } + return n; + } + + public int tailSum(int currentSum, int n){ + if (n <= 1) { + return currentSum + n; + } + return tailSum(currentSum + n, n - 1); + } + + public int iterativeSum(int n){ + int sum = 0; + if(n < 0){ + return -1; + } + for(int i=0; i<=n; i++){ + sum += i; + } + return sum; + } + + public int powerOf10(int n){ + if (n == 0){ + return 1; + } + return powerOf10(n-1)*10; + } + + public int fibonacci(int n){ + if (n <=1 ){ + return n; + } + return fibonacci(n-1) + fibonacci(n-2); + } + + public String toBinary(int n){ + if (n <= 1 ){ + return String.valueOf(n); + } + return toBinary(n / 2) + String.valueOf(n % 2); + } + + public int calculateTreeHeight(BinaryNode root){ + if (root!= null){ + if (root.getLeft() != null || root.getRight() != null){ + return 1 + max(calculateTreeHeight(root.left) , calculateTreeHeight(root.right)); + } + } + return 0; + } + + public int max(int a,int b){ + return a>b ? a:b; + } + +} diff --git a/core-java-lang/src/main/java/com/baeldung/scope/BracketScopeExample.java b/core-java-modules/core-java-lang/src/main/java/com/baeldung/scope/BracketScopeExample.java similarity index 100% rename from core-java-lang/src/main/java/com/baeldung/scope/BracketScopeExample.java rename to core-java-modules/core-java-lang/src/main/java/com/baeldung/scope/BracketScopeExample.java diff --git a/core-java-lang/src/main/java/com/baeldung/scope/ClassScopeExample.java b/core-java-modules/core-java-lang/src/main/java/com/baeldung/scope/ClassScopeExample.java similarity index 100% rename from core-java-lang/src/main/java/com/baeldung/scope/ClassScopeExample.java rename to core-java-modules/core-java-lang/src/main/java/com/baeldung/scope/ClassScopeExample.java diff --git a/core-java-lang/src/main/java/com/baeldung/scope/LoopScopeExample.java b/core-java-modules/core-java-lang/src/main/java/com/baeldung/scope/LoopScopeExample.java similarity index 100% rename from core-java-lang/src/main/java/com/baeldung/scope/LoopScopeExample.java rename to core-java-modules/core-java-lang/src/main/java/com/baeldung/scope/LoopScopeExample.java diff --git a/core-java-lang/src/main/java/com/baeldung/scope/MethodScopeExample.java b/core-java-modules/core-java-lang/src/main/java/com/baeldung/scope/MethodScopeExample.java similarity index 100% rename from core-java-lang/src/main/java/com/baeldung/scope/MethodScopeExample.java rename to core-java-modules/core-java-lang/src/main/java/com/baeldung/scope/MethodScopeExample.java diff --git a/core-java-lang/src/main/java/com/baeldung/scope/NestedScopesExample.java b/core-java-modules/core-java-lang/src/main/java/com/baeldung/scope/NestedScopesExample.java similarity index 100% rename from core-java-lang/src/main/java/com/baeldung/scope/NestedScopesExample.java rename to core-java-modules/core-java-lang/src/main/java/com/baeldung/scope/NestedScopesExample.java diff --git a/core-java-lang/src/main/java/com/baeldung/sneakythrows/SneakyRunnable.java b/core-java-modules/core-java-lang/src/main/java/com/baeldung/sneakythrows/SneakyRunnable.java similarity index 100% rename from core-java-lang/src/main/java/com/baeldung/sneakythrows/SneakyRunnable.java rename to core-java-modules/core-java-lang/src/main/java/com/baeldung/sneakythrows/SneakyRunnable.java diff --git a/core-java-lang/src/main/java/com/baeldung/sneakythrows/SneakyThrows.java b/core-java-modules/core-java-lang/src/main/java/com/baeldung/sneakythrows/SneakyThrows.java similarity index 100% rename from core-java-lang/src/main/java/com/baeldung/sneakythrows/SneakyThrows.java rename to core-java-modules/core-java-lang/src/main/java/com/baeldung/sneakythrows/SneakyThrows.java diff --git a/core-java-lang/src/main/java/com/baeldung/stackoverflowerror/AccountHolder.java b/core-java-modules/core-java-lang/src/main/java/com/baeldung/stackoverflowerror/AccountHolder.java similarity index 96% rename from core-java-lang/src/main/java/com/baeldung/stackoverflowerror/AccountHolder.java rename to core-java-modules/core-java-lang/src/main/java/com/baeldung/stackoverflowerror/AccountHolder.java index 9555433792..91b8a3bbb0 100644 --- a/core-java-lang/src/main/java/com/baeldung/stackoverflowerror/AccountHolder.java +++ b/core-java-modules/core-java-lang/src/main/java/com/baeldung/stackoverflowerror/AccountHolder.java @@ -1,8 +1,8 @@ -package com.baeldung.stackoverflowerror; - -public class AccountHolder { - private String firstName; - private String lastName; - - AccountHolder jointAccountHolder = new AccountHolder(); -} +package com.baeldung.stackoverflowerror; + +public class AccountHolder { + private String firstName; + private String lastName; + + AccountHolder jointAccountHolder = new AccountHolder(); +} diff --git a/core-java-lang/src/main/java/com/baeldung/stackoverflowerror/ClassOne.java b/core-java-modules/core-java-lang/src/main/java/com/baeldung/stackoverflowerror/ClassOne.java similarity index 95% rename from core-java-lang/src/main/java/com/baeldung/stackoverflowerror/ClassOne.java rename to core-java-modules/core-java-lang/src/main/java/com/baeldung/stackoverflowerror/ClassOne.java index 99ef2b4f92..3b95fd1368 100644 --- a/core-java-lang/src/main/java/com/baeldung/stackoverflowerror/ClassOne.java +++ b/core-java-modules/core-java-lang/src/main/java/com/baeldung/stackoverflowerror/ClassOne.java @@ -1,16 +1,16 @@ -package com.baeldung.stackoverflowerror; - -public class ClassOne { - private int oneValue; - private ClassTwo clsTwoInstance = null; - - public ClassOne() { - oneValue = 0; - clsTwoInstance = new ClassTwo(); - } - - public ClassOne(int oneValue, ClassTwo clsTwoInstance) { - this.oneValue = oneValue; - this.clsTwoInstance = clsTwoInstance; - } -} +package com.baeldung.stackoverflowerror; + +public class ClassOne { + private int oneValue; + private ClassTwo clsTwoInstance = null; + + public ClassOne() { + oneValue = 0; + clsTwoInstance = new ClassTwo(); + } + + public ClassOne(int oneValue, ClassTwo clsTwoInstance) { + this.oneValue = oneValue; + this.clsTwoInstance = clsTwoInstance; + } +} diff --git a/core-java-lang/src/main/java/com/baeldung/stackoverflowerror/ClassTwo.java b/core-java-modules/core-java-lang/src/main/java/com/baeldung/stackoverflowerror/ClassTwo.java similarity index 95% rename from core-java-lang/src/main/java/com/baeldung/stackoverflowerror/ClassTwo.java rename to core-java-modules/core-java-lang/src/main/java/com/baeldung/stackoverflowerror/ClassTwo.java index 0d34ac3c32..0adf075b43 100644 --- a/core-java-lang/src/main/java/com/baeldung/stackoverflowerror/ClassTwo.java +++ b/core-java-modules/core-java-lang/src/main/java/com/baeldung/stackoverflowerror/ClassTwo.java @@ -1,16 +1,16 @@ -package com.baeldung.stackoverflowerror; - -public class ClassTwo { - private int twoValue; - private ClassOne clsOneInstance = null; - - public ClassTwo() { - twoValue = 10; - clsOneInstance = new ClassOne(); - } - - public ClassTwo(int twoValue, ClassOne clsOneInstance) { - this.twoValue = twoValue; - this.clsOneInstance = clsOneInstance; - } -} +package com.baeldung.stackoverflowerror; + +public class ClassTwo { + private int twoValue; + private ClassOne clsOneInstance = null; + + public ClassTwo() { + twoValue = 10; + clsOneInstance = new ClassOne(); + } + + public ClassTwo(int twoValue, ClassOne clsOneInstance) { + this.twoValue = twoValue; + this.clsOneInstance = clsOneInstance; + } +} diff --git a/core-java-lang/src/main/java/com/baeldung/stackoverflowerror/InfiniteRecursionWithTerminationCondition.java b/core-java-modules/core-java-lang/src/main/java/com/baeldung/stackoverflowerror/InfiniteRecursionWithTerminationCondition.java similarity index 97% rename from core-java-lang/src/main/java/com/baeldung/stackoverflowerror/InfiniteRecursionWithTerminationCondition.java rename to core-java-modules/core-java-lang/src/main/java/com/baeldung/stackoverflowerror/InfiniteRecursionWithTerminationCondition.java index 9fb00d4b83..c67eeb30d1 100644 --- a/core-java-lang/src/main/java/com/baeldung/stackoverflowerror/InfiniteRecursionWithTerminationCondition.java +++ b/core-java-modules/core-java-lang/src/main/java/com/baeldung/stackoverflowerror/InfiniteRecursionWithTerminationCondition.java @@ -1,7 +1,7 @@ -package com.baeldung.stackoverflowerror; - -public class InfiniteRecursionWithTerminationCondition { - public int calculateFactorial(final int number) { - return number == 1 ? 1 : number * calculateFactorial(number - 1); - } -} +package com.baeldung.stackoverflowerror; + +public class InfiniteRecursionWithTerminationCondition { + public int calculateFactorial(final int number) { + return number == 1 ? 1 : number * calculateFactorial(number - 1); + } +} diff --git a/core-java-lang/src/main/java/com/baeldung/stackoverflowerror/RecursionWithCorrectTerminationCondition.java b/core-java-modules/core-java-lang/src/main/java/com/baeldung/stackoverflowerror/RecursionWithCorrectTerminationCondition.java similarity index 97% rename from core-java-lang/src/main/java/com/baeldung/stackoverflowerror/RecursionWithCorrectTerminationCondition.java rename to core-java-modules/core-java-lang/src/main/java/com/baeldung/stackoverflowerror/RecursionWithCorrectTerminationCondition.java index 16d771f389..8d10c65dcc 100644 --- a/core-java-lang/src/main/java/com/baeldung/stackoverflowerror/RecursionWithCorrectTerminationCondition.java +++ b/core-java-modules/core-java-lang/src/main/java/com/baeldung/stackoverflowerror/RecursionWithCorrectTerminationCondition.java @@ -1,7 +1,7 @@ -package com.baeldung.stackoverflowerror; - -public class RecursionWithCorrectTerminationCondition { - public int calculateFactorial(final int number) { - return number <= 1 ? 1 : number * calculateFactorial(number - 1); - } -} +package com.baeldung.stackoverflowerror; + +public class RecursionWithCorrectTerminationCondition { + public int calculateFactorial(final int number) { + return number <= 1 ? 1 : number * calculateFactorial(number - 1); + } +} diff --git a/core-java-lang/src/main/java/com/baeldung/stackoverflowerror/UnintendedInfiniteRecursion.java b/core-java-modules/core-java-lang/src/main/java/com/baeldung/stackoverflowerror/UnintendedInfiniteRecursion.java similarity index 96% rename from core-java-lang/src/main/java/com/baeldung/stackoverflowerror/UnintendedInfiniteRecursion.java rename to core-java-modules/core-java-lang/src/main/java/com/baeldung/stackoverflowerror/UnintendedInfiniteRecursion.java index f5160c3eb3..0b7fb3cf94 100644 --- a/core-java-lang/src/main/java/com/baeldung/stackoverflowerror/UnintendedInfiniteRecursion.java +++ b/core-java-modules/core-java-lang/src/main/java/com/baeldung/stackoverflowerror/UnintendedInfiniteRecursion.java @@ -1,7 +1,7 @@ -package com.baeldung.stackoverflowerror; - -public class UnintendedInfiniteRecursion { - public int calculateFactorial(int number) { - return number * calculateFactorial(number - 1); - } -} +package com.baeldung.stackoverflowerror; + +public class UnintendedInfiniteRecursion { + public int calculateFactorial(int number) { + return number * calculateFactorial(number - 1); + } +} diff --git a/core-java-lang/src/main/java/com/baeldung/synthetic/BridgeMethodDemo.java b/core-java-modules/core-java-lang/src/main/java/com/baeldung/synthetic/BridgeMethodDemo.java similarity index 100% rename from core-java-lang/src/main/java/com/baeldung/synthetic/BridgeMethodDemo.java rename to core-java-modules/core-java-lang/src/main/java/com/baeldung/synthetic/BridgeMethodDemo.java diff --git a/core-java-lang/src/main/java/com/baeldung/synthetic/SyntheticConstructorDemo.java b/core-java-modules/core-java-lang/src/main/java/com/baeldung/synthetic/SyntheticConstructorDemo.java similarity index 100% rename from core-java-lang/src/main/java/com/baeldung/synthetic/SyntheticConstructorDemo.java rename to core-java-modules/core-java-lang/src/main/java/com/baeldung/synthetic/SyntheticConstructorDemo.java diff --git a/core-java-lang/src/main/java/com/baeldung/synthetic/SyntheticFieldDemo.java b/core-java-modules/core-java-lang/src/main/java/com/baeldung/synthetic/SyntheticFieldDemo.java similarity index 100% rename from core-java-lang/src/main/java/com/baeldung/synthetic/SyntheticFieldDemo.java rename to core-java-modules/core-java-lang/src/main/java/com/baeldung/synthetic/SyntheticFieldDemo.java diff --git a/core-java-lang/src/main/java/com/baeldung/synthetic/SyntheticMethodDemo.java b/core-java-modules/core-java-lang/src/main/java/com/baeldung/synthetic/SyntheticMethodDemo.java similarity index 100% rename from core-java-lang/src/main/java/com/baeldung/synthetic/SyntheticMethodDemo.java rename to core-java-modules/core-java-lang/src/main/java/com/baeldung/synthetic/SyntheticMethodDemo.java diff --git a/core-java-lang/src/main/java/com/baeldung/throwsexception/DataAccessException.java b/core-java-modules/core-java-lang/src/main/java/com/baeldung/throwsexception/DataAccessException.java similarity index 100% rename from core-java-lang/src/main/java/com/baeldung/throwsexception/DataAccessException.java rename to core-java-modules/core-java-lang/src/main/java/com/baeldung/throwsexception/DataAccessException.java diff --git a/core-java-lang/src/main/java/com/baeldung/throwsexception/Main.java b/core-java-modules/core-java-lang/src/main/java/com/baeldung/throwsexception/Main.java similarity index 100% rename from core-java-lang/src/main/java/com/baeldung/throwsexception/Main.java rename to core-java-modules/core-java-lang/src/main/java/com/baeldung/throwsexception/Main.java diff --git a/core-java-lang/src/main/java/com/baeldung/throwsexception/PersonRepository.java b/core-java-modules/core-java-lang/src/main/java/com/baeldung/throwsexception/PersonRepository.java similarity index 100% rename from core-java-lang/src/main/java/com/baeldung/throwsexception/PersonRepository.java rename to core-java-modules/core-java-lang/src/main/java/com/baeldung/throwsexception/PersonRepository.java diff --git a/core-java-lang/src/main/java/com/baeldung/throwsexception/SimpleService.java b/core-java-modules/core-java-lang/src/main/java/com/baeldung/throwsexception/SimpleService.java similarity index 100% rename from core-java-lang/src/main/java/com/baeldung/throwsexception/SimpleService.java rename to core-java-modules/core-java-lang/src/main/java/com/baeldung/throwsexception/SimpleService.java diff --git a/core-java-lang/src/main/java/com/baeldung/throwsexception/TryCatch.java b/core-java-modules/core-java-lang/src/main/java/com/baeldung/throwsexception/TryCatch.java similarity index 100% rename from core-java-lang/src/main/java/com/baeldung/throwsexception/TryCatch.java rename to core-java-modules/core-java-lang/src/main/java/com/baeldung/throwsexception/TryCatch.java diff --git a/core-java-lang/src/main/resources/file.txt b/core-java-modules/core-java-lang/src/main/resources/file.txt similarity index 100% rename from core-java-lang/src/main/resources/file.txt rename to core-java-modules/core-java-lang/src/main/resources/file.txt diff --git a/core-java-lang/src/test/java/com/baeldung/binding/AnimalActivityUnitTest.java b/core-java-modules/core-java-lang/src/test/java/com/baeldung/binding/AnimalActivityUnitTest.java similarity index 100% rename from core-java-lang/src/test/java/com/baeldung/binding/AnimalActivityUnitTest.java rename to core-java-modules/core-java-lang/src/test/java/com/baeldung/binding/AnimalActivityUnitTest.java diff --git a/core-java-lang/src/test/java/com/baeldung/binding/AnimalUnitTest.java b/core-java-modules/core-java-lang/src/test/java/com/baeldung/binding/AnimalUnitTest.java similarity index 100% rename from core-java-lang/src/test/java/com/baeldung/binding/AnimalUnitTest.java rename to core-java-modules/core-java-lang/src/test/java/com/baeldung/binding/AnimalUnitTest.java diff --git a/core-java-lang/src/test/java/com/baeldung/binding/CatUnitTest.java b/core-java-modules/core-java-lang/src/test/java/com/baeldung/binding/CatUnitTest.java similarity index 100% rename from core-java-lang/src/test/java/com/baeldung/binding/CatUnitTest.java rename to core-java-modules/core-java-lang/src/test/java/com/baeldung/binding/CatUnitTest.java diff --git a/core-java-lang/src/test/java/com/baeldung/className/RetrievingClassNameUnitTest.java b/core-java-modules/core-java-lang/src/test/java/com/baeldung/className/RetrievingClassNameUnitTest.java similarity index 100% rename from core-java-lang/src/test/java/com/baeldung/className/RetrievingClassNameUnitTest.java rename to core-java-modules/core-java-lang/src/test/java/com/baeldung/className/RetrievingClassNameUnitTest.java diff --git a/core-java-lang/src/test/java/com/baeldung/classnotfoundexception/ClassNotFoundExceptionUnitTest.java b/core-java-modules/core-java-lang/src/test/java/com/baeldung/classnotfoundexception/ClassNotFoundExceptionUnitTest.java similarity index 97% rename from core-java-lang/src/test/java/com/baeldung/classnotfoundexception/ClassNotFoundExceptionUnitTest.java rename to core-java-modules/core-java-lang/src/test/java/com/baeldung/classnotfoundexception/ClassNotFoundExceptionUnitTest.java index b076b0324a..59605fb1c9 100644 --- a/core-java-lang/src/test/java/com/baeldung/classnotfoundexception/ClassNotFoundExceptionUnitTest.java +++ b/core-java-modules/core-java-lang/src/test/java/com/baeldung/classnotfoundexception/ClassNotFoundExceptionUnitTest.java @@ -1,11 +1,11 @@ -package com.baeldung.classnotfoundexception; - -import org.junit.Test; - -public class ClassNotFoundExceptionUnitTest { - - @Test(expected = ClassNotFoundException.class) - public void givenNoDriversInClassPath_whenLoadDrivers_thenClassNotFoundException() throws ClassNotFoundException { - Class.forName("oracle.jdbc.driver.OracleDriver"); - } +package com.baeldung.classnotfoundexception; + +import org.junit.Test; + +public class ClassNotFoundExceptionUnitTest { + + @Test(expected = ClassNotFoundException.class) + public void givenNoDriversInClassPath_whenLoadDrivers_thenClassNotFoundException() throws ClassNotFoundException { + Class.forName("oracle.jdbc.driver.OracleDriver"); + } } \ No newline at end of file diff --git a/core-java-lang/src/test/java/com/baeldung/comparable/ComparableUnitTest.java b/core-java-modules/core-java-lang/src/test/java/com/baeldung/comparable/ComparableUnitTest.java similarity index 100% rename from core-java-lang/src/test/java/com/baeldung/comparable/ComparableUnitTest.java rename to core-java-modules/core-java-lang/src/test/java/com/baeldung/comparable/ComparableUnitTest.java diff --git a/core-java-lang/src/test/java/com/baeldung/comparator/ComparatorUnitTest.java b/core-java-modules/core-java-lang/src/test/java/com/baeldung/comparator/ComparatorUnitTest.java similarity index 100% rename from core-java-lang/src/test/java/com/baeldung/comparator/ComparatorUnitTest.java rename to core-java-modules/core-java-lang/src/test/java/com/baeldung/comparator/ComparatorUnitTest.java diff --git a/core-java-lang/src/test/java/com/baeldung/comparator/Java8ComparatorUnitTest.java b/core-java-modules/core-java-lang/src/test/java/com/baeldung/comparator/Java8ComparatorUnitTest.java similarity index 100% rename from core-java-lang/src/test/java/com/baeldung/comparator/Java8ComparatorUnitTest.java rename to core-java-modules/core-java-lang/src/test/java/com/baeldung/comparator/Java8ComparatorUnitTest.java diff --git a/core-java-lang/src/test/java/com/baeldung/compoundoperators/CompoundOperatorsUnitTest.java b/core-java-modules/core-java-lang/src/test/java/com/baeldung/compoundoperators/CompoundOperatorsUnitTest.java similarity index 100% rename from core-java-lang/src/test/java/com/baeldung/compoundoperators/CompoundOperatorsUnitTest.java rename to core-java-modules/core-java-lang/src/test/java/com/baeldung/compoundoperators/CompoundOperatorsUnitTest.java diff --git a/core-java-lang/src/test/java/com/baeldung/customexception/IncorrectFileExtensionExceptionUnitTest.java b/core-java-modules/core-java-lang/src/test/java/com/baeldung/customexception/IncorrectFileExtensionExceptionUnitTest.java similarity index 100% rename from core-java-lang/src/test/java/com/baeldung/customexception/IncorrectFileExtensionExceptionUnitTest.java rename to core-java-modules/core-java-lang/src/test/java/com/baeldung/customexception/IncorrectFileExtensionExceptionUnitTest.java diff --git a/core-java-lang/src/test/java/com/baeldung/customexception/IncorrectFileNameExceptionUnitTest.java b/core-java-modules/core-java-lang/src/test/java/com/baeldung/customexception/IncorrectFileNameExceptionUnitTest.java similarity index 100% rename from core-java-lang/src/test/java/com/baeldung/customexception/IncorrectFileNameExceptionUnitTest.java rename to core-java-modules/core-java-lang/src/test/java/com/baeldung/customexception/IncorrectFileNameExceptionUnitTest.java diff --git a/core-java-lang/src/test/java/com/baeldung/dynamicproxy/DynamicProxyIntegrationTest.java b/core-java-modules/core-java-lang/src/test/java/com/baeldung/dynamicproxy/DynamicProxyIntegrationTest.java similarity index 100% rename from core-java-lang/src/test/java/com/baeldung/dynamicproxy/DynamicProxyIntegrationTest.java rename to core-java-modules/core-java-lang/src/test/java/com/baeldung/dynamicproxy/DynamicProxyIntegrationTest.java diff --git a/core-java-lang/src/test/java/com/baeldung/enums/values/Element1UnitTest.java b/core-java-modules/core-java-lang/src/test/java/com/baeldung/enums/values/Element1UnitTest.java similarity index 100% rename from core-java-lang/src/test/java/com/baeldung/enums/values/Element1UnitTest.java rename to core-java-modules/core-java-lang/src/test/java/com/baeldung/enums/values/Element1UnitTest.java diff --git a/core-java-lang/src/test/java/com/baeldung/enums/values/Element2UnitTest.java b/core-java-modules/core-java-lang/src/test/java/com/baeldung/enums/values/Element2UnitTest.java similarity index 100% rename from core-java-lang/src/test/java/com/baeldung/enums/values/Element2UnitTest.java rename to core-java-modules/core-java-lang/src/test/java/com/baeldung/enums/values/Element2UnitTest.java diff --git a/core-java-lang/src/test/java/com/baeldung/enums/values/Element3UnitTest.java b/core-java-modules/core-java-lang/src/test/java/com/baeldung/enums/values/Element3UnitTest.java similarity index 100% rename from core-java-lang/src/test/java/com/baeldung/enums/values/Element3UnitTest.java rename to core-java-modules/core-java-lang/src/test/java/com/baeldung/enums/values/Element3UnitTest.java diff --git a/core-java-lang/src/test/java/com/baeldung/enums/values/Element4UnitTest.java b/core-java-modules/core-java-lang/src/test/java/com/baeldung/enums/values/Element4UnitTest.java similarity index 100% rename from core-java-lang/src/test/java/com/baeldung/enums/values/Element4UnitTest.java rename to core-java-modules/core-java-lang/src/test/java/com/baeldung/enums/values/Element4UnitTest.java diff --git a/core-java-lang/src/test/java/com/baeldung/exceptionhandling/ExceptionsUnitTest.java b/core-java-modules/core-java-lang/src/test/java/com/baeldung/exceptionhandling/ExceptionsUnitTest.java similarity index 96% rename from core-java-lang/src/test/java/com/baeldung/exceptionhandling/ExceptionsUnitTest.java rename to core-java-modules/core-java-lang/src/test/java/com/baeldung/exceptionhandling/ExceptionsUnitTest.java index b3f585cfe4..29c690133d 100644 --- a/core-java-lang/src/test/java/com/baeldung/exceptionhandling/ExceptionsUnitTest.java +++ b/core-java-modules/core-java-lang/src/test/java/com/baeldung/exceptionhandling/ExceptionsUnitTest.java @@ -1,80 +1,80 @@ -package com.baeldung.exceptionhandling; - -import org.junit.Test; - -import java.io.FileNotFoundException; -import java.io.IOException; -import java.nio.file.NoSuchFileException; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class ExceptionsUnitTest { - - Exceptions exceptions = new Exceptions(); - - @Test - public void getPlayers() { - assertThatThrownBy(() -> exceptions.getPlayers()) - .isInstanceOf(NoSuchFileException.class); - } - - @Test - public void loadAllPlayers() { - assertThatThrownBy(() -> exceptions.loadAllPlayers("")) - .isInstanceOf(IllegalStateException.class); - } - - @Test - public void getPlayerScoreThrows() { - assertThatThrownBy(() -> exceptions.getPlayerScoreThrows("")) - .isInstanceOf(FileNotFoundException.class); - } - - @Test - public void getPlayerScoreTryCatch() { - assertThatThrownBy(() -> exceptions.getPlayerScoreTryCatch("")) - .isInstanceOf(IllegalArgumentException.class); - } - - @Test - public void getPlayerScoreFinally() { - assertThatThrownBy(() -> exceptions.getPlayerScoreFinally("")) - .isInstanceOf(FileNotFoundException.class); - } - - @Test - public void loadAllPlayersThrowingChecked() { - assertThatThrownBy(() -> exceptions.loadAllPlayersThrowingChecked("")) - .isInstanceOf(TimeoutException.class); - } - - @Test - public void loadAllPlayersThrowingUnchecked() { - assertThatThrownBy(() -> exceptions.loadAllPlayersThrowingUnchecked("")) - .isInstanceOf(IllegalArgumentException.class); - } - - @Test - public void loadAllPlayersWrapping() { - assertThatThrownBy(() -> exceptions.loadAllPlayersWrapping("")) - .isInstanceOf(IOException.class); - } - - @Test - public void loadAllPlayersRethrowing() { - assertThatThrownBy(() -> exceptions.loadAllPlayersRethrowing("")) - .isInstanceOf(PlayerLoadException.class); - } - - @Test - public void loadAllPlayersThrowable() { - assertThatThrownBy(() -> exceptions.loadAllPlayersThrowable("")) - .isInstanceOf(NullPointerException.class); - } - - @Test - public void getPlayerScoreSwallowingExceptionAntiPatternAlternative2() { - assertThatThrownBy(() -> exceptions.getPlayerScoreSwallowingExceptionAntiPatternAlternative2("")) - .isInstanceOf(PlayerScoreException.class); - } -} +package com.baeldung.exceptionhandling; + +import org.junit.Test; + +import java.io.FileNotFoundException; +import java.io.IOException; +import java.nio.file.NoSuchFileException; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +public class ExceptionsUnitTest { + + Exceptions exceptions = new Exceptions(); + + @Test + public void getPlayers() { + assertThatThrownBy(() -> exceptions.getPlayers()) + .isInstanceOf(NoSuchFileException.class); + } + + @Test + public void loadAllPlayers() { + assertThatThrownBy(() -> exceptions.loadAllPlayers("")) + .isInstanceOf(IllegalStateException.class); + } + + @Test + public void getPlayerScoreThrows() { + assertThatThrownBy(() -> exceptions.getPlayerScoreThrows("")) + .isInstanceOf(FileNotFoundException.class); + } + + @Test + public void getPlayerScoreTryCatch() { + assertThatThrownBy(() -> exceptions.getPlayerScoreTryCatch("")) + .isInstanceOf(IllegalArgumentException.class); + } + + @Test + public void getPlayerScoreFinally() { + assertThatThrownBy(() -> exceptions.getPlayerScoreFinally("")) + .isInstanceOf(FileNotFoundException.class); + } + + @Test + public void loadAllPlayersThrowingChecked() { + assertThatThrownBy(() -> exceptions.loadAllPlayersThrowingChecked("")) + .isInstanceOf(TimeoutException.class); + } + + @Test + public void loadAllPlayersThrowingUnchecked() { + assertThatThrownBy(() -> exceptions.loadAllPlayersThrowingUnchecked("")) + .isInstanceOf(IllegalArgumentException.class); + } + + @Test + public void loadAllPlayersWrapping() { + assertThatThrownBy(() -> exceptions.loadAllPlayersWrapping("")) + .isInstanceOf(IOException.class); + } + + @Test + public void loadAllPlayersRethrowing() { + assertThatThrownBy(() -> exceptions.loadAllPlayersRethrowing("")) + .isInstanceOf(PlayerLoadException.class); + } + + @Test + public void loadAllPlayersThrowable() { + assertThatThrownBy(() -> exceptions.loadAllPlayersThrowable("")) + .isInstanceOf(NullPointerException.class); + } + + @Test + public void getPlayerScoreSwallowingExceptionAntiPatternAlternative2() { + assertThatThrownBy(() -> exceptions.getPlayerScoreSwallowingExceptionAntiPatternAlternative2("")) + .isInstanceOf(PlayerScoreException.class); + } +} diff --git a/core-java-lang/src/test/java/com/baeldung/finalize/FinalizeUnitTest.java b/core-java-modules/core-java-lang/src/test/java/com/baeldung/finalize/FinalizeUnitTest.java similarity index 100% rename from core-java-lang/src/test/java/com/baeldung/finalize/FinalizeUnitTest.java rename to core-java-modules/core-java-lang/src/test/java/com/baeldung/finalize/FinalizeUnitTest.java diff --git a/core-java-lang/src/test/java/com/baeldung/interfaces/InnerInterfaceUnitTest.java b/core-java-modules/core-java-lang/src/test/java/com/baeldung/interfaces/InnerInterfaceUnitTest.java similarity index 100% rename from core-java-lang/src/test/java/com/baeldung/interfaces/InnerInterfaceUnitTest.java rename to core-java-modules/core-java-lang/src/test/java/com/baeldung/interfaces/InnerInterfaceUnitTest.java diff --git a/core-java-lang/src/test/java/com/baeldung/java/enumiteration/DaysOfWeekEnum.java b/core-java-modules/core-java-lang/src/test/java/com/baeldung/java/enumiteration/DaysOfWeekEnum.java similarity index 100% rename from core-java-lang/src/test/java/com/baeldung/java/enumiteration/DaysOfWeekEnum.java rename to core-java-modules/core-java-lang/src/test/java/com/baeldung/java/enumiteration/DaysOfWeekEnum.java diff --git a/core-java-lang/src/test/java/com/baeldung/java/enumiteration/EnumIterationExamples.java b/core-java-modules/core-java-lang/src/test/java/com/baeldung/java/enumiteration/EnumIterationExamples.java similarity index 100% rename from core-java-lang/src/test/java/com/baeldung/java/enumiteration/EnumIterationExamples.java rename to core-java-modules/core-java-lang/src/test/java/com/baeldung/java/enumiteration/EnumIterationExamples.java diff --git a/core-java-lang/src/test/java/com/baeldung/java/reflection/OperationsUnitTest.java b/core-java-modules/core-java-lang/src/test/java/com/baeldung/java/reflection/OperationsUnitTest.java similarity index 100% rename from core-java-lang/src/test/java/com/baeldung/java/reflection/OperationsUnitTest.java rename to core-java-modules/core-java-lang/src/test/java/com/baeldung/java/reflection/OperationsUnitTest.java diff --git a/core-java-lang/src/test/java/com/baeldung/java/reflection/ReflectionUnitTest.java b/core-java-modules/core-java-lang/src/test/java/com/baeldung/java/reflection/ReflectionUnitTest.java similarity index 100% rename from core-java-lang/src/test/java/com/baeldung/java/reflection/ReflectionUnitTest.java rename to core-java-modules/core-java-lang/src/test/java/com/baeldung/java/reflection/ReflectionUnitTest.java diff --git a/core-java-lang/src/test/java/com/baeldung/nativekeyword/DateTimeUtilsManualTest.java b/core-java-modules/core-java-lang/src/test/java/com/baeldung/nativekeyword/DateTimeUtilsManualTest.java similarity index 96% rename from core-java-lang/src/test/java/com/baeldung/nativekeyword/DateTimeUtilsManualTest.java rename to core-java-modules/core-java-lang/src/test/java/com/baeldung/nativekeyword/DateTimeUtilsManualTest.java index d5003dfc1f..ac27c11c68 100644 --- a/core-java-lang/src/test/java/com/baeldung/nativekeyword/DateTimeUtilsManualTest.java +++ b/core-java-modules/core-java-lang/src/test/java/com/baeldung/nativekeyword/DateTimeUtilsManualTest.java @@ -1,27 +1,27 @@ -package com.baeldung.nativekeyword; - -import static org.junit.Assert.assertNotNull; - -import org.junit.BeforeClass; -import org.junit.Test; -import org.slf4j.Logger; - -public class DateTimeUtilsManualTest { - - private static final Logger LOG = org.slf4j.LoggerFactory.getLogger(DateTimeUtilsManualTest.class); - - @BeforeClass - public static void setUpClass() { - System.loadLibrary("msvcr100"); - System.loadLibrary("libgcc_s_sjlj-1"); - System.loadLibrary("libstdc++-6"); - System.loadLibrary("nativedatetimeutils"); - } - - @Test - public void givenNativeLibsLoaded_thenNativeMethodIsAccessible() { - DateTimeUtils dateTimeUtils = new DateTimeUtils(); - LOG.info("System time is : " + dateTimeUtils.getSystemTime()); - assertNotNull(dateTimeUtils.getSystemTime()); - } -} +package com.baeldung.nativekeyword; + +import static org.junit.Assert.assertNotNull; + +import org.junit.BeforeClass; +import org.junit.Test; +import org.slf4j.Logger; + +public class DateTimeUtilsManualTest { + + private static final Logger LOG = org.slf4j.LoggerFactory.getLogger(DateTimeUtilsManualTest.class); + + @BeforeClass + public static void setUpClass() { + System.loadLibrary("msvcr100"); + System.loadLibrary("libgcc_s_sjlj-1"); + System.loadLibrary("libstdc++-6"); + System.loadLibrary("nativedatetimeutils"); + } + + @Test + public void givenNativeLibsLoaded_thenNativeMethodIsAccessible() { + DateTimeUtils dateTimeUtils = new DateTimeUtils(); + LOG.info("System time is : " + dateTimeUtils.getSystemTime()); + assertNotNull(dateTimeUtils.getSystemTime()); + } +} diff --git a/core-java-lang/src/test/java/com/baeldung/nestedclass/AnonymousInner.java b/core-java-modules/core-java-lang/src/test/java/com/baeldung/nestedclass/AnonymousInner.java similarity index 100% rename from core-java-lang/src/test/java/com/baeldung/nestedclass/AnonymousInner.java rename to core-java-modules/core-java-lang/src/test/java/com/baeldung/nestedclass/AnonymousInner.java diff --git a/core-java-lang/src/test/java/com/baeldung/nestedclass/Enclosing.java b/core-java-modules/core-java-lang/src/test/java/com/baeldung/nestedclass/Enclosing.java similarity index 100% rename from core-java-lang/src/test/java/com/baeldung/nestedclass/Enclosing.java rename to core-java-modules/core-java-lang/src/test/java/com/baeldung/nestedclass/Enclosing.java diff --git a/core-java-lang/src/test/java/com/baeldung/nestedclass/NewEnclosing.java b/core-java-modules/core-java-lang/src/test/java/com/baeldung/nestedclass/NewEnclosing.java similarity index 100% rename from core-java-lang/src/test/java/com/baeldung/nestedclass/NewEnclosing.java rename to core-java-modules/core-java-lang/src/test/java/com/baeldung/nestedclass/NewEnclosing.java diff --git a/core-java-lang/src/test/java/com/baeldung/nestedclass/NewOuter.java b/core-java-modules/core-java-lang/src/test/java/com/baeldung/nestedclass/NewOuter.java similarity index 100% rename from core-java-lang/src/test/java/com/baeldung/nestedclass/NewOuter.java rename to core-java-modules/core-java-lang/src/test/java/com/baeldung/nestedclass/NewOuter.java diff --git a/core-java-lang/src/test/java/com/baeldung/nestedclass/Outer.java b/core-java-modules/core-java-lang/src/test/java/com/baeldung/nestedclass/Outer.java similarity index 100% rename from core-java-lang/src/test/java/com/baeldung/nestedclass/Outer.java rename to core-java-modules/core-java-lang/src/test/java/com/baeldung/nestedclass/Outer.java diff --git a/core-java-lang/src/test/java/com/baeldung/noclassdeffounderror/NoClassDefFoundErrorUnitTest.java b/core-java-modules/core-java-lang/src/test/java/com/baeldung/noclassdeffounderror/NoClassDefFoundErrorUnitTest.java similarity index 97% rename from core-java-lang/src/test/java/com/baeldung/noclassdeffounderror/NoClassDefFoundErrorUnitTest.java rename to core-java-modules/core-java-lang/src/test/java/com/baeldung/noclassdeffounderror/NoClassDefFoundErrorUnitTest.java index ccc8c1f69c..521c50098a 100644 --- a/core-java-lang/src/test/java/com/baeldung/noclassdeffounderror/NoClassDefFoundErrorUnitTest.java +++ b/core-java-modules/core-java-lang/src/test/java/com/baeldung/noclassdeffounderror/NoClassDefFoundErrorUnitTest.java @@ -1,12 +1,12 @@ -package com.baeldung.noclassdeffounderror; - -import org.junit.Test; - -public class NoClassDefFoundErrorUnitTest { - - @Test(expected = NoClassDefFoundError.class) - public void givenInitErrorInClass_whenloadClass_thenNoClassDefFoundError() { - NoClassDefFoundErrorExample sample = new NoClassDefFoundErrorExample(); - sample.getClassWithInitErrors(); - } +package com.baeldung.noclassdeffounderror; + +import org.junit.Test; + +public class NoClassDefFoundErrorUnitTest { + + @Test(expected = NoClassDefFoundError.class) + public void givenInitErrorInClass_whenloadClass_thenNoClassDefFoundError() { + NoClassDefFoundErrorExample sample = new NoClassDefFoundErrorExample(); + sample.getClassWithInitErrors(); + } } \ No newline at end of file diff --git a/core-java-lang/src/test/java/com/baeldung/objects/CarUnitTest.java b/core-java-modules/core-java-lang/src/test/java/com/baeldung/objects/CarUnitTest.java similarity index 100% rename from core-java-lang/src/test/java/com/baeldung/objects/CarUnitTest.java rename to core-java-modules/core-java-lang/src/test/java/com/baeldung/objects/CarUnitTest.java diff --git a/core-java-lang/src/test/java/com/baeldung/packages/PackagesUnitTest.java b/core-java-modules/core-java-lang/src/test/java/com/baeldung/packages/PackagesUnitTest.java similarity index 100% rename from core-java-lang/src/test/java/com/baeldung/packages/PackagesUnitTest.java rename to core-java-modules/core-java-lang/src/test/java/com/baeldung/packages/PackagesUnitTest.java diff --git a/core-java-lang/src/test/java/com/baeldung/recursion/RecursionExampleUnitTest.java b/core-java-modules/core-java-lang/src/test/java/com/baeldung/recursion/RecursionExampleUnitTest.java similarity index 96% rename from core-java-lang/src/test/java/com/baeldung/recursion/RecursionExampleUnitTest.java rename to core-java-modules/core-java-lang/src/test/java/com/baeldung/recursion/RecursionExampleUnitTest.java index 6c560c9c37..7b11e968ce 100644 --- a/core-java-lang/src/test/java/com/baeldung/recursion/RecursionExampleUnitTest.java +++ b/core-java-modules/core-java-lang/src/test/java/com/baeldung/recursion/RecursionExampleUnitTest.java @@ -1,61 +1,61 @@ -package com.baeldung.recursion; - -import org.junit.Assert; -import org.junit.Test; - -public class RecursionExampleUnitTest { - - RecursionExample recursion = new RecursionExample(); - - @Test - public void testPowerOf10() { - int p0 = recursion.powerOf10(0); - int p1 = recursion.powerOf10(1); - int p4 = recursion.powerOf10(4); - - Assert.assertEquals(1, p0); - Assert.assertEquals(10, p1); - Assert.assertEquals(10000, p4); - } - - @Test - public void testFibonacci() { - int n0 = recursion.fibonacci(0); - int n1 = recursion.fibonacci(1); - int n7 = recursion.fibonacci(7); - - Assert.assertEquals(0, n0); - Assert.assertEquals(1, n1); - Assert.assertEquals(13, n7); - } - - @Test - public void testToBinary() { - String b0 = recursion.toBinary(0); - String b1 = recursion.toBinary(1); - String b10 = recursion.toBinary(10); - - Assert.assertEquals("0", b0); - Assert.assertEquals("1", b1); - Assert.assertEquals("1010", b10); - } - - @Test - public void testCalculateTreeHeight() { - BinaryNode root = new BinaryNode(1); - root.setLeft(new BinaryNode(1)); - root.setRight(new BinaryNode(1)); - - root.getLeft().setLeft(new BinaryNode(1)); - root.getLeft().getLeft().setRight(new BinaryNode(1)); - root.getLeft().getLeft().getRight().setLeft(new BinaryNode(1)); - - root.getRight().setLeft(new BinaryNode(1)); - root.getRight().getLeft().setRight(new BinaryNode(1)); - - int height = recursion.calculateTreeHeight(root); - - Assert.assertEquals(4, height); - } - -} +package com.baeldung.recursion; + +import org.junit.Assert; +import org.junit.Test; + +public class RecursionExampleUnitTest { + + RecursionExample recursion = new RecursionExample(); + + @Test + public void testPowerOf10() { + int p0 = recursion.powerOf10(0); + int p1 = recursion.powerOf10(1); + int p4 = recursion.powerOf10(4); + + Assert.assertEquals(1, p0); + Assert.assertEquals(10, p1); + Assert.assertEquals(10000, p4); + } + + @Test + public void testFibonacci() { + int n0 = recursion.fibonacci(0); + int n1 = recursion.fibonacci(1); + int n7 = recursion.fibonacci(7); + + Assert.assertEquals(0, n0); + Assert.assertEquals(1, n1); + Assert.assertEquals(13, n7); + } + + @Test + public void testToBinary() { + String b0 = recursion.toBinary(0); + String b1 = recursion.toBinary(1); + String b10 = recursion.toBinary(10); + + Assert.assertEquals("0", b0); + Assert.assertEquals("1", b1); + Assert.assertEquals("1010", b10); + } + + @Test + public void testCalculateTreeHeight() { + BinaryNode root = new BinaryNode(1); + root.setLeft(new BinaryNode(1)); + root.setRight(new BinaryNode(1)); + + root.getLeft().setLeft(new BinaryNode(1)); + root.getLeft().getLeft().setRight(new BinaryNode(1)); + root.getLeft().getLeft().getRight().setLeft(new BinaryNode(1)); + + root.getRight().setLeft(new BinaryNode(1)); + root.getRight().getLeft().setRight(new BinaryNode(1)); + + int height = recursion.calculateTreeHeight(root); + + Assert.assertEquals(4, height); + } + +} diff --git a/core-java-lang/src/test/java/com/baeldung/sneakythrows/SneakyRunnableUnitTest.java b/core-java-modules/core-java-lang/src/test/java/com/baeldung/sneakythrows/SneakyRunnableUnitTest.java similarity index 100% rename from core-java-lang/src/test/java/com/baeldung/sneakythrows/SneakyRunnableUnitTest.java rename to core-java-modules/core-java-lang/src/test/java/com/baeldung/sneakythrows/SneakyRunnableUnitTest.java diff --git a/core-java-lang/src/test/java/com/baeldung/sneakythrows/SneakyThrowsUnitTest.java b/core-java-modules/core-java-lang/src/test/java/com/baeldung/sneakythrows/SneakyThrowsUnitTest.java similarity index 100% rename from core-java-lang/src/test/java/com/baeldung/sneakythrows/SneakyThrowsUnitTest.java rename to core-java-modules/core-java-lang/src/test/java/com/baeldung/sneakythrows/SneakyThrowsUnitTest.java diff --git a/core-java-lang/src/test/java/com/baeldung/stackoverflowerror/AccountHolderManualTest.java b/core-java-modules/core-java-lang/src/test/java/com/baeldung/stackoverflowerror/AccountHolderManualTest.java similarity index 96% rename from core-java-lang/src/test/java/com/baeldung/stackoverflowerror/AccountHolderManualTest.java rename to core-java-modules/core-java-lang/src/test/java/com/baeldung/stackoverflowerror/AccountHolderManualTest.java index e6a8f89a16..180b7723ac 100644 --- a/core-java-lang/src/test/java/com/baeldung/stackoverflowerror/AccountHolderManualTest.java +++ b/core-java-modules/core-java-lang/src/test/java/com/baeldung/stackoverflowerror/AccountHolderManualTest.java @@ -1,10 +1,10 @@ -package com.baeldung.stackoverflowerror; - -import org.junit.Test; - -public class AccountHolderManualTest { - @Test(expected = StackOverflowError.class) - public void whenInstanciatingAccountHolder_thenThrowsException() { - AccountHolder holder = new AccountHolder(); - } -} +package com.baeldung.stackoverflowerror; + +import org.junit.Test; + +public class AccountHolderManualTest { + @Test(expected = StackOverflowError.class) + public void whenInstanciatingAccountHolder_thenThrowsException() { + AccountHolder holder = new AccountHolder(); + } +} diff --git a/core-java-lang/src/test/java/com/baeldung/stackoverflowerror/CyclicDependancyManualTest.java b/core-java-modules/core-java-lang/src/test/java/com/baeldung/stackoverflowerror/CyclicDependancyManualTest.java similarity index 96% rename from core-java-lang/src/test/java/com/baeldung/stackoverflowerror/CyclicDependancyManualTest.java rename to core-java-modules/core-java-lang/src/test/java/com/baeldung/stackoverflowerror/CyclicDependancyManualTest.java index 1f1de9149a..95164ac935 100644 --- a/core-java-lang/src/test/java/com/baeldung/stackoverflowerror/CyclicDependancyManualTest.java +++ b/core-java-modules/core-java-lang/src/test/java/com/baeldung/stackoverflowerror/CyclicDependancyManualTest.java @@ -1,10 +1,10 @@ -package com.baeldung.stackoverflowerror; - -import org.junit.Test; - -public class CyclicDependancyManualTest { - @Test(expected = StackOverflowError.class) - public void whenInstanciatingClassOne_thenThrowsException() { - ClassOne obj = new ClassOne(); - } -} +package com.baeldung.stackoverflowerror; + +import org.junit.Test; + +public class CyclicDependancyManualTest { + @Test(expected = StackOverflowError.class) + public void whenInstanciatingClassOne_thenThrowsException() { + ClassOne obj = new ClassOne(); + } +} diff --git a/core-java-lang/src/test/java/com/baeldung/stackoverflowerror/InfiniteRecursionWithTerminationConditionManualTest.java b/core-java-modules/core-java-lang/src/test/java/com/baeldung/stackoverflowerror/InfiniteRecursionWithTerminationConditionManualTest.java similarity index 97% rename from core-java-lang/src/test/java/com/baeldung/stackoverflowerror/InfiniteRecursionWithTerminationConditionManualTest.java rename to core-java-modules/core-java-lang/src/test/java/com/baeldung/stackoverflowerror/InfiniteRecursionWithTerminationConditionManualTest.java index 3530fa1c3e..ccf8c25271 100644 --- a/core-java-lang/src/test/java/com/baeldung/stackoverflowerror/InfiniteRecursionWithTerminationConditionManualTest.java +++ b/core-java-modules/core-java-lang/src/test/java/com/baeldung/stackoverflowerror/InfiniteRecursionWithTerminationConditionManualTest.java @@ -1,31 +1,31 @@ -package com.baeldung.stackoverflowerror; - -import org.junit.Test; - -import static junit.framework.TestCase.assertEquals; - -public class InfiniteRecursionWithTerminationConditionManualTest { - @Test - public void givenPositiveIntNoOne_whenCalcFact_thenCorrectlyCalc() { - int numToCalcFactorial = 1; - InfiniteRecursionWithTerminationCondition irtc = new InfiniteRecursionWithTerminationCondition(); - - assertEquals(1, irtc.calculateFactorial(numToCalcFactorial)); - } - - @Test - public void givenPositiveIntGtOne_whenCalcFact_thenCorrectlyCalc() { - int numToCalcFactorial = 5; - InfiniteRecursionWithTerminationCondition irtc = new InfiniteRecursionWithTerminationCondition(); - - assertEquals(120, irtc.calculateFactorial(numToCalcFactorial)); - } - - @Test(expected = StackOverflowError.class) - public void givenNegativeInt_whenCalcFact_thenThrowsException() { - int numToCalcFactorial = -1; - InfiniteRecursionWithTerminationCondition irtc = new InfiniteRecursionWithTerminationCondition(); - - irtc.calculateFactorial(numToCalcFactorial); - } -} +package com.baeldung.stackoverflowerror; + +import org.junit.Test; + +import static junit.framework.TestCase.assertEquals; + +public class InfiniteRecursionWithTerminationConditionManualTest { + @Test + public void givenPositiveIntNoOne_whenCalcFact_thenCorrectlyCalc() { + int numToCalcFactorial = 1; + InfiniteRecursionWithTerminationCondition irtc = new InfiniteRecursionWithTerminationCondition(); + + assertEquals(1, irtc.calculateFactorial(numToCalcFactorial)); + } + + @Test + public void givenPositiveIntGtOne_whenCalcFact_thenCorrectlyCalc() { + int numToCalcFactorial = 5; + InfiniteRecursionWithTerminationCondition irtc = new InfiniteRecursionWithTerminationCondition(); + + assertEquals(120, irtc.calculateFactorial(numToCalcFactorial)); + } + + @Test(expected = StackOverflowError.class) + public void givenNegativeInt_whenCalcFact_thenThrowsException() { + int numToCalcFactorial = -1; + InfiniteRecursionWithTerminationCondition irtc = new InfiniteRecursionWithTerminationCondition(); + + irtc.calculateFactorial(numToCalcFactorial); + } +} diff --git a/core-java-lang/src/test/java/com/baeldung/stackoverflowerror/RecursionWithCorrectTerminationConditionManualTest.java b/core-java-modules/core-java-lang/src/test/java/com/baeldung/stackoverflowerror/RecursionWithCorrectTerminationConditionManualTest.java similarity index 96% rename from core-java-lang/src/test/java/com/baeldung/stackoverflowerror/RecursionWithCorrectTerminationConditionManualTest.java rename to core-java-modules/core-java-lang/src/test/java/com/baeldung/stackoverflowerror/RecursionWithCorrectTerminationConditionManualTest.java index 858cec2ffa..40c2c4799e 100644 --- a/core-java-lang/src/test/java/com/baeldung/stackoverflowerror/RecursionWithCorrectTerminationConditionManualTest.java +++ b/core-java-modules/core-java-lang/src/test/java/com/baeldung/stackoverflowerror/RecursionWithCorrectTerminationConditionManualTest.java @@ -1,15 +1,15 @@ -package com.baeldung.stackoverflowerror; - -import org.junit.Test; - -import static junit.framework.TestCase.assertEquals; - -public class RecursionWithCorrectTerminationConditionManualTest { - @Test - public void givenNegativeInt_whenCalcFact_thenCorrectlyCalc() { - int numToCalcFactorial = -1; - RecursionWithCorrectTerminationCondition rctc = new RecursionWithCorrectTerminationCondition(); - - assertEquals(1, rctc.calculateFactorial(numToCalcFactorial)); - } -} +package com.baeldung.stackoverflowerror; + +import org.junit.Test; + +import static junit.framework.TestCase.assertEquals; + +public class RecursionWithCorrectTerminationConditionManualTest { + @Test + public void givenNegativeInt_whenCalcFact_thenCorrectlyCalc() { + int numToCalcFactorial = -1; + RecursionWithCorrectTerminationCondition rctc = new RecursionWithCorrectTerminationCondition(); + + assertEquals(1, rctc.calculateFactorial(numToCalcFactorial)); + } +} diff --git a/core-java-lang/src/test/java/com/baeldung/stackoverflowerror/UnintendedInfiniteRecursionManualTest.java b/core-java-modules/core-java-lang/src/test/java/com/baeldung/stackoverflowerror/UnintendedInfiniteRecursionManualTest.java similarity index 97% rename from core-java-lang/src/test/java/com/baeldung/stackoverflowerror/UnintendedInfiniteRecursionManualTest.java rename to core-java-modules/core-java-lang/src/test/java/com/baeldung/stackoverflowerror/UnintendedInfiniteRecursionManualTest.java index 1e1c245d4d..f4e2e5221a 100644 --- a/core-java-lang/src/test/java/com/baeldung/stackoverflowerror/UnintendedInfiniteRecursionManualTest.java +++ b/core-java-modules/core-java-lang/src/test/java/com/baeldung/stackoverflowerror/UnintendedInfiniteRecursionManualTest.java @@ -1,30 +1,30 @@ -package com.baeldung.stackoverflowerror; - - -import org.junit.Test; - -public class UnintendedInfiniteRecursionManualTest { - @Test(expected = StackOverflowError.class) - public void givenPositiveIntNoOne_whenCalFact_thenThrowsException() { - int numToCalcFactorial = 1; - UnintendedInfiniteRecursion uir = new UnintendedInfiniteRecursion(); - - uir.calculateFactorial(numToCalcFactorial); - } - - @Test(expected = StackOverflowError.class) - public void givenPositiveIntGtOne_whenCalcFact_thenThrowsException() { - int numToCalcFactorial = 2; - UnintendedInfiniteRecursion uir = new UnintendedInfiniteRecursion(); - - uir.calculateFactorial(numToCalcFactorial); - } - - @Test(expected = StackOverflowError.class) - public void givenNegativeInt_whenCalcFact_thenThrowsException() { - int numToCalcFactorial = -1; - UnintendedInfiniteRecursion uir = new UnintendedInfiniteRecursion(); - - uir.calculateFactorial(numToCalcFactorial); - } -} +package com.baeldung.stackoverflowerror; + + +import org.junit.Test; + +public class UnintendedInfiniteRecursionManualTest { + @Test(expected = StackOverflowError.class) + public void givenPositiveIntNoOne_whenCalFact_thenThrowsException() { + int numToCalcFactorial = 1; + UnintendedInfiniteRecursion uir = new UnintendedInfiniteRecursion(); + + uir.calculateFactorial(numToCalcFactorial); + } + + @Test(expected = StackOverflowError.class) + public void givenPositiveIntGtOne_whenCalcFact_thenThrowsException() { + int numToCalcFactorial = 2; + UnintendedInfiniteRecursion uir = new UnintendedInfiniteRecursion(); + + uir.calculateFactorial(numToCalcFactorial); + } + + @Test(expected = StackOverflowError.class) + public void givenNegativeInt_whenCalcFact_thenThrowsException() { + int numToCalcFactorial = -1; + UnintendedInfiniteRecursion uir = new UnintendedInfiniteRecursion(); + + uir.calculateFactorial(numToCalcFactorial); + } +} diff --git a/core-java-lang/src/test/java/com/baeldung/synthetic/SyntheticUnitTest.java b/core-java-modules/core-java-lang/src/test/java/com/baeldung/synthetic/SyntheticUnitTest.java similarity index 100% rename from core-java-lang/src/test/java/com/baeldung/synthetic/SyntheticUnitTest.java rename to core-java-modules/core-java-lang/src/test/java/com/baeldung/synthetic/SyntheticUnitTest.java diff --git a/core-java-lang/src/test/java/com/baeldung/throwsexception/SimpleServiceUnitTest.java b/core-java-modules/core-java-lang/src/test/java/com/baeldung/throwsexception/SimpleServiceUnitTest.java similarity index 100% rename from core-java-lang/src/test/java/com/baeldung/throwsexception/SimpleServiceUnitTest.java rename to core-java-modules/core-java-lang/src/test/java/com/baeldung/throwsexception/SimpleServiceUnitTest.java diff --git a/core-java-lang/src/test/resources/correctFileNameWithoutProperExtension b/core-java-modules/core-java-lang/src/test/resources/correctFileNameWithoutProperExtension similarity index 100% rename from core-java-lang/src/test/resources/correctFileNameWithoutProperExtension rename to core-java-modules/core-java-lang/src/test/resources/correctFileNameWithoutProperExtension diff --git a/core-java/.gitignore b/core-java-modules/core-java-networking/.gitignore similarity index 100% rename from core-java/.gitignore rename to core-java-modules/core-java-networking/.gitignore diff --git a/core-java-networking/README.md b/core-java-modules/core-java-networking/README.md similarity index 100% rename from core-java-networking/README.md rename to core-java-modules/core-java-networking/README.md diff --git a/core-java-networking/pom.xml b/core-java-modules/core-java-networking/pom.xml similarity index 96% rename from core-java-networking/pom.xml rename to core-java-modules/core-java-networking/pom.xml index 12bb257fcb..550ebdb4ff 100644 --- a/core-java-networking/pom.xml +++ b/core-java-modules/core-java-networking/pom.xml @@ -10,7 +10,7 @@ com.baeldung parent-java 0.0.1-SNAPSHOT - ../parent-java + ../../parent-java diff --git a/core-java-networking/src/main/java/com/baeldung/http/FullResponseBuilder.java b/core-java-modules/core-java-networking/src/main/java/com/baeldung/http/FullResponseBuilder.java similarity index 100% rename from core-java-networking/src/main/java/com/baeldung/http/FullResponseBuilder.java rename to core-java-modules/core-java-networking/src/main/java/com/baeldung/http/FullResponseBuilder.java diff --git a/core-java-networking/src/main/java/com/baeldung/http/ParameterStringBuilder.java b/core-java-modules/core-java-networking/src/main/java/com/baeldung/http/ParameterStringBuilder.java similarity index 100% rename from core-java-networking/src/main/java/com/baeldung/http/ParameterStringBuilder.java rename to core-java-modules/core-java-networking/src/main/java/com/baeldung/http/ParameterStringBuilder.java diff --git a/core-java-networking/src/main/java/com/baeldung/mail/EmailService.java b/core-java-modules/core-java-networking/src/main/java/com/baeldung/mail/EmailService.java similarity index 100% rename from core-java-networking/src/main/java/com/baeldung/mail/EmailService.java rename to core-java-modules/core-java-networking/src/main/java/com/baeldung/mail/EmailService.java diff --git a/core-java-networking/src/main/java/com/baeldung/networking/cookies/PersistentCookieStore.java b/core-java-modules/core-java-networking/src/main/java/com/baeldung/networking/cookies/PersistentCookieStore.java similarity index 100% rename from core-java-networking/src/main/java/com/baeldung/networking/cookies/PersistentCookieStore.java rename to core-java-modules/core-java-networking/src/main/java/com/baeldung/networking/cookies/PersistentCookieStore.java diff --git a/core-java-networking/src/main/java/com/baeldung/networking/cookies/ProxyAcceptCookiePolicy.java b/core-java-modules/core-java-networking/src/main/java/com/baeldung/networking/cookies/ProxyAcceptCookiePolicy.java similarity index 100% rename from core-java-networking/src/main/java/com/baeldung/networking/cookies/ProxyAcceptCookiePolicy.java rename to core-java-modules/core-java-networking/src/main/java/com/baeldung/networking/cookies/ProxyAcceptCookiePolicy.java diff --git a/core-java-networking/src/main/java/com/baeldung/networking/proxies/CommandLineProxyDemo.java b/core-java-modules/core-java-networking/src/main/java/com/baeldung/networking/proxies/CommandLineProxyDemo.java similarity index 100% rename from core-java-networking/src/main/java/com/baeldung/networking/proxies/CommandLineProxyDemo.java rename to core-java-modules/core-java-networking/src/main/java/com/baeldung/networking/proxies/CommandLineProxyDemo.java diff --git a/core-java-networking/src/main/java/com/baeldung/networking/proxies/DirectProxyDemo.java b/core-java-modules/core-java-networking/src/main/java/com/baeldung/networking/proxies/DirectProxyDemo.java similarity index 100% rename from core-java-networking/src/main/java/com/baeldung/networking/proxies/DirectProxyDemo.java rename to core-java-modules/core-java-networking/src/main/java/com/baeldung/networking/proxies/DirectProxyDemo.java diff --git a/core-java-networking/src/main/java/com/baeldung/networking/proxies/SocksProxyDemo.java b/core-java-modules/core-java-networking/src/main/java/com/baeldung/networking/proxies/SocksProxyDemo.java similarity index 100% rename from core-java-networking/src/main/java/com/baeldung/networking/proxies/SocksProxyDemo.java rename to core-java-modules/core-java-networking/src/main/java/com/baeldung/networking/proxies/SocksProxyDemo.java diff --git a/core-java-networking/src/main/java/com/baeldung/networking/proxies/SystemPropertyProxyDemo.java b/core-java-modules/core-java-networking/src/main/java/com/baeldung/networking/proxies/SystemPropertyProxyDemo.java similarity index 100% rename from core-java-networking/src/main/java/com/baeldung/networking/proxies/SystemPropertyProxyDemo.java rename to core-java-modules/core-java-networking/src/main/java/com/baeldung/networking/proxies/SystemPropertyProxyDemo.java diff --git a/core-java-networking/src/main/java/com/baeldung/networking/proxies/UrlConnectionUtils.java b/core-java-modules/core-java-networking/src/main/java/com/baeldung/networking/proxies/UrlConnectionUtils.java similarity index 100% rename from core-java-networking/src/main/java/com/baeldung/networking/proxies/UrlConnectionUtils.java rename to core-java-modules/core-java-networking/src/main/java/com/baeldung/networking/proxies/UrlConnectionUtils.java diff --git a/core-java-networking/src/main/java/com/baeldung/networking/proxies/WebProxyDemo.java b/core-java-modules/core-java-networking/src/main/java/com/baeldung/networking/proxies/WebProxyDemo.java similarity index 100% rename from core-java-networking/src/main/java/com/baeldung/networking/proxies/WebProxyDemo.java rename to core-java-modules/core-java-networking/src/main/java/com/baeldung/networking/proxies/WebProxyDemo.java diff --git a/core-java-networking/src/main/java/com/baeldung/networking/udp/EchoClient.java b/core-java-modules/core-java-networking/src/main/java/com/baeldung/networking/udp/EchoClient.java similarity index 100% rename from core-java-networking/src/main/java/com/baeldung/networking/udp/EchoClient.java rename to core-java-modules/core-java-networking/src/main/java/com/baeldung/networking/udp/EchoClient.java diff --git a/core-java-networking/src/main/java/com/baeldung/networking/udp/EchoServer.java b/core-java-modules/core-java-networking/src/main/java/com/baeldung/networking/udp/EchoServer.java similarity index 100% rename from core-java-networking/src/main/java/com/baeldung/networking/udp/EchoServer.java rename to core-java-modules/core-java-networking/src/main/java/com/baeldung/networking/udp/EchoServer.java diff --git a/core-java-networking/src/main/java/com/baeldung/networking/udp/broadcast/BroadcastingClient.java b/core-java-modules/core-java-networking/src/main/java/com/baeldung/networking/udp/broadcast/BroadcastingClient.java similarity index 100% rename from core-java-networking/src/main/java/com/baeldung/networking/udp/broadcast/BroadcastingClient.java rename to core-java-modules/core-java-networking/src/main/java/com/baeldung/networking/udp/broadcast/BroadcastingClient.java diff --git a/core-java-networking/src/main/java/com/baeldung/networking/udp/broadcast/BroadcastingEchoServer.java b/core-java-modules/core-java-networking/src/main/java/com/baeldung/networking/udp/broadcast/BroadcastingEchoServer.java similarity index 100% rename from core-java-networking/src/main/java/com/baeldung/networking/udp/broadcast/BroadcastingEchoServer.java rename to core-java-modules/core-java-networking/src/main/java/com/baeldung/networking/udp/broadcast/BroadcastingEchoServer.java diff --git a/core-java-networking/src/main/java/com/baeldung/networking/udp/multicast/MulticastEchoServer.java b/core-java-modules/core-java-networking/src/main/java/com/baeldung/networking/udp/multicast/MulticastEchoServer.java similarity index 100% rename from core-java-networking/src/main/java/com/baeldung/networking/udp/multicast/MulticastEchoServer.java rename to core-java-modules/core-java-networking/src/main/java/com/baeldung/networking/udp/multicast/MulticastEchoServer.java diff --git a/core-java-networking/src/main/java/com/baeldung/networking/udp/multicast/MulticastingClient.java b/core-java-modules/core-java-networking/src/main/java/com/baeldung/networking/udp/multicast/MulticastingClient.java similarity index 100% rename from core-java-networking/src/main/java/com/baeldung/networking/udp/multicast/MulticastingClient.java rename to core-java-modules/core-java-networking/src/main/java/com/baeldung/networking/udp/multicast/MulticastingClient.java diff --git a/core-java-networking/src/main/java/com/baeldung/networking/uriurl/URIDemo.java b/core-java-modules/core-java-networking/src/main/java/com/baeldung/networking/uriurl/URIDemo.java similarity index 100% rename from core-java-networking/src/main/java/com/baeldung/networking/uriurl/URIDemo.java rename to core-java-modules/core-java-networking/src/main/java/com/baeldung/networking/uriurl/URIDemo.java diff --git a/core-java-networking/src/main/java/com/baeldung/networking/uriurl/URLDemo.java b/core-java-modules/core-java-networking/src/main/java/com/baeldung/networking/uriurl/URLDemo.java similarity index 100% rename from core-java-networking/src/main/java/com/baeldung/networking/uriurl/URLDemo.java rename to core-java-modules/core-java-networking/src/main/java/com/baeldung/networking/uriurl/URLDemo.java diff --git a/core-java-networking/src/main/java/com/baeldung/socket/EchoClient.java b/core-java-modules/core-java-networking/src/main/java/com/baeldung/socket/EchoClient.java similarity index 100% rename from core-java-networking/src/main/java/com/baeldung/socket/EchoClient.java rename to core-java-modules/core-java-networking/src/main/java/com/baeldung/socket/EchoClient.java diff --git a/core-java-networking/src/main/java/com/baeldung/socket/EchoMultiServer.java b/core-java-modules/core-java-networking/src/main/java/com/baeldung/socket/EchoMultiServer.java similarity index 100% rename from core-java-networking/src/main/java/com/baeldung/socket/EchoMultiServer.java rename to core-java-modules/core-java-networking/src/main/java/com/baeldung/socket/EchoMultiServer.java diff --git a/core-java-networking/src/main/java/com/baeldung/socket/EchoServer.java b/core-java-modules/core-java-networking/src/main/java/com/baeldung/socket/EchoServer.java similarity index 100% rename from core-java-networking/src/main/java/com/baeldung/socket/EchoServer.java rename to core-java-modules/core-java-networking/src/main/java/com/baeldung/socket/EchoServer.java diff --git a/core-java-networking/src/main/java/com/baeldung/socket/GreetClient.java b/core-java-modules/core-java-networking/src/main/java/com/baeldung/socket/GreetClient.java similarity index 100% rename from core-java-networking/src/main/java/com/baeldung/socket/GreetClient.java rename to core-java-modules/core-java-networking/src/main/java/com/baeldung/socket/GreetClient.java diff --git a/core-java-networking/src/main/java/com/baeldung/socket/GreetServer.java b/core-java-modules/core-java-networking/src/main/java/com/baeldung/socket/GreetServer.java similarity index 100% rename from core-java-networking/src/main/java/com/baeldung/socket/GreetServer.java rename to core-java-modules/core-java-networking/src/main/java/com/baeldung/socket/GreetServer.java diff --git a/core-java-networking/src/main/java/com/baeldung/socket/read/Client.java b/core-java-modules/core-java-networking/src/main/java/com/baeldung/socket/read/Client.java similarity index 100% rename from core-java-networking/src/main/java/com/baeldung/socket/read/Client.java rename to core-java-modules/core-java-networking/src/main/java/com/baeldung/socket/read/Client.java diff --git a/core-java-networking/src/main/java/com/baeldung/socket/read/Server.java b/core-java-modules/core-java-networking/src/main/java/com/baeldung/socket/read/Server.java similarity index 100% rename from core-java-networking/src/main/java/com/baeldung/socket/read/Server.java rename to core-java-modules/core-java-networking/src/main/java/com/baeldung/socket/read/Server.java diff --git a/core-java-networking/src/main/resources/logback.xml b/core-java-modules/core-java-networking/src/main/resources/logback.xml similarity index 100% rename from core-java-networking/src/main/resources/logback.xml rename to core-java-modules/core-java-networking/src/main/resources/logback.xml diff --git a/core-java-networking/src/test/java/com/baeldung/encoderdecoder/EncoderDecoderUnitTest.java b/core-java-modules/core-java-networking/src/test/java/com/baeldung/encoderdecoder/EncoderDecoderUnitTest.java similarity index 100% rename from core-java-networking/src/test/java/com/baeldung/encoderdecoder/EncoderDecoderUnitTest.java rename to core-java-modules/core-java-networking/src/test/java/com/baeldung/encoderdecoder/EncoderDecoderUnitTest.java diff --git a/core-java-networking/src/test/java/com/baeldung/http/HttpRequestLiveTest.java b/core-java-modules/core-java-networking/src/test/java/com/baeldung/http/HttpRequestLiveTest.java similarity index 100% rename from core-java-networking/src/test/java/com/baeldung/http/HttpRequestLiveTest.java rename to core-java-modules/core-java-networking/src/test/java/com/baeldung/http/HttpRequestLiveTest.java diff --git a/core-java-networking/src/test/java/com/baeldung/networking/interfaces/NetworkInterfaceManualTest.java b/core-java-modules/core-java-networking/src/test/java/com/baeldung/networking/interfaces/NetworkInterfaceManualTest.java similarity index 100% rename from core-java-networking/src/test/java/com/baeldung/networking/interfaces/NetworkInterfaceManualTest.java rename to core-java-modules/core-java-networking/src/test/java/com/baeldung/networking/interfaces/NetworkInterfaceManualTest.java diff --git a/core-java-networking/src/test/java/com/baeldung/networking/udp/UDPLiveTest.java b/core-java-modules/core-java-networking/src/test/java/com/baeldung/networking/udp/UDPLiveTest.java similarity index 100% rename from core-java-networking/src/test/java/com/baeldung/networking/udp/UDPLiveTest.java rename to core-java-modules/core-java-networking/src/test/java/com/baeldung/networking/udp/UDPLiveTest.java diff --git a/core-java-networking/src/test/java/com/baeldung/networking/udp/broadcast/BroadcastLiveTest.java b/core-java-modules/core-java-networking/src/test/java/com/baeldung/networking/udp/broadcast/BroadcastLiveTest.java similarity index 100% rename from core-java-networking/src/test/java/com/baeldung/networking/udp/broadcast/BroadcastLiveTest.java rename to core-java-modules/core-java-networking/src/test/java/com/baeldung/networking/udp/broadcast/BroadcastLiveTest.java diff --git a/core-java-networking/src/test/java/com/baeldung/networking/udp/multicast/MulticastLiveTest.java b/core-java-modules/core-java-networking/src/test/java/com/baeldung/networking/udp/multicast/MulticastLiveTest.java similarity index 100% rename from core-java-networking/src/test/java/com/baeldung/networking/udp/multicast/MulticastLiveTest.java rename to core-java-modules/core-java-networking/src/test/java/com/baeldung/networking/udp/multicast/MulticastLiveTest.java diff --git a/core-java-networking/src/test/java/com/baeldung/networking/uriurl/URIDemoLiveTest.java b/core-java-modules/core-java-networking/src/test/java/com/baeldung/networking/uriurl/URIDemoLiveTest.java similarity index 100% rename from core-java-networking/src/test/java/com/baeldung/networking/uriurl/URIDemoLiveTest.java rename to core-java-modules/core-java-networking/src/test/java/com/baeldung/networking/uriurl/URIDemoLiveTest.java diff --git a/core-java-networking/src/test/java/com/baeldung/networking/uriurl/URIvsURLUnitTest.java b/core-java-modules/core-java-networking/src/test/java/com/baeldung/networking/uriurl/URIvsURLUnitTest.java similarity index 100% rename from core-java-networking/src/test/java/com/baeldung/networking/uriurl/URIvsURLUnitTest.java rename to core-java-modules/core-java-networking/src/test/java/com/baeldung/networking/uriurl/URIvsURLUnitTest.java diff --git a/core-java-networking/src/test/java/com/baeldung/networking/uriurl/URLDemoLiveTest.java b/core-java-modules/core-java-networking/src/test/java/com/baeldung/networking/uriurl/URLDemoLiveTest.java similarity index 100% rename from core-java-networking/src/test/java/com/baeldung/networking/uriurl/URLDemoLiveTest.java rename to core-java-modules/core-java-networking/src/test/java/com/baeldung/networking/uriurl/URLDemoLiveTest.java diff --git a/core-java-networking/src/test/java/com/baeldung/networking/url/UrlUnitTest.java b/core-java-modules/core-java-networking/src/test/java/com/baeldung/networking/url/UrlUnitTest.java similarity index 100% rename from core-java-networking/src/test/java/com/baeldung/networking/url/UrlUnitTest.java rename to core-java-modules/core-java-networking/src/test/java/com/baeldung/networking/url/UrlUnitTest.java diff --git a/core-java-networking/src/test/java/com/baeldung/socket/EchoIntegrationTest.java b/core-java-modules/core-java-networking/src/test/java/com/baeldung/socket/EchoIntegrationTest.java similarity index 100% rename from core-java-networking/src/test/java/com/baeldung/socket/EchoIntegrationTest.java rename to core-java-modules/core-java-networking/src/test/java/com/baeldung/socket/EchoIntegrationTest.java diff --git a/core-java-networking/src/test/java/com/baeldung/socket/GreetServerIntegrationTest.java b/core-java-modules/core-java-networking/src/test/java/com/baeldung/socket/GreetServerIntegrationTest.java similarity index 100% rename from core-java-networking/src/test/java/com/baeldung/socket/GreetServerIntegrationTest.java rename to core-java-modules/core-java-networking/src/test/java/com/baeldung/socket/GreetServerIntegrationTest.java diff --git a/core-java-networking/src/test/java/com/baeldung/socket/SocketEchoMultiIntegrationTest.java b/core-java-modules/core-java-networking/src/test/java/com/baeldung/socket/SocketEchoMultiIntegrationTest.java similarity index 100% rename from core-java-networking/src/test/java/com/baeldung/socket/SocketEchoMultiIntegrationTest.java rename to core-java-modules/core-java-networking/src/test/java/com/baeldung/socket/SocketEchoMultiIntegrationTest.java diff --git a/core-java-networking/src/test/java/com/baeldung/socket/read/SocketReadAllDataLiveTest.java b/core-java-modules/core-java-networking/src/test/java/com/baeldung/socket/read/SocketReadAllDataLiveTest.java similarity index 100% rename from core-java-networking/src/test/java/com/baeldung/socket/read/SocketReadAllDataLiveTest.java rename to core-java-modules/core-java-networking/src/test/java/com/baeldung/socket/read/SocketReadAllDataLiveTest.java diff --git a/core-java-networking/src/test/resources/.gitignore b/core-java-modules/core-java-networking/src/test/resources/.gitignore similarity index 100% rename from core-java-networking/src/test/resources/.gitignore rename to core-java-modules/core-java-networking/src/test/resources/.gitignore diff --git a/core-java-os/.gitignore b/core-java-modules/core-java-os/.gitignore similarity index 100% rename from core-java-os/.gitignore rename to core-java-modules/core-java-os/.gitignore diff --git a/core-java-os/README.md b/core-java-modules/core-java-os/README.md similarity index 100% rename from core-java-os/README.md rename to core-java-modules/core-java-os/README.md diff --git a/core-java-os/pom.xml b/core-java-modules/core-java-os/pom.xml similarity index 95% rename from core-java-os/pom.xml rename to core-java-modules/core-java-os/pom.xml index c9097cb554..85194b176e 100644 --- a/core-java-os/pom.xml +++ b/core-java-modules/core-java-os/pom.xml @@ -1,82 +1,82 @@ - - 4.0.0 - com.baeldung - core-java-os - 0.1.0-SNAPSHOT - core-java-os - jar - - - com.baeldung - parent-java - 0.0.1-SNAPSHOT - ../parent-java - - - - - org.apache.commons - commons-collections4 - ${commons-collections4.version} - - - commons-io - commons-io - ${commons-io.version} - - - org.apache.commons - commons-lang3 - ${commons-lang3.version} - - - log4j - log4j - ${log4j.version} - - - - org.assertj - assertj-core - ${assertj.version} - test - - - - - core-java-os - - - src/main/resources - true - - - - - - org.apache.maven.plugins - maven-compiler-plugin - ${maven-compiler-plugin.version} - - ${maven.compiler.source} - ${maven.compiler.target} - - - - - - - - 3.5 - 4.1 - 4.01 - - - 3.6.1 - 1.8.9 - 1.9 - 1.9 - 25.1-jre - - + + 4.0.0 + com.baeldung + core-java-os + 0.1.0-SNAPSHOT + core-java-os + jar + + + com.baeldung + parent-java + 0.0.1-SNAPSHOT + ../../parent-java + + + + + org.apache.commons + commons-collections4 + ${commons-collections4.version} + + + commons-io + commons-io + ${commons-io.version} + + + org.apache.commons + commons-lang3 + ${commons-lang3.version} + + + log4j + log4j + ${log4j.version} + + + + org.assertj + assertj-core + ${assertj.version} + test + + + + + core-java-os + + + src/main/resources + true + + + + + + org.apache.maven.plugins + maven-compiler-plugin + ${maven-compiler-plugin.version} + + ${maven.compiler.source} + ${maven.compiler.target} + + + + + + + + 3.5 + 4.1 + 4.01 + + + 3.6.1 + 1.8.9 + 1.9 + 1.9 + 25.1-jre + + diff --git a/core-java-os/src/main/java/com/baeldung/java9/process/ChildProcess.java b/core-java-modules/core-java-os/src/main/java/com/baeldung/java9/process/ChildProcess.java similarity index 100% rename from core-java-os/src/main/java/com/baeldung/java9/process/ChildProcess.java rename to core-java-modules/core-java-os/src/main/java/com/baeldung/java9/process/ChildProcess.java diff --git a/core-java-os/src/main/java/com/baeldung/java9/process/OutputStreamExample.java b/core-java-modules/core-java-os/src/main/java/com/baeldung/java9/process/OutputStreamExample.java similarity index 96% rename from core-java-os/src/main/java/com/baeldung/java9/process/OutputStreamExample.java rename to core-java-modules/core-java-os/src/main/java/com/baeldung/java9/process/OutputStreamExample.java index 443847916a..37378f9d6c 100644 --- a/core-java-os/src/main/java/com/baeldung/java9/process/OutputStreamExample.java +++ b/core-java-modules/core-java-os/src/main/java/com/baeldung/java9/process/OutputStreamExample.java @@ -1,16 +1,16 @@ -package com.baeldung.java9.process; - -import java.util.logging.Level; -import java.util.logging.Logger; - -public class OutputStreamExample { - - public static void main(String[] args) { - Logger log = Logger.getLogger(OutputStreamExample.class.getName()); - log.log(Level.INFO, Integer.toString(sum(1,2))); - } - - public static int sum(int a, int b) { - return a + b; - } -} +package com.baeldung.java9.process; + +import java.util.logging.Level; +import java.util.logging.Logger; + +public class OutputStreamExample { + + public static void main(String[] args) { + Logger log = Logger.getLogger(OutputStreamExample.class.getName()); + log.log(Level.INFO, Integer.toString(sum(1,2))); + } + + public static int sum(int a, int b) { + return a + b; + } +} diff --git a/core-java-os/src/main/java/com/baeldung/java9/process/ProcessCompilationError.java b/core-java-modules/core-java-os/src/main/java/com/baeldung/java9/process/ProcessCompilationError.java similarity index 100% rename from core-java-os/src/main/java/com/baeldung/java9/process/ProcessCompilationError.java rename to core-java-modules/core-java-os/src/main/java/com/baeldung/java9/process/ProcessCompilationError.java diff --git a/core-java-os/src/main/java/com/baeldung/java9/process/ProcessUnderstanding.java b/core-java-modules/core-java-os/src/main/java/com/baeldung/java9/process/ProcessUnderstanding.java similarity index 100% rename from core-java-os/src/main/java/com/baeldung/java9/process/ProcessUnderstanding.java rename to core-java-modules/core-java-os/src/main/java/com/baeldung/java9/process/ProcessUnderstanding.java diff --git a/core-java-os/src/main/java/com/baeldung/java9/process/ProcessUtils.java b/core-java-modules/core-java-os/src/main/java/com/baeldung/java9/process/ProcessUtils.java similarity index 96% rename from core-java-os/src/main/java/com/baeldung/java9/process/ProcessUtils.java rename to core-java-modules/core-java-os/src/main/java/com/baeldung/java9/process/ProcessUtils.java index 5cd2567fb3..1b952f0c3c 100644 --- a/core-java-os/src/main/java/com/baeldung/java9/process/ProcessUtils.java +++ b/core-java-modules/core-java-os/src/main/java/com/baeldung/java9/process/ProcessUtils.java @@ -1,43 +1,43 @@ -package com.baeldung.java9.process; - -import java.io.File; -import java.io.IOException; -import java.security.NoSuchAlgorithmException; -import java.security.SecureRandom; -import java.time.Duration; -import java.time.Instant; -import java.util.stream.Stream; - -public class ProcessUtils { - - public static String getClassPath() { - String cp = System.getProperty("java.class.path"); - System.out.println("ClassPath is " + cp); - return cp; - } - - public static File getJavaCmd() throws IOException { - String javaHome = System.getProperty("java.home"); - File javaCmd; - if (System.getProperty("os.name").startsWith("Win")) { - javaCmd = new File(javaHome, "bin/java.exe"); - } else { - javaCmd = new File(javaHome, "bin/java"); - } - if (javaCmd.canExecute()) { - return javaCmd; - } else { - throw new UnsupportedOperationException(javaCmd.getCanonicalPath() + " is not executable"); - } - } - - public static String getMainClass() { - return System.getProperty("sun.java.command"); - } - - public static String getSystemProperties() { - StringBuilder sb = new StringBuilder(); - System.getProperties().forEach((s1, s2) -> sb.append(s1 + " - " + s2)); - return sb.toString(); - } -} +package com.baeldung.java9.process; + +import java.io.File; +import java.io.IOException; +import java.security.NoSuchAlgorithmException; +import java.security.SecureRandom; +import java.time.Duration; +import java.time.Instant; +import java.util.stream.Stream; + +public class ProcessUtils { + + public static String getClassPath() { + String cp = System.getProperty("java.class.path"); + System.out.println("ClassPath is " + cp); + return cp; + } + + public static File getJavaCmd() throws IOException { + String javaHome = System.getProperty("java.home"); + File javaCmd; + if (System.getProperty("os.name").startsWith("Win")) { + javaCmd = new File(javaHome, "bin/java.exe"); + } else { + javaCmd = new File(javaHome, "bin/java"); + } + if (javaCmd.canExecute()) { + return javaCmd; + } else { + throw new UnsupportedOperationException(javaCmd.getCanonicalPath() + " is not executable"); + } + } + + public static String getMainClass() { + return System.getProperty("sun.java.command"); + } + + public static String getSystemProperties() { + StringBuilder sb = new StringBuilder(); + System.getProperties().forEach((s1, s2) -> sb.append(s1 + " - " + s2)); + return sb.toString(); + } +} diff --git a/core-java-os/src/main/java/com/baeldung/java9/process/ServiceMain.java b/core-java-modules/core-java-os/src/main/java/com/baeldung/java9/process/ServiceMain.java similarity index 96% rename from core-java-os/src/main/java/com/baeldung/java9/process/ServiceMain.java rename to core-java-modules/core-java-os/src/main/java/com/baeldung/java9/process/ServiceMain.java index 5dc00dba25..77831f601c 100644 --- a/core-java-os/src/main/java/com/baeldung/java9/process/ServiceMain.java +++ b/core-java-modules/core-java-os/src/main/java/com/baeldung/java9/process/ServiceMain.java @@ -1,21 +1,21 @@ -package com.baeldung.java9.process; - -import java.util.Optional; - -public class ServiceMain { - - public static void main(String[] args) throws InterruptedException { - ProcessHandle thisProcess = ProcessHandle.current(); - long pid = thisProcess.pid(); - - Optional opArgs = Optional.ofNullable(args); - String procName = opArgs.map(str -> str.length > 0 ? str[0] : null).orElse(System.getProperty("sun.java.command")); - - for (int i = 0; i < 10000; i++) { - System.out.println("Process " + procName + " with ID " + pid + " is running!"); - Thread.sleep(10000); - } - - } - -} +package com.baeldung.java9.process; + +import java.util.Optional; + +public class ServiceMain { + + public static void main(String[] args) throws InterruptedException { + ProcessHandle thisProcess = ProcessHandle.current(); + long pid = thisProcess.pid(); + + Optional opArgs = Optional.ofNullable(args); + String procName = opArgs.map(str -> str.length > 0 ? str[0] : null).orElse(System.getProperty("sun.java.command")); + + for (int i = 0; i < 10000; i++) { + System.out.println("Process " + procName + " with ID " + pid + " is running!"); + Thread.sleep(10000); + } + + } + +} diff --git a/core-java-os/src/main/resources/logback.xml b/core-java-modules/core-java-os/src/main/resources/logback.xml similarity index 100% rename from core-java-os/src/main/resources/logback.xml rename to core-java-modules/core-java-os/src/main/resources/logback.xml diff --git a/core-java-os/src/test/java/com/baeldung/java9/process/ProcessAPIEnhancementsUnitTest.java b/core-java-modules/core-java-os/src/test/java/com/baeldung/java9/process/ProcessAPIEnhancementsUnitTest.java similarity index 100% rename from core-java-os/src/test/java/com/baeldung/java9/process/ProcessAPIEnhancementsUnitTest.java rename to core-java-modules/core-java-os/src/test/java/com/baeldung/java9/process/ProcessAPIEnhancementsUnitTest.java diff --git a/core-java-os/src/test/java/com/baeldung/java9/process/ProcessApiUnitTest.java b/core-java-modules/core-java-os/src/test/java/com/baeldung/java9/process/ProcessApiUnitTest.java similarity index 97% rename from core-java-os/src/test/java/com/baeldung/java9/process/ProcessApiUnitTest.java rename to core-java-modules/core-java-os/src/test/java/com/baeldung/java9/process/ProcessApiUnitTest.java index 8bdf8cb09f..c3f390d8ae 100644 --- a/core-java-os/src/test/java/com/baeldung/java9/process/ProcessApiUnitTest.java +++ b/core-java-modules/core-java-os/src/test/java/com/baeldung/java9/process/ProcessApiUnitTest.java @@ -1,111 +1,111 @@ -package com.baeldung.java9.process; - -import java.io.IOException; -import java.security.NoSuchAlgorithmException; -import java.security.SecureRandom; -import java.time.Duration; -import java.time.Instant; -import java.util.ArrayList; -import java.util.List; -import java.util.Optional; -import java.util.concurrent.CompletableFuture; -import java.util.stream.Stream; - -import org.junit.Before; -import org.junit.Test; - -import junit.framework.Assert; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - -public class ProcessApiUnitTest { - - @Before - public void init() { - - } - - @Test - public void processInfoExample() throws NoSuchAlgorithmException { - ProcessHandle self = ProcessHandle.current(); - long PID = self.pid(); - ProcessHandle.Info procInfo = self.info(); - Optional args = procInfo.arguments(); - Optional cmd = procInfo.commandLine(); - Optional startTime = procInfo.startInstant(); - Optional cpuUsage = procInfo.totalCpuDuration(); - - waistCPU(); - System.out.println("Args " + args); - System.out.println("Command " + cmd.orElse("EmptyCmd")); - System.out.println("Start time: " + startTime.get().toString()); - System.out.println(cpuUsage.get().toMillis()); - - Stream allProc = ProcessHandle.current().children(); - allProc.forEach(p -> { - System.out.println("Proc " + p.pid()); - }); - - } - - @Test - public void createAndDestroyProcess() throws IOException, InterruptedException { - int numberOfChildProcesses = 5; - for (int i = 0; i < numberOfChildProcesses; i++) { - createNewJVM(ServiceMain.class, i).pid(); - } - - Stream childProc = ProcessHandle.current().children(); - assertEquals(childProc.count(), numberOfChildProcesses); - - childProc = ProcessHandle.current().children(); - childProc.forEach(processHandle -> { - assertTrue("Process " + processHandle.pid() + " should be alive!", processHandle.isAlive()); - CompletableFuture onProcExit = processHandle.onExit(); - onProcExit.thenAccept(procHandle -> { - System.out.println("Process with PID " + procHandle.pid() + " has stopped"); - }); - }); - - Thread.sleep(10000); - - childProc = ProcessHandle.current().children(); - childProc.forEach(procHandle -> { - assertTrue("Could not kill process " + procHandle.pid(), procHandle.destroy()); - }); - - Thread.sleep(5000); - - childProc = ProcessHandle.current().children(); - childProc.forEach(procHandle -> { - assertFalse("Process " + procHandle.pid() + " should not be alive!", procHandle.isAlive()); - }); - - } - - private Process createNewJVM(Class mainClass, int number) throws IOException { - ArrayList cmdParams = new ArrayList(5); - cmdParams.add(ProcessUtils.getJavaCmd().getAbsolutePath()); - cmdParams.add("-cp"); - cmdParams.add(ProcessUtils.getClassPath()); - cmdParams.add(mainClass.getName()); - cmdParams.add("Service " + number); - ProcessBuilder myService = new ProcessBuilder(cmdParams); - myService.inheritIO(); - return myService.start(); - } - - private void waistCPU() throws NoSuchAlgorithmException { - ArrayList randArr = new ArrayList(4096); - SecureRandom sr = SecureRandom.getInstanceStrong(); - Duration somecpu = Duration.ofMillis(4200L); - Instant end = Instant.now().plus(somecpu); - while (Instant.now().isBefore(end)) { - // System.out.println(sr.nextInt()); - randArr.add(sr.nextInt()); - } - } - -} +package com.baeldung.java9.process; + +import java.io.IOException; +import java.security.NoSuchAlgorithmException; +import java.security.SecureRandom; +import java.time.Duration; +import java.time.Instant; +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; +import java.util.concurrent.CompletableFuture; +import java.util.stream.Stream; + +import org.junit.Before; +import org.junit.Test; + +import junit.framework.Assert; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +public class ProcessApiUnitTest { + + @Before + public void init() { + + } + + @Test + public void processInfoExample() throws NoSuchAlgorithmException { + ProcessHandle self = ProcessHandle.current(); + long PID = self.pid(); + ProcessHandle.Info procInfo = self.info(); + Optional args = procInfo.arguments(); + Optional cmd = procInfo.commandLine(); + Optional startTime = procInfo.startInstant(); + Optional cpuUsage = procInfo.totalCpuDuration(); + + waistCPU(); + System.out.println("Args " + args); + System.out.println("Command " + cmd.orElse("EmptyCmd")); + System.out.println("Start time: " + startTime.get().toString()); + System.out.println(cpuUsage.get().toMillis()); + + Stream allProc = ProcessHandle.current().children(); + allProc.forEach(p -> { + System.out.println("Proc " + p.pid()); + }); + + } + + @Test + public void createAndDestroyProcess() throws IOException, InterruptedException { + int numberOfChildProcesses = 5; + for (int i = 0; i < numberOfChildProcesses; i++) { + createNewJVM(ServiceMain.class, i).pid(); + } + + Stream childProc = ProcessHandle.current().children(); + assertEquals(childProc.count(), numberOfChildProcesses); + + childProc = ProcessHandle.current().children(); + childProc.forEach(processHandle -> { + assertTrue("Process " + processHandle.pid() + " should be alive!", processHandle.isAlive()); + CompletableFuture onProcExit = processHandle.onExit(); + onProcExit.thenAccept(procHandle -> { + System.out.println("Process with PID " + procHandle.pid() + " has stopped"); + }); + }); + + Thread.sleep(10000); + + childProc = ProcessHandle.current().children(); + childProc.forEach(procHandle -> { + assertTrue("Could not kill process " + procHandle.pid(), procHandle.destroy()); + }); + + Thread.sleep(5000); + + childProc = ProcessHandle.current().children(); + childProc.forEach(procHandle -> { + assertFalse("Process " + procHandle.pid() + " should not be alive!", procHandle.isAlive()); + }); + + } + + private Process createNewJVM(Class mainClass, int number) throws IOException { + ArrayList cmdParams = new ArrayList(5); + cmdParams.add(ProcessUtils.getJavaCmd().getAbsolutePath()); + cmdParams.add("-cp"); + cmdParams.add(ProcessUtils.getClassPath()); + cmdParams.add(mainClass.getName()); + cmdParams.add("Service " + number); + ProcessBuilder myService = new ProcessBuilder(cmdParams); + myService.inheritIO(); + return myService.start(); + } + + private void waistCPU() throws NoSuchAlgorithmException { + ArrayList randArr = new ArrayList(4096); + SecureRandom sr = SecureRandom.getInstanceStrong(); + Duration somecpu = Duration.ofMillis(4200L); + Instant end = Instant.now().plus(somecpu); + while (Instant.now().isBefore(end)) { + // System.out.println(sr.nextInt()); + randArr.add(sr.nextInt()); + } + } + +} diff --git a/core-java-os/src/test/java/com/baeldung/java9/process/ProcessUnderstandingUnitTest.java b/core-java-modules/core-java-os/src/test/java/com/baeldung/java9/process/ProcessUnderstandingUnitTest.java similarity index 100% rename from core-java-os/src/test/java/com/baeldung/java9/process/ProcessUnderstandingUnitTest.java rename to core-java-modules/core-java-os/src/test/java/com/baeldung/java9/process/ProcessUnderstandingUnitTest.java diff --git a/core-java-os/src/test/java/com/baeldung/processbuilder/ProcessBuilderUnitTest.java b/core-java-modules/core-java-os/src/test/java/com/baeldung/processbuilder/ProcessBuilderUnitTest.java similarity index 97% rename from core-java-os/src/test/java/com/baeldung/processbuilder/ProcessBuilderUnitTest.java rename to core-java-modules/core-java-os/src/test/java/com/baeldung/processbuilder/ProcessBuilderUnitTest.java index 0458383e99..8fc5f9f160 100644 --- a/core-java-os/src/test/java/com/baeldung/processbuilder/ProcessBuilderUnitTest.java +++ b/core-java-modules/core-java-os/src/test/java/com/baeldung/processbuilder/ProcessBuilderUnitTest.java @@ -1,182 +1,182 @@ -package com.baeldung.processbuilder; - -import static org.hamcrest.Matchers.containsString; -import static org.hamcrest.Matchers.empty; -import static org.hamcrest.Matchers.hasItem; -import static org.hamcrest.Matchers.hasItems; -import static org.hamcrest.Matchers.is; -import static org.hamcrest.Matchers.not; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertThat; - -import java.io.BufferedReader; -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.lang.ProcessBuilder.Redirect; -import java.nio.file.Files; -import java.util.Arrays; -import java.util.List; -import java.util.Map; -import java.util.concurrent.ExecutionException; -import java.util.stream.Collectors; - -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.TemporaryFolder; - -public class ProcessBuilderUnitTest { - - @Rule - public TemporaryFolder tempFolder = new TemporaryFolder(); - - @Test - public void givenProcessBuilder_whenInvokeStart_thenSuccess() throws IOException, InterruptedException, ExecutionException { - ProcessBuilder processBuilder = new ProcessBuilder("java", "-version"); - processBuilder.redirectErrorStream(true); - - Process process = processBuilder.start(); - - List results = readOutput(process.getInputStream()); - assertThat("Results should not be empty", results, is(not(empty()))); - assertThat("Results should contain java version: ", results, hasItem(containsString("java version"))); - - int exitCode = process.waitFor(); - assertEquals("No errors should be detected", 0, exitCode); - } - - @Test - public void givenProcessBuilder_whenModifyEnvironment_thenSuccess() throws IOException, InterruptedException { - ProcessBuilder processBuilder = new ProcessBuilder(); - Map environment = processBuilder.environment(); - environment.forEach((key, value) -> System.out.println(key + value)); - - environment.put("GREETING", "Hola Mundo"); - - List command = getGreetingCommand(); - processBuilder.command(command); - Process process = processBuilder.start(); - - List results = readOutput(process.getInputStream()); - assertThat("Results should not be empty", results, is(not(empty()))); - assertThat("Results should contain a greeting ", results, hasItem(containsString("Hola Mundo"))); - - int exitCode = process.waitFor(); - assertEquals("No errors should be detected", 0, exitCode); - } - - @Test - public void givenProcessBuilder_whenModifyWorkingDir_thenSuccess() throws IOException, InterruptedException { - List command = getDirectoryListingCommand(); - ProcessBuilder processBuilder = new ProcessBuilder(command); - - processBuilder.directory(new File("src")); - Process process = processBuilder.start(); - - List results = readOutput(process.getInputStream()); - assertThat("Results should not be empty", results, is(not(empty()))); - assertThat("Results should contain directory listing: ", results, hasItems(containsString("main"), containsString("test"))); - - int exitCode = process.waitFor(); - assertEquals("No errors should be detected", 0, exitCode); - } - - @Test - public void givenProcessBuilder_whenRedirectStandardOutput_thenSuccessWriting() throws IOException, InterruptedException { - ProcessBuilder processBuilder = new ProcessBuilder("java", "-version"); - - processBuilder.redirectErrorStream(true); - File log = tempFolder.newFile("java-version.log"); - processBuilder.redirectOutput(log); - - Process process = processBuilder.start(); - - assertEquals("If redirected, should be -1 ", -1, process.getInputStream() - .read()); - int exitCode = process.waitFor(); - assertEquals("No errors should be detected", 0, exitCode); - - List lines = Files.lines(log.toPath()) - .collect(Collectors.toList()); - - assertThat("Results should not be empty", lines, is(not(empty()))); - assertThat("Results should contain java version: ", lines, hasItem(containsString("java version"))); - } - - @Test - public void givenProcessBuilder_whenRedirectStandardOutput_thenSuccessAppending() throws IOException, InterruptedException { - ProcessBuilder processBuilder = new ProcessBuilder("java", "-version"); - - File log = tempFolder.newFile("java-version-append.log"); - processBuilder.redirectErrorStream(true); - processBuilder.redirectOutput(Redirect.appendTo(log)); - - Process process = processBuilder.start(); - - assertEquals("If redirected output, should be -1 ", -1, process.getInputStream() - .read()); - - int exitCode = process.waitFor(); - assertEquals("No errors should be detected", 0, exitCode); - - List lines = Files.lines(log.toPath()) - .collect(Collectors.toList()); - - assertThat("Results should not be empty", lines, is(not(empty()))); - assertThat("Results should contain java version: ", lines, hasItem(containsString("java version"))); - } - - @Test - public void givenProcessBuilder_whenStartingPipeline_thenSuccess() throws IOException, InterruptedException { - if (!isWindows()) { - List builders = Arrays.asList( - new ProcessBuilder("find", "src", "-name", "*.java", "-type", "f"), - new ProcessBuilder("wc", "-l")); - - List processes = ProcessBuilder.startPipeline(builders); - Process last = processes.get(processes.size() - 1); - - List output = readOutput(last.getInputStream()); - assertThat("Results should not be empty", output, is(not(empty()))); - } - } - - @Test - public void givenProcessBuilder_whenInheritIO_thenSuccess() throws IOException, InterruptedException { - List command = getEchoCommand(); - ProcessBuilder processBuilder = new ProcessBuilder(command); - - processBuilder.inheritIO(); - Process process = processBuilder.start(); - - int exitCode = process.waitFor(); - assertEquals("No errors should be detected", 0, exitCode); - } - - private List readOutput(InputStream inputStream) throws IOException { - try (BufferedReader output = new BufferedReader(new InputStreamReader(inputStream))) { - return output.lines() - .collect(Collectors.toList()); - } - } - - private List getDirectoryListingCommand() { - return isWindows() ? Arrays.asList("cmd.exe", "/c", "dir") : Arrays.asList("/bin/sh", "-c", "ls"); - } - - private List getGreetingCommand() { - return isWindows() ? Arrays.asList("cmd.exe", "/c", "echo %GREETING%") : Arrays.asList("/bin/bash", "-c", "echo $GREETING"); - } - - private List getEchoCommand() { - return isWindows() ? Arrays.asList("cmd.exe", "/c", "echo hello") : Arrays.asList("/bin/sh", "-c", "echo hello"); - } - - private boolean isWindows() { - return System.getProperty("os.name") - .toLowerCase() - .startsWith("windows"); - } - -} +package com.baeldung.processbuilder; + +import static org.hamcrest.Matchers.containsString; +import static org.hamcrest.Matchers.empty; +import static org.hamcrest.Matchers.hasItem; +import static org.hamcrest.Matchers.hasItems; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.not; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThat; + +import java.io.BufferedReader; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.lang.ProcessBuilder.Redirect; +import java.nio.file.Files; +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import java.util.concurrent.ExecutionException; +import java.util.stream.Collectors; + +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.TemporaryFolder; + +public class ProcessBuilderUnitTest { + + @Rule + public TemporaryFolder tempFolder = new TemporaryFolder(); + + @Test + public void givenProcessBuilder_whenInvokeStart_thenSuccess() throws IOException, InterruptedException, ExecutionException { + ProcessBuilder processBuilder = new ProcessBuilder("java", "-version"); + processBuilder.redirectErrorStream(true); + + Process process = processBuilder.start(); + + List results = readOutput(process.getInputStream()); + assertThat("Results should not be empty", results, is(not(empty()))); + assertThat("Results should contain java version: ", results, hasItem(containsString("java version"))); + + int exitCode = process.waitFor(); + assertEquals("No errors should be detected", 0, exitCode); + } + + @Test + public void givenProcessBuilder_whenModifyEnvironment_thenSuccess() throws IOException, InterruptedException { + ProcessBuilder processBuilder = new ProcessBuilder(); + Map environment = processBuilder.environment(); + environment.forEach((key, value) -> System.out.println(key + value)); + + environment.put("GREETING", "Hola Mundo"); + + List command = getGreetingCommand(); + processBuilder.command(command); + Process process = processBuilder.start(); + + List results = readOutput(process.getInputStream()); + assertThat("Results should not be empty", results, is(not(empty()))); + assertThat("Results should contain a greeting ", results, hasItem(containsString("Hola Mundo"))); + + int exitCode = process.waitFor(); + assertEquals("No errors should be detected", 0, exitCode); + } + + @Test + public void givenProcessBuilder_whenModifyWorkingDir_thenSuccess() throws IOException, InterruptedException { + List command = getDirectoryListingCommand(); + ProcessBuilder processBuilder = new ProcessBuilder(command); + + processBuilder.directory(new File("src")); + Process process = processBuilder.start(); + + List results = readOutput(process.getInputStream()); + assertThat("Results should not be empty", results, is(not(empty()))); + assertThat("Results should contain directory listing: ", results, hasItems(containsString("main"), containsString("test"))); + + int exitCode = process.waitFor(); + assertEquals("No errors should be detected", 0, exitCode); + } + + @Test + public void givenProcessBuilder_whenRedirectStandardOutput_thenSuccessWriting() throws IOException, InterruptedException { + ProcessBuilder processBuilder = new ProcessBuilder("java", "-version"); + + processBuilder.redirectErrorStream(true); + File log = tempFolder.newFile("java-version.log"); + processBuilder.redirectOutput(log); + + Process process = processBuilder.start(); + + assertEquals("If redirected, should be -1 ", -1, process.getInputStream() + .read()); + int exitCode = process.waitFor(); + assertEquals("No errors should be detected", 0, exitCode); + + List lines = Files.lines(log.toPath()) + .collect(Collectors.toList()); + + assertThat("Results should not be empty", lines, is(not(empty()))); + assertThat("Results should contain java version: ", lines, hasItem(containsString("java version"))); + } + + @Test + public void givenProcessBuilder_whenRedirectStandardOutput_thenSuccessAppending() throws IOException, InterruptedException { + ProcessBuilder processBuilder = new ProcessBuilder("java", "-version"); + + File log = tempFolder.newFile("java-version-append.log"); + processBuilder.redirectErrorStream(true); + processBuilder.redirectOutput(Redirect.appendTo(log)); + + Process process = processBuilder.start(); + + assertEquals("If redirected output, should be -1 ", -1, process.getInputStream() + .read()); + + int exitCode = process.waitFor(); + assertEquals("No errors should be detected", 0, exitCode); + + List lines = Files.lines(log.toPath()) + .collect(Collectors.toList()); + + assertThat("Results should not be empty", lines, is(not(empty()))); + assertThat("Results should contain java version: ", lines, hasItem(containsString("java version"))); + } + + @Test + public void givenProcessBuilder_whenStartingPipeline_thenSuccess() throws IOException, InterruptedException { + if (!isWindows()) { + List builders = Arrays.asList( + new ProcessBuilder("find", "src", "-name", "*.java", "-type", "f"), + new ProcessBuilder("wc", "-l")); + + List processes = ProcessBuilder.startPipeline(builders); + Process last = processes.get(processes.size() - 1); + + List output = readOutput(last.getInputStream()); + assertThat("Results should not be empty", output, is(not(empty()))); + } + } + + @Test + public void givenProcessBuilder_whenInheritIO_thenSuccess() throws IOException, InterruptedException { + List command = getEchoCommand(); + ProcessBuilder processBuilder = new ProcessBuilder(command); + + processBuilder.inheritIO(); + Process process = processBuilder.start(); + + int exitCode = process.waitFor(); + assertEquals("No errors should be detected", 0, exitCode); + } + + private List readOutput(InputStream inputStream) throws IOException { + try (BufferedReader output = new BufferedReader(new InputStreamReader(inputStream))) { + return output.lines() + .collect(Collectors.toList()); + } + } + + private List getDirectoryListingCommand() { + return isWindows() ? Arrays.asList("cmd.exe", "/c", "dir") : Arrays.asList("/bin/sh", "-c", "ls"); + } + + private List getGreetingCommand() { + return isWindows() ? Arrays.asList("cmd.exe", "/c", "echo %GREETING%") : Arrays.asList("/bin/bash", "-c", "echo $GREETING"); + } + + private List getEchoCommand() { + return isWindows() ? Arrays.asList("cmd.exe", "/c", "echo hello") : Arrays.asList("/bin/sh", "-c", "echo hello"); + } + + private boolean isWindows() { + return System.getProperty("os.name") + .toLowerCase() + .startsWith("windows"); + } + +} diff --git a/core-java-os/src/test/resources/.gitignore b/core-java-modules/core-java-os/src/test/resources/.gitignore similarity index 100% rename from core-java-os/src/test/resources/.gitignore rename to core-java-modules/core-java-os/src/test/resources/.gitignore diff --git a/core-java-perf/README.md b/core-java-modules/core-java-perf/README.md similarity index 100% rename from core-java-perf/README.md rename to core-java-modules/core-java-perf/README.md diff --git a/core-java-perf/pom.xml b/core-java-modules/core-java-perf/pom.xml similarity index 94% rename from core-java-perf/pom.xml rename to core-java-modules/core-java-perf/pom.xml index 0e0ec79691..f225a9554b 100644 --- a/core-java-perf/pom.xml +++ b/core-java-modules/core-java-perf/pom.xml @@ -11,7 +11,7 @@ com.baeldung parent-java 0.0.1-SNAPSHOT - ../parent-java + ../../parent-java diff --git a/core-java-perf/src/main/java/com/baeldung/flightrecorder/FlightRecorder.java b/core-java-modules/core-java-perf/src/main/java/com/baeldung/flightrecorder/FlightRecorder.java similarity index 100% rename from core-java-perf/src/main/java/com/baeldung/flightrecorder/FlightRecorder.java rename to core-java-modules/core-java-perf/src/main/java/com/baeldung/flightrecorder/FlightRecorder.java diff --git a/core-java-perf/src/main/java/com/baeldung/gc/VerboseGarbageCollectorRunner.java b/core-java-modules/core-java-perf/src/main/java/com/baeldung/gc/VerboseGarbageCollectorRunner.java similarity index 97% rename from core-java-perf/src/main/java/com/baeldung/gc/VerboseGarbageCollectorRunner.java rename to core-java-modules/core-java-perf/src/main/java/com/baeldung/gc/VerboseGarbageCollectorRunner.java index f57580bbb5..9e4e6d9902 100644 --- a/core-java-perf/src/main/java/com/baeldung/gc/VerboseGarbageCollectorRunner.java +++ b/core-java-modules/core-java-perf/src/main/java/com/baeldung/gc/VerboseGarbageCollectorRunner.java @@ -1,63 +1,63 @@ -package com.baeldung.gc; - -import java.util.HashMap; -import java.util.Map; - -/** - * A simple Java program to demonstrate how to enable verbose Garbage Collection (GC) logging. - *

- * This simple program loads 3 million {@link java.lang.String} instances into a {@link java.util.HashMap} - * object before making an explicit call to the garbage collector using System.gc(). - *

- * Finally, it removes 2 million of the {@link java.lang.String} instances from the {@link java.util.HashMap}. - * We also explicitly use System.out.println to make interpreting the output easier. - *

- * Run this program with the following arguments to see verbose GC logging in its complete form: - *

- * -XX:+UseSerialGC -Xms1024m -Xmx1024m -verbose:gc -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -XX:+PrintGCDateStamps -Xloggc:/path/to/file/gc.log
- * 
- * Where: - *
    - *
  • -XX:+UseSerialGC - specify the serial garbage collector.
  • - *
  • -Xms1024m - specify the minimal heap size.
  • - *
  • -Xmx1024m - specify the maximal heap size.
  • - *
  • -verbose:gc - activate the logging of garbage collection information in its simplest form.
  • - *
  • -XX:+PrintGCDetails - activate detailed information about garbage collection.
  • - *
  • -XX:+PrintGCTimeStamps - include a timestamp in the output reflecting the real-time passed in seconds since the JVM started.
  • - *
  • -XX:+PrintGCDateStamps - include the absolute date and time at the start of each line.
  • - *
  • -Xloggc - by default the GC log is written to stdout. Specify an output file via this argument.
  • - *
- *

- * It should be noted that the first three arguments are not strictly necessary but for the purposes or the example - * help really simplify things. - * - */ -public class VerboseGarbageCollectorRunner { - - private static Map stringContainer = new HashMap<>(); - - public static void main(String[] args) { - System.out.println("Start of program!"); - String stringWithPrefix = "stringWithPrefix"; - - // Load Java Heap with 3 M java.lang.String instances - for (int i = 0; i < 3000000; i++) { - String newString = stringWithPrefix + i; - stringContainer.put(newString, newString); - } - System.out.println("MAP size: " + stringContainer.size()); - - // Explicit GC! - System.gc(); - - // Remove 2 M out of 3 M - for (int i = 0; i < 2000000; i++) { - String newString = stringWithPrefix + i; - stringContainer.remove(newString); - } - - System.out.println("MAP size: " + stringContainer.size()); - System.out.println("End of program!"); - } - -} +package com.baeldung.gc; + +import java.util.HashMap; +import java.util.Map; + +/** + * A simple Java program to demonstrate how to enable verbose Garbage Collection (GC) logging. + *

+ * This simple program loads 3 million {@link java.lang.String} instances into a {@link java.util.HashMap} + * object before making an explicit call to the garbage collector using System.gc(). + *

+ * Finally, it removes 2 million of the {@link java.lang.String} instances from the {@link java.util.HashMap}. + * We also explicitly use System.out.println to make interpreting the output easier. + *

+ * Run this program with the following arguments to see verbose GC logging in its complete form: + *

+ * -XX:+UseSerialGC -Xms1024m -Xmx1024m -verbose:gc -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -XX:+PrintGCDateStamps -Xloggc:/path/to/file/gc.log
+ * 
+ * Where: + *
    + *
  • -XX:+UseSerialGC - specify the serial garbage collector.
  • + *
  • -Xms1024m - specify the minimal heap size.
  • + *
  • -Xmx1024m - specify the maximal heap size.
  • + *
  • -verbose:gc - activate the logging of garbage collection information in its simplest form.
  • + *
  • -XX:+PrintGCDetails - activate detailed information about garbage collection.
  • + *
  • -XX:+PrintGCTimeStamps - include a timestamp in the output reflecting the real-time passed in seconds since the JVM started.
  • + *
  • -XX:+PrintGCDateStamps - include the absolute date and time at the start of each line.
  • + *
  • -Xloggc - by default the GC log is written to stdout. Specify an output file via this argument.
  • + *
+ *

+ * It should be noted that the first three arguments are not strictly necessary but for the purposes or the example + * help really simplify things. + * + */ +public class VerboseGarbageCollectorRunner { + + private static Map stringContainer = new HashMap<>(); + + public static void main(String[] args) { + System.out.println("Start of program!"); + String stringWithPrefix = "stringWithPrefix"; + + // Load Java Heap with 3 M java.lang.String instances + for (int i = 0; i < 3000000; i++) { + String newString = stringWithPrefix + i; + stringContainer.put(newString, newString); + } + System.out.println("MAP size: " + stringContainer.size()); + + // Explicit GC! + System.gc(); + + // Remove 2 M out of 3 M + for (int i = 0; i < 2000000; i++) { + String newString = stringWithPrefix + i; + stringContainer.remove(newString); + } + + System.out.println("MAP size: " + stringContainer.size()); + System.out.println("End of program!"); + } + +} diff --git a/core-java-perf/src/main/java/com/baeldung/heapdump/HeapDump.java b/core-java-modules/core-java-perf/src/main/java/com/baeldung/heapdump/HeapDump.java similarity index 100% rename from core-java-perf/src/main/java/com/baeldung/heapdump/HeapDump.java rename to core-java-modules/core-java-perf/src/main/java/com/baeldung/heapdump/HeapDump.java diff --git a/core-java-perf/src/main/java/com/baeldung/jmx/Game.java b/core-java-modules/core-java-perf/src/main/java/com/baeldung/jmx/Game.java similarity index 100% rename from core-java-perf/src/main/java/com/baeldung/jmx/Game.java rename to core-java-modules/core-java-perf/src/main/java/com/baeldung/jmx/Game.java diff --git a/core-java-perf/src/main/java/com/baeldung/jmx/GameMBean.java b/core-java-modules/core-java-perf/src/main/java/com/baeldung/jmx/GameMBean.java similarity index 100% rename from core-java-perf/src/main/java/com/baeldung/jmx/GameMBean.java rename to core-java-modules/core-java-perf/src/main/java/com/baeldung/jmx/GameMBean.java diff --git a/core-java-perf/src/main/java/com/baeldung/jmx/JMXTutorialMainlauncher.java b/core-java-modules/core-java-perf/src/main/java/com/baeldung/jmx/JMXTutorialMainlauncher.java similarity index 100% rename from core-java-perf/src/main/java/com/baeldung/jmx/JMXTutorialMainlauncher.java rename to core-java-modules/core-java-perf/src/main/java/com/baeldung/jmx/JMXTutorialMainlauncher.java diff --git a/core-java-perf/src/main/java/com/baeldung/memoryleaks/equalshashcode/Person.java b/core-java-modules/core-java-perf/src/main/java/com/baeldung/memoryleaks/equalshashcode/Person.java old mode 100755 new mode 100644 similarity index 94% rename from core-java-perf/src/main/java/com/baeldung/memoryleaks/equalshashcode/Person.java rename to core-java-modules/core-java-perf/src/main/java/com/baeldung/memoryleaks/equalshashcode/Person.java index e16d1ae6da..a5b5794238 --- a/core-java-perf/src/main/java/com/baeldung/memoryleaks/equalshashcode/Person.java +++ b/core-java-modules/core-java-perf/src/main/java/com/baeldung/memoryleaks/equalshashcode/Person.java @@ -1,9 +1,9 @@ -package com.baeldung.memoryleaks.equalshashcode; - -public class Person { - public String name; - - public Person(String name) { - this.name = name; - } -} +package com.baeldung.memoryleaks.equalshashcode; + +public class Person { + public String name; + + public Person(String name) { + this.name = name; + } +} diff --git a/core-java-perf/src/main/java/com/baeldung/memoryleaks/equalshashcode/PersonOptimized.java b/core-java-modules/core-java-perf/src/main/java/com/baeldung/memoryleaks/equalshashcode/PersonOptimized.java old mode 100755 new mode 100644 similarity index 96% rename from core-java-perf/src/main/java/com/baeldung/memoryleaks/equalshashcode/PersonOptimized.java rename to core-java-modules/core-java-perf/src/main/java/com/baeldung/memoryleaks/equalshashcode/PersonOptimized.java index 3af70dd1eb..3e54332264 --- a/core-java-perf/src/main/java/com/baeldung/memoryleaks/equalshashcode/PersonOptimized.java +++ b/core-java-modules/core-java-perf/src/main/java/com/baeldung/memoryleaks/equalshashcode/PersonOptimized.java @@ -1,25 +1,25 @@ -package com.baeldung.memoryleaks.equalshashcode; - -public class PersonOptimized { - public String name; - - public PersonOptimized(String name) { - this.name = name; - } - - @Override - public boolean equals(Object o) { - if (o == this) return true; - if (!(o instanceof PersonOptimized)) { - return false; - } - PersonOptimized person = (PersonOptimized) o; - return person.name.equals(name); - } - - @Override - public int hashCode() { - int result = 17; - result = 31 * result + name.hashCode(); - return result; - }} +package com.baeldung.memoryleaks.equalshashcode; + +public class PersonOptimized { + public String name; + + public PersonOptimized(String name) { + this.name = name; + } + + @Override + public boolean equals(Object o) { + if (o == this) return true; + if (!(o instanceof PersonOptimized)) { + return false; + } + PersonOptimized person = (PersonOptimized) o; + return person.name.equals(name); + } + + @Override + public int hashCode() { + int result = 17; + result = 31 * result + name.hashCode(); + return result; + }} diff --git a/core-java-perf/src/main/java/com/baeldung/memoryleaks/finalize/BulkyObject.java b/core-java-modules/core-java-perf/src/main/java/com/baeldung/memoryleaks/finalize/BulkyObject.java old mode 100755 new mode 100644 similarity index 95% rename from core-java-perf/src/main/java/com/baeldung/memoryleaks/finalize/BulkyObject.java rename to core-java-modules/core-java-perf/src/main/java/com/baeldung/memoryleaks/finalize/BulkyObject.java index ce77d883f6..07ed52e38d --- a/core-java-perf/src/main/java/com/baeldung/memoryleaks/finalize/BulkyObject.java +++ b/core-java-modules/core-java-perf/src/main/java/com/baeldung/memoryleaks/finalize/BulkyObject.java @@ -1,32 +1,32 @@ -package com.baeldung.memoryleaks.finalize; - -import java.nio.charset.Charset; -import java.util.Random; - -public class BulkyObject { - private String data[]; - - public BulkyObject() { - data = new String[1000000]; - - for(int i=0; i<1000000; i++) { - data[i] = getRandomString(); - } - } - - private String getRandomString() { - byte[] array = new byte[1000]; - new Random().nextBytes(array); - return new String(array, Charset.forName("UTF-8")); - } - - @Override - public void finalize() { - try { - Thread.sleep(100); - } catch (InterruptedException e) { - e.printStackTrace(); - } - System.out.println("Finalizer called"); - } -} +package com.baeldung.memoryleaks.finalize; + +import java.nio.charset.Charset; +import java.util.Random; + +public class BulkyObject { + private String data[]; + + public BulkyObject() { + data = new String[1000000]; + + for(int i=0; i<1000000; i++) { + data[i] = getRandomString(); + } + } + + private String getRandomString() { + byte[] array = new byte[1000]; + new Random().nextBytes(array); + return new String(array, Charset.forName("UTF-8")); + } + + @Override + public void finalize() { + try { + Thread.sleep(100); + } catch (InterruptedException e) { + e.printStackTrace(); + } + System.out.println("Finalizer called"); + } +} diff --git a/core-java-perf/src/main/java/com/baeldung/memoryleaks/finalize/BulkyObjectOptimized.java b/core-java-modules/core-java-perf/src/main/java/com/baeldung/memoryleaks/finalize/BulkyObjectOptimized.java similarity index 96% rename from core-java-perf/src/main/java/com/baeldung/memoryleaks/finalize/BulkyObjectOptimized.java rename to core-java-modules/core-java-perf/src/main/java/com/baeldung/memoryleaks/finalize/BulkyObjectOptimized.java index dc1302432e..8a8f2ae6c2 100644 --- a/core-java-perf/src/main/java/com/baeldung/memoryleaks/finalize/BulkyObjectOptimized.java +++ b/core-java-modules/core-java-perf/src/main/java/com/baeldung/memoryleaks/finalize/BulkyObjectOptimized.java @@ -1,22 +1,22 @@ -package com.baeldung.memoryleaks.finalize; - -import java.nio.charset.Charset; -import java.util.Random; - -public class BulkyObjectOptimized { - private String data[]; - - public BulkyObjectOptimized() { - data = new String[1000000]; - - for(int i=0; i<1000000; i++) { - data[i] = getRandomString(); - } - } - - private String getRandomString() { - byte[] array = new byte[1000]; - new Random().nextBytes(array); - return new String(array, Charset.forName("UTF-8")); - } -} +package com.baeldung.memoryleaks.finalize; + +import java.nio.charset.Charset; +import java.util.Random; + +public class BulkyObjectOptimized { + private String data[]; + + public BulkyObjectOptimized() { + data = new String[1000000]; + + for(int i=0; i<1000000; i++) { + data[i] = getRandomString(); + } + } + + private String getRandomString() { + byte[] array = new byte[1000]; + new Random().nextBytes(array); + return new String(array, Charset.forName("UTF-8")); + } +} diff --git a/core-java-perf/src/main/java/com/baeldung/memoryleaks/innerclass/BulkyObject.java b/core-java-modules/core-java-perf/src/main/java/com/baeldung/memoryleaks/innerclass/BulkyObject.java old mode 100755 new mode 100644 similarity index 95% rename from core-java-perf/src/main/java/com/baeldung/memoryleaks/innerclass/BulkyObject.java rename to core-java-modules/core-java-perf/src/main/java/com/baeldung/memoryleaks/innerclass/BulkyObject.java index bbd5310182..47801878f8 --- a/core-java-perf/src/main/java/com/baeldung/memoryleaks/innerclass/BulkyObject.java +++ b/core-java-modules/core-java-perf/src/main/java/com/baeldung/memoryleaks/innerclass/BulkyObject.java @@ -1,22 +1,22 @@ -package com.baeldung.memoryleaks.innerclass; - -import java.nio.charset.Charset; -import java.util.Random; - -public class BulkyObject { - private String data[]; - - public BulkyObject() { - data = new String[1000000]; - - for(int i=0; i<1000000; i++) { - data[i] = getRandomString(); - } - } - - private String getRandomString() { - byte[] array = new byte[1000]; - new Random().nextBytes(array); - return new String(array, Charset.forName("UTF-8")); - } -} +package com.baeldung.memoryleaks.innerclass; + +import java.nio.charset.Charset; +import java.util.Random; + +public class BulkyObject { + private String data[]; + + public BulkyObject() { + data = new String[1000000]; + + for(int i=0; i<1000000; i++) { + data[i] = getRandomString(); + } + } + + private String getRandomString() { + byte[] array = new byte[1000]; + new Random().nextBytes(array); + return new String(array, Charset.forName("UTF-8")); + } +} diff --git a/core-java-perf/src/main/java/com/baeldung/memoryleaks/innerclass/InnerClassDriver.java b/core-java-modules/core-java-perf/src/main/java/com/baeldung/memoryleaks/innerclass/InnerClassDriver.java old mode 100755 new mode 100644 similarity index 97% rename from core-java-perf/src/main/java/com/baeldung/memoryleaks/innerclass/InnerClassDriver.java rename to core-java-modules/core-java-perf/src/main/java/com/baeldung/memoryleaks/innerclass/InnerClassDriver.java index 06f928bc4a..e3e4506397 --- a/core-java-perf/src/main/java/com/baeldung/memoryleaks/innerclass/InnerClassDriver.java +++ b/core-java-modules/core-java-perf/src/main/java/com/baeldung/memoryleaks/innerclass/InnerClassDriver.java @@ -1,17 +1,17 @@ -package com.baeldung.memoryleaks.innerclass; - -public class InnerClassDriver { - public static InnerClassWrapper.SimpleInnerClass getSimpleInnerClassObj() { - return new InnerClassWrapper().new SimpleInnerClass(); - } - - public static void main2(String[] args) { - InnerClassWrapper.SimpleInnerClass simpleInnerClassObj = getSimpleInnerClassObj(); - System.out.println("Debug point"); - } - - public static void main(String[] args) { - StaticNestedClassWrapper.StaticNestedClass simpleInnerClassObj = new StaticNestedClassWrapper.StaticNestedClass(); - System.out.println("Debug point"); - } -} +package com.baeldung.memoryleaks.innerclass; + +public class InnerClassDriver { + public static InnerClassWrapper.SimpleInnerClass getSimpleInnerClassObj() { + return new InnerClassWrapper().new SimpleInnerClass(); + } + + public static void main2(String[] args) { + InnerClassWrapper.SimpleInnerClass simpleInnerClassObj = getSimpleInnerClassObj(); + System.out.println("Debug point"); + } + + public static void main(String[] args) { + StaticNestedClassWrapper.StaticNestedClass simpleInnerClassObj = new StaticNestedClassWrapper.StaticNestedClass(); + System.out.println("Debug point"); + } +} diff --git a/core-java-perf/src/main/java/com/baeldung/memoryleaks/innerclass/InnerClassWrapper.java b/core-java-modules/core-java-perf/src/main/java/com/baeldung/memoryleaks/innerclass/InnerClassWrapper.java old mode 100755 new mode 100644 similarity index 95% rename from core-java-perf/src/main/java/com/baeldung/memoryleaks/innerclass/InnerClassWrapper.java rename to core-java-modules/core-java-perf/src/main/java/com/baeldung/memoryleaks/innerclass/InnerClassWrapper.java index 25fecf9bb3..97b05ea02e --- a/core-java-perf/src/main/java/com/baeldung/memoryleaks/innerclass/InnerClassWrapper.java +++ b/core-java-modules/core-java-perf/src/main/java/com/baeldung/memoryleaks/innerclass/InnerClassWrapper.java @@ -1,10 +1,10 @@ -package com.baeldung.memoryleaks.innerclass; - - -public class InnerClassWrapper { - private BulkyObject bulkyObject = new BulkyObject(); - - public class SimpleInnerClass { - - } -} +package com.baeldung.memoryleaks.innerclass; + + +public class InnerClassWrapper { + private BulkyObject bulkyObject = new BulkyObject(); + + public class SimpleInnerClass { + + } +} diff --git a/core-java-perf/src/main/java/com/baeldung/memoryleaks/innerclass/StaticNestedClassWrapper.java b/core-java-modules/core-java-perf/src/main/java/com/baeldung/memoryleaks/innerclass/StaticNestedClassWrapper.java old mode 100755 new mode 100644 similarity index 95% rename from core-java-perf/src/main/java/com/baeldung/memoryleaks/innerclass/StaticNestedClassWrapper.java rename to core-java-modules/core-java-perf/src/main/java/com/baeldung/memoryleaks/innerclass/StaticNestedClassWrapper.java index d1729d78a3..c37e08a049 --- a/core-java-perf/src/main/java/com/baeldung/memoryleaks/innerclass/StaticNestedClassWrapper.java +++ b/core-java-modules/core-java-perf/src/main/java/com/baeldung/memoryleaks/innerclass/StaticNestedClassWrapper.java @@ -1,10 +1,10 @@ -package com.baeldung.memoryleaks.innerclass; - - -public class StaticNestedClassWrapper { - private BulkyObject bulkyObject = new BulkyObject(); - - public static class StaticNestedClass { - - } -} +package com.baeldung.memoryleaks.innerclass; + + +public class StaticNestedClassWrapper { + private BulkyObject bulkyObject = new BulkyObject(); + + public static class StaticNestedClass { + + } +} diff --git a/core-java-perf/src/main/java/com/baeldung/memoryleaks/internedstrings/InternedString.java b/core-java-modules/core-java-perf/src/main/java/com/baeldung/memoryleaks/internedstrings/InternedString.java similarity index 100% rename from core-java-perf/src/main/java/com/baeldung/memoryleaks/internedstrings/InternedString.java rename to core-java-modules/core-java-perf/src/main/java/com/baeldung/memoryleaks/internedstrings/InternedString.java diff --git a/core-java-perf/src/main/java/com/baeldung/memoryleaks/internedstrings/ReadStringFromFileUtil.java b/core-java-modules/core-java-perf/src/main/java/com/baeldung/memoryleaks/internedstrings/ReadStringFromFileUtil.java similarity index 100% rename from core-java-perf/src/main/java/com/baeldung/memoryleaks/internedstrings/ReadStringFromFileUtil.java rename to core-java-modules/core-java-perf/src/main/java/com/baeldung/memoryleaks/internedstrings/ReadStringFromFileUtil.java diff --git a/core-java-perf/src/main/java/com/baeldung/memoryleaks/internedstrings/StringObject.java b/core-java-modules/core-java-perf/src/main/java/com/baeldung/memoryleaks/internedstrings/StringObject.java similarity index 100% rename from core-java-perf/src/main/java/com/baeldung/memoryleaks/internedstrings/StringObject.java rename to core-java-modules/core-java-perf/src/main/java/com/baeldung/memoryleaks/internedstrings/StringObject.java diff --git a/core-java-perf/src/main/java/com/baeldung/memoryleaks/staticfields/NonStaticFieldsDemo.java b/core-java-modules/core-java-perf/src/main/java/com/baeldung/memoryleaks/staticfields/NonStaticFieldsDemo.java similarity index 100% rename from core-java-perf/src/main/java/com/baeldung/memoryleaks/staticfields/NonStaticFieldsDemo.java rename to core-java-modules/core-java-perf/src/main/java/com/baeldung/memoryleaks/staticfields/NonStaticFieldsDemo.java diff --git a/core-java-perf/src/main/java/com/baeldung/memoryleaks/staticfields/StaticFieldsDemo.java b/core-java-modules/core-java-perf/src/main/java/com/baeldung/memoryleaks/staticfields/StaticFieldsDemo.java similarity index 100% rename from core-java-perf/src/main/java/com/baeldung/memoryleaks/staticfields/StaticFieldsDemo.java rename to core-java-modules/core-java-perf/src/main/java/com/baeldung/memoryleaks/staticfields/StaticFieldsDemo.java diff --git a/core-java-perf/src/main/java/com/baeldung/outofmemoryerror/OutOfMemoryGCLimitExceed.java b/core-java-modules/core-java-perf/src/main/java/com/baeldung/outofmemoryerror/OutOfMemoryGCLimitExceed.java similarity index 100% rename from core-java-perf/src/main/java/com/baeldung/outofmemoryerror/OutOfMemoryGCLimitExceed.java rename to core-java-modules/core-java-perf/src/main/java/com/baeldung/outofmemoryerror/OutOfMemoryGCLimitExceed.java diff --git a/core-java-perf/src/main/resources/logback.xml b/core-java-modules/core-java-perf/src/main/resources/logback.xml similarity index 100% rename from core-java-perf/src/main/resources/logback.xml rename to core-java-modules/core-java-perf/src/main/resources/logback.xml diff --git a/core-java-perf/src/test/java/com/baeldung/memoryleaks/equalshashcode/PersonMemoryLeakUnitTest.java b/core-java-modules/core-java-perf/src/test/java/com/baeldung/memoryleaks/equalshashcode/PersonMemoryLeakUnitTest.java similarity index 100% rename from core-java-perf/src/test/java/com/baeldung/memoryleaks/equalshashcode/PersonMemoryLeakUnitTest.java rename to core-java-modules/core-java-perf/src/test/java/com/baeldung/memoryleaks/equalshashcode/PersonMemoryLeakUnitTest.java diff --git a/core-java-perf/src/test/java/com/baeldung/memoryleaks/finalize/FinalizeMemoryLeakUnitTest.java b/core-java-modules/core-java-perf/src/test/java/com/baeldung/memoryleaks/finalize/FinalizeMemoryLeakUnitTest.java similarity index 100% rename from core-java-perf/src/test/java/com/baeldung/memoryleaks/finalize/FinalizeMemoryLeakUnitTest.java rename to core-java-modules/core-java-perf/src/test/java/com/baeldung/memoryleaks/finalize/FinalizeMemoryLeakUnitTest.java diff --git a/core-java-perf/src/test/java/com/baeldung/memoryleaks/innerclass/StaticInnerClassMemoryLeakUnitTest.java b/core-java-modules/core-java-perf/src/test/java/com/baeldung/memoryleaks/innerclass/StaticInnerClassMemoryLeakUnitTest.java similarity index 100% rename from core-java-perf/src/test/java/com/baeldung/memoryleaks/innerclass/StaticInnerClassMemoryLeakUnitTest.java rename to core-java-modules/core-java-perf/src/test/java/com/baeldung/memoryleaks/innerclass/StaticInnerClassMemoryLeakUnitTest.java diff --git a/core-java-perf/src/test/java/com/baeldung/memoryleaks/internedstrings/StringInternMemoryLeakUnitTest.java b/core-java-modules/core-java-perf/src/test/java/com/baeldung/memoryleaks/internedstrings/StringInternMemoryLeakUnitTest.java similarity index 100% rename from core-java-perf/src/test/java/com/baeldung/memoryleaks/internedstrings/StringInternMemoryLeakUnitTest.java rename to core-java-modules/core-java-perf/src/test/java/com/baeldung/memoryleaks/internedstrings/StringInternMemoryLeakUnitTest.java diff --git a/core-java-perf/src/test/java/com/baeldung/memoryleaks/staticfields/NonStaticFieldsMemoryLeakUnitTest.java b/core-java-modules/core-java-perf/src/test/java/com/baeldung/memoryleaks/staticfields/NonStaticFieldsMemoryLeakUnitTest.java similarity index 100% rename from core-java-perf/src/test/java/com/baeldung/memoryleaks/staticfields/NonStaticFieldsMemoryLeakUnitTest.java rename to core-java-modules/core-java-perf/src/test/java/com/baeldung/memoryleaks/staticfields/NonStaticFieldsMemoryLeakUnitTest.java diff --git a/core-java-perf/src/test/java/com/baeldung/memoryleaks/staticfields/StaticFieldsMemoryLeakUnitTest.java b/core-java-modules/core-java-perf/src/test/java/com/baeldung/memoryleaks/staticfields/StaticFieldsMemoryLeakUnitTest.java similarity index 100% rename from core-java-perf/src/test/java/com/baeldung/memoryleaks/staticfields/StaticFieldsMemoryLeakUnitTest.java rename to core-java-modules/core-java-perf/src/test/java/com/baeldung/memoryleaks/staticfields/StaticFieldsMemoryLeakUnitTest.java diff --git a/picocli/pom.xml b/core-java-modules/core-java-reflection/pom.xml similarity index 59% rename from picocli/pom.xml rename to core-java-modules/core-java-reflection/pom.xml index 0334f5463d..e6c7f81d6c 100644 --- a/picocli/pom.xml +++ b/core-java-modules/core-java-reflection/pom.xml @@ -3,26 +3,27 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 + core-java-reflection + 0.1.0-SNAPSHOT + core-java-reflection + jar + com.baeldung parent-java 0.0.1-SNAPSHOT - ../parent-java + ../../parent-java - picocli - - info.picocli - picocli - 3.9.6 - - - - org.springframework.boot - spring-boot-starter - 2.1.4.RELEASE + org.assertj + assertj-core + ${assertj-core.version} + + + 3.10.0 + \ No newline at end of file diff --git a/core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/voidtype/Action.java b/core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/voidtype/Action.java new file mode 100644 index 0000000000..1459bf25c5 --- /dev/null +++ b/core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/voidtype/Action.java @@ -0,0 +1,5 @@ +package com.baeldung.reflection.voidtype; + +public interface Action { + void execute(); +} diff --git a/core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/voidtype/Calculator.java b/core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/voidtype/Calculator.java new file mode 100644 index 0000000000..dcfbe72008 --- /dev/null +++ b/core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/voidtype/Calculator.java @@ -0,0 +1,21 @@ +package com.baeldung.reflection.voidtype; + +public class Calculator { + private int result = 0; + + public int add(int number) { + return result += number; + } + + public int sub(int number) { + return result -= number; + } + + public void clear() { + result = 0; + } + + public void print() { + System.out.println(result); + } +} diff --git a/core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/voidtype/Defer.java b/core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/voidtype/Defer.java new file mode 100644 index 0000000000..09817199fa --- /dev/null +++ b/core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/voidtype/Defer.java @@ -0,0 +1,27 @@ +package com.baeldung.reflection.voidtype; + +import java.util.concurrent.Callable; +import java.util.function.Consumer; +import java.util.function.Function; + +public class Defer { + public static V defer(Callable callable) throws Exception { + return callable.call(); + } + + public static void defer(Runnable runnable) { + runnable.run(); + } + + public static R defer(Function function, T arg) { + return function.apply(arg); + } + + public static void defer(Consumer consumer, T arg) { + consumer.accept(arg); + } + + public static void defer(Action action) { + action.execute(); + } +} diff --git a/core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/voidtype/MyOwnDefer.java b/core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/voidtype/MyOwnDefer.java new file mode 100644 index 0000000000..47468ee641 --- /dev/null +++ b/core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/voidtype/MyOwnDefer.java @@ -0,0 +1,15 @@ +package com.baeldung.reflection.voidtype; + +import java.util.concurrent.Callable; + +public class MyOwnDefer { + public static void defer(Runnable runnable) throws Exception { + Defer.defer(new Callable() { + @Override + public Void call() { + runnable.run(); + return null; + } + }); + } +} diff --git a/core-java-modules/core-java-reflection/src/test/java/com/baeldung/reflection/voidtype/CalculatorUnitTest.java b/core-java-modules/core-java-reflection/src/test/java/com/baeldung/reflection/voidtype/CalculatorUnitTest.java new file mode 100644 index 0000000000..0ba22bf6e3 --- /dev/null +++ b/core-java-modules/core-java-reflection/src/test/java/com/baeldung/reflection/voidtype/CalculatorUnitTest.java @@ -0,0 +1,23 @@ +package com.baeldung.reflection.voidtype; + +import org.junit.jupiter.api.Test; + +import java.lang.reflect.Method; +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + +import static org.assertj.core.api.Assertions.assertThat; + +class CalculatorUnitTest { + @Test + void givenCalculator_whenGettingVoidMethodsByReflection_thenOnlyClearAndPrint() { + Method[] calculatorMethods = Calculator.class.getDeclaredMethods(); + List calculatorVoidMethods = Arrays.stream(calculatorMethods) + .filter(method -> method.getReturnType().equals(Void.TYPE)) + .collect(Collectors.toList()); + + assertThat(calculatorVoidMethods) + .allMatch(method -> Arrays.asList("clear", "print").contains(method.getName())); + } +} \ No newline at end of file diff --git a/core-java-modules/core-java-reflection/src/test/java/com/baeldung/reflection/voidtype/DeferUnitTest.java b/core-java-modules/core-java-reflection/src/test/java/com/baeldung/reflection/voidtype/DeferUnitTest.java new file mode 100644 index 0000000000..e2dc68effc --- /dev/null +++ b/core-java-modules/core-java-reflection/src/test/java/com/baeldung/reflection/voidtype/DeferUnitTest.java @@ -0,0 +1,81 @@ +package com.baeldung.reflection.voidtype; + +import org.junit.jupiter.api.Test; + +import java.util.concurrent.Callable; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.function.Consumer; +import java.util.function.Function; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.Assertions.*; + +class DeferUnitTest { + @Test + void givenVoidCallable_whenDiffer_thenReturnNull() throws Exception { + Callable callable = new Callable() { + @Override + public Void call() { + System.out.println("Hello!"); + return null; + } + }; + + assertThat(Defer.defer(callable)).isNull(); + } + + @Test + void givenVoidRunnable_whenDiffer_thenNoReturn() { + AtomicBoolean run = new AtomicBoolean(false); + + Runnable runnable = new Runnable() { + @Override + public void run() { + System.out.println("Hello!"); + run.set(true); + } + }; + + Defer.defer(runnable); + + assertTrue(run.get()); + } + + @Test + void givenVoidFunction_whenDiffer_thenReturnNull() { + Function function = s -> { + System.out.println("Hello " + s + "!"); + return null; + }; + + assertThat(Defer.defer(function, "World")).isNull(); + } + + @Test + void givenVoidConsumer_whenDiffer_thenReturnNull() { + AtomicBoolean run = new AtomicBoolean(false); + + Consumer function = s -> { + System.out.println("Hello " + s + "!"); + run.set(true); + }; + + Defer.defer(function, "World"); + + assertTrue(run.get()); + } + + @Test + void givenAction_whenDiffer_thenNoReturn() { + AtomicBoolean run = new AtomicBoolean(false); + + Action action = () -> { + System.out.println("Hello!"); + run.set(true); + }; + + Defer.defer(action); + + assertTrue(run.get()); + } +} \ No newline at end of file diff --git a/core-java-modules/core-java-reflection/src/test/java/com/baeldung/reflection/voidtype/MyOwnDeferUnitTest.java b/core-java-modules/core-java-reflection/src/test/java/com/baeldung/reflection/voidtype/MyOwnDeferUnitTest.java new file mode 100644 index 0000000000..e3c3612a22 --- /dev/null +++ b/core-java-modules/core-java-reflection/src/test/java/com/baeldung/reflection/voidtype/MyOwnDeferUnitTest.java @@ -0,0 +1,22 @@ +package com.baeldung.reflection.voidtype; + +import org.junit.jupiter.api.Test; + +import java.util.concurrent.atomic.AtomicBoolean; + +import static org.junit.jupiter.api.Assertions.*; + +class MyOwnDeferUnitTest { + @Test + void defer() throws Exception { + AtomicBoolean run = new AtomicBoolean(false); + Runnable runnable = () -> { + System.out.println("Hello!"); + run.set(true); + }; + + MyOwnDefer.defer(runnable); + + assertTrue(run.get()); + } +} \ No newline at end of file diff --git a/core-java-security/README.md b/core-java-modules/core-java-security/README.md similarity index 100% rename from core-java-security/README.md rename to core-java-modules/core-java-security/README.md diff --git a/core-java-security/pom.xml b/core-java-modules/core-java-security/pom.xml similarity index 97% rename from core-java-security/pom.xml rename to core-java-modules/core-java-security/pom.xml index 63bc46b114..ed82a5209a 100644 --- a/core-java-security/pom.xml +++ b/core-java-modules/core-java-security/pom.xml @@ -11,7 +11,7 @@ com.baeldung parent-java 0.0.1-SNAPSHOT - ../parent-java + ../../parent-java diff --git a/core-java-security/src/main/java/com/baeldung/cipher/Encryptor.java b/core-java-modules/core-java-security/src/main/java/com/baeldung/cipher/Encryptor.java similarity index 100% rename from core-java-security/src/main/java/com/baeldung/cipher/Encryptor.java rename to core-java-modules/core-java-security/src/main/java/com/baeldung/cipher/Encryptor.java diff --git a/core-java-security/src/main/java/com/baeldung/encrypt/FileEncrypterDecrypter.java b/core-java-modules/core-java-security/src/main/java/com/baeldung/encrypt/FileEncrypterDecrypter.java similarity index 100% rename from core-java-security/src/main/java/com/baeldung/encrypt/FileEncrypterDecrypter.java rename to core-java-modules/core-java-security/src/main/java/com/baeldung/encrypt/FileEncrypterDecrypter.java diff --git a/core-java-security/src/main/java/com/baeldung/hashing/DigestAlgorithms.java b/core-java-modules/core-java-security/src/main/java/com/baeldung/hashing/DigestAlgorithms.java similarity index 100% rename from core-java-security/src/main/java/com/baeldung/hashing/DigestAlgorithms.java rename to core-java-modules/core-java-security/src/main/java/com/baeldung/hashing/DigestAlgorithms.java diff --git a/core-java-security/src/main/java/com/baeldung/hashing/Keccak256Hashing.java b/core-java-modules/core-java-security/src/main/java/com/baeldung/hashing/Keccak256Hashing.java similarity index 100% rename from core-java-security/src/main/java/com/baeldung/hashing/Keccak256Hashing.java rename to core-java-modules/core-java-security/src/main/java/com/baeldung/hashing/Keccak256Hashing.java diff --git a/core-java-security/src/main/java/com/baeldung/hashing/SHA256Hashing.java b/core-java-modules/core-java-security/src/main/java/com/baeldung/hashing/SHA256Hashing.java similarity index 100% rename from core-java-security/src/main/java/com/baeldung/hashing/SHA256Hashing.java rename to core-java-modules/core-java-security/src/main/java/com/baeldung/hashing/SHA256Hashing.java diff --git a/core-java-security/src/main/java/com/baeldung/hashing/SHA3Hashing.java b/core-java-modules/core-java-security/src/main/java/com/baeldung/hashing/SHA3Hashing.java similarity index 100% rename from core-java-security/src/main/java/com/baeldung/hashing/SHA3Hashing.java rename to core-java-modules/core-java-security/src/main/java/com/baeldung/hashing/SHA3Hashing.java diff --git a/core-java-security/src/main/java/com/baeldung/hashing/SHACommonUtils.java b/core-java-modules/core-java-security/src/main/java/com/baeldung/hashing/SHACommonUtils.java similarity index 100% rename from core-java-security/src/main/java/com/baeldung/hashing/SHACommonUtils.java rename to core-java-modules/core-java-security/src/main/java/com/baeldung/hashing/SHACommonUtils.java diff --git a/core-java-security/src/main/java/com/baeldung/keystore/JavaKeyStore.java b/core-java-modules/core-java-security/src/main/java/com/baeldung/keystore/JavaKeyStore.java similarity index 100% rename from core-java-security/src/main/java/com/baeldung/keystore/JavaKeyStore.java rename to core-java-modules/core-java-security/src/main/java/com/baeldung/keystore/JavaKeyStore.java diff --git a/core-java-security/src/main/java/com/baeldung/passwordhashing/PBKDF2Hasher.java b/core-java-modules/core-java-security/src/main/java/com/baeldung/passwordhashing/PBKDF2Hasher.java similarity index 100% rename from core-java-security/src/main/java/com/baeldung/passwordhashing/PBKDF2Hasher.java rename to core-java-modules/core-java-security/src/main/java/com/baeldung/passwordhashing/PBKDF2Hasher.java diff --git a/core-java-security/src/main/java/com/baeldung/passwordhashing/SHA512Hasher.java b/core-java-modules/core-java-security/src/main/java/com/baeldung/passwordhashing/SHA512Hasher.java similarity index 100% rename from core-java-security/src/main/java/com/baeldung/passwordhashing/SHA512Hasher.java rename to core-java-modules/core-java-security/src/main/java/com/baeldung/passwordhashing/SHA512Hasher.java diff --git a/core-java-security/src/main/java/com/baeldung/passwordhashing/SimplePBKDF2Hasher.java b/core-java-modules/core-java-security/src/main/java/com/baeldung/passwordhashing/SimplePBKDF2Hasher.java similarity index 100% rename from core-java-security/src/main/java/com/baeldung/passwordhashing/SimplePBKDF2Hasher.java rename to core-java-modules/core-java-security/src/main/java/com/baeldung/passwordhashing/SimplePBKDF2Hasher.java diff --git a/core-java-security/src/main/java/com/baeldung/ssl/EnableTLSv12.java b/core-java-modules/core-java-security/src/main/java/com/baeldung/ssl/EnableTLSv12.java similarity index 100% rename from core-java-security/src/main/java/com/baeldung/ssl/EnableTLSv12.java rename to core-java-modules/core-java-security/src/main/java/com/baeldung/ssl/EnableTLSv12.java diff --git a/core-java-security/src/main/java/com/baeldung/ssl/SecureConnection.java b/core-java-modules/core-java-security/src/main/java/com/baeldung/ssl/SecureConnection.java similarity index 100% rename from core-java-security/src/main/java/com/baeldung/ssl/SecureConnection.java rename to core-java-modules/core-java-security/src/main/java/com/baeldung/ssl/SecureConnection.java diff --git a/core-java-security/src/main/java/com/baeldung/ssl/example/SimpleClient.java b/core-java-modules/core-java-security/src/main/java/com/baeldung/ssl/example/SimpleClient.java similarity index 100% rename from core-java-security/src/main/java/com/baeldung/ssl/example/SimpleClient.java rename to core-java-modules/core-java-security/src/main/java/com/baeldung/ssl/example/SimpleClient.java diff --git a/core-java-security/src/main/java/com/baeldung/ssl/example/SimpleServer.java b/core-java-modules/core-java-security/src/main/java/com/baeldung/ssl/example/SimpleServer.java similarity index 100% rename from core-java-security/src/main/java/com/baeldung/ssl/example/SimpleServer.java rename to core-java-modules/core-java-security/src/main/java/com/baeldung/ssl/example/SimpleServer.java diff --git a/core-java-security/src/main/resources/logback.xml b/core-java-modules/core-java-security/src/main/resources/logback.xml similarity index 100% rename from core-java-security/src/main/resources/logback.xml rename to core-java-modules/core-java-security/src/main/resources/logback.xml diff --git a/core-java-security/src/test/java/com/baeldung/cipher/EncryptorUnitTest.java b/core-java-modules/core-java-security/src/test/java/com/baeldung/cipher/EncryptorUnitTest.java similarity index 100% rename from core-java-security/src/test/java/com/baeldung/cipher/EncryptorUnitTest.java rename to core-java-modules/core-java-security/src/test/java/com/baeldung/cipher/EncryptorUnitTest.java diff --git a/core-java-security/src/test/java/com/baeldung/encrypt/FileEncrypterDecrypterIntegrationTest.java b/core-java-modules/core-java-security/src/test/java/com/baeldung/encrypt/FileEncrypterDecrypterIntegrationTest.java similarity index 100% rename from core-java-security/src/test/java/com/baeldung/encrypt/FileEncrypterDecrypterIntegrationTest.java rename to core-java-modules/core-java-security/src/test/java/com/baeldung/encrypt/FileEncrypterDecrypterIntegrationTest.java diff --git a/core-java-security/src/test/java/com/baeldung/hashing/Keccak256HashingUnitTest.java b/core-java-modules/core-java-security/src/test/java/com/baeldung/hashing/Keccak256HashingUnitTest.java similarity index 100% rename from core-java-security/src/test/java/com/baeldung/hashing/Keccak256HashingUnitTest.java rename to core-java-modules/core-java-security/src/test/java/com/baeldung/hashing/Keccak256HashingUnitTest.java diff --git a/core-java-security/src/test/java/com/baeldung/hashing/SHA256HashingUnitTest.java b/core-java-modules/core-java-security/src/test/java/com/baeldung/hashing/SHA256HashingUnitTest.java similarity index 100% rename from core-java-security/src/test/java/com/baeldung/hashing/SHA256HashingUnitTest.java rename to core-java-modules/core-java-security/src/test/java/com/baeldung/hashing/SHA256HashingUnitTest.java diff --git a/core-java-security/src/test/java/com/baeldung/hashing/SHA3HashingUnitTest.java b/core-java-modules/core-java-security/src/test/java/com/baeldung/hashing/SHA3HashingUnitTest.java similarity index 100% rename from core-java-security/src/test/java/com/baeldung/hashing/SHA3HashingUnitTest.java rename to core-java-modules/core-java-security/src/test/java/com/baeldung/hashing/SHA3HashingUnitTest.java diff --git a/core-java-security/src/test/java/com/baeldung/keystore/JavaKeyStoreUnitTest.java b/core-java-modules/core-java-security/src/test/java/com/baeldung/keystore/JavaKeyStoreUnitTest.java similarity index 100% rename from core-java-security/src/test/java/com/baeldung/keystore/JavaKeyStoreUnitTest.java rename to core-java-modules/core-java-security/src/test/java/com/baeldung/keystore/JavaKeyStoreUnitTest.java diff --git a/core-java-security/src/test/java/com/baeldung/passwordhashing/PBKDF2HasherUnitTest.java b/core-java-modules/core-java-security/src/test/java/com/baeldung/passwordhashing/PBKDF2HasherUnitTest.java similarity index 100% rename from core-java-security/src/test/java/com/baeldung/passwordhashing/PBKDF2HasherUnitTest.java rename to core-java-modules/core-java-security/src/test/java/com/baeldung/passwordhashing/PBKDF2HasherUnitTest.java diff --git a/core-java-security/src/test/java/com/baeldung/passwordhashing/SHA512HasherUnitTest.java b/core-java-modules/core-java-security/src/test/java/com/baeldung/passwordhashing/SHA512HasherUnitTest.java similarity index 100% rename from core-java-security/src/test/java/com/baeldung/passwordhashing/SHA512HasherUnitTest.java rename to core-java-modules/core-java-security/src/test/java/com/baeldung/passwordhashing/SHA512HasherUnitTest.java diff --git a/core-java-security/src/test/java/org/baeldung/java/md5/JavaMD5UnitTest.java b/core-java-modules/core-java-security/src/test/java/org/baeldung/java/md5/JavaMD5UnitTest.java similarity index 100% rename from core-java-security/src/test/java/org/baeldung/java/md5/JavaMD5UnitTest.java rename to core-java-modules/core-java-security/src/test/java/org/baeldung/java/md5/JavaMD5UnitTest.java diff --git a/core-java-security/src/test/resources/test_md5.txt b/core-java-modules/core-java-security/src/test/resources/test_md5.txt similarity index 100% rename from core-java-security/src/test/resources/test_md5.txt rename to core-java-modules/core-java-security/src/test/resources/test_md5.txt diff --git a/core-java-sun/.gitignore b/core-java-modules/core-java-sun/.gitignore similarity index 100% rename from core-java-sun/.gitignore rename to core-java-modules/core-java-sun/.gitignore diff --git a/core-java-sun/README.md b/core-java-modules/core-java-sun/README.md similarity index 100% rename from core-java-sun/README.md rename to core-java-modules/core-java-sun/README.md diff --git a/core-java-sun/pom.xml b/core-java-modules/core-java-sun/pom.xml similarity index 99% rename from core-java-sun/pom.xml rename to core-java-modules/core-java-sun/pom.xml index 5f2065016f..da27564d96 100644 --- a/core-java-sun/pom.xml +++ b/core-java-modules/core-java-sun/pom.xml @@ -11,7 +11,7 @@ com.baeldung parent-java 0.0.1-SNAPSHOT - ../parent-java + ../../parent-java diff --git a/core-java-sun/src/main/java/com/baeldung/.gitignore b/core-java-modules/core-java-sun/src/main/java/com/baeldung/.gitignore similarity index 100% rename from core-java-sun/src/main/java/com/baeldung/.gitignore rename to core-java-modules/core-java-sun/src/main/java/com/baeldung/.gitignore diff --git a/core-java-sun/src/main/java/com/baeldung/README.md b/core-java-modules/core-java-sun/src/main/java/com/baeldung/README.md similarity index 100% rename from core-java-sun/src/main/java/com/baeldung/README.md rename to core-java-modules/core-java-sun/src/main/java/com/baeldung/README.md diff --git a/core-java-sun/src/main/java/com/baeldung/javac/Positive.java b/core-java-modules/core-java-sun/src/main/java/com/baeldung/javac/Positive.java similarity index 100% rename from core-java-sun/src/main/java/com/baeldung/javac/Positive.java rename to core-java-modules/core-java-sun/src/main/java/com/baeldung/javac/Positive.java diff --git a/core-java-sun/src/main/java/com/baeldung/javac/SampleJavacPlugin.java b/core-java-modules/core-java-sun/src/main/java/com/baeldung/javac/SampleJavacPlugin.java similarity index 100% rename from core-java-sun/src/main/java/com/baeldung/javac/SampleJavacPlugin.java rename to core-java-modules/core-java-sun/src/main/java/com/baeldung/javac/SampleJavacPlugin.java diff --git a/core-java-sun/src/main/resources/META-INF/services/com.sun.source.util.Plugin b/core-java-modules/core-java-sun/src/main/resources/META-INF/services/com.sun.source.util.Plugin similarity index 100% rename from core-java-sun/src/main/resources/META-INF/services/com.sun.source.util.Plugin rename to core-java-modules/core-java-sun/src/main/resources/META-INF/services/com.sun.source.util.Plugin diff --git a/core-java-sun/src/main/resources/log4j.properties b/core-java-modules/core-java-sun/src/main/resources/log4j.properties similarity index 100% rename from core-java-sun/src/main/resources/log4j.properties rename to core-java-modules/core-java-sun/src/main/resources/log4j.properties diff --git a/core-java-sun/src/main/resources/logback.xml b/core-java-modules/core-java-sun/src/main/resources/logback.xml similarity index 100% rename from core-java-sun/src/main/resources/logback.xml rename to core-java-modules/core-java-sun/src/main/resources/logback.xml diff --git a/core-java-sun/src/test/java/com/baeldung/javac/SampleJavacPluginIntegrationTest.java b/core-java-modules/core-java-sun/src/test/java/com/baeldung/javac/SampleJavacPluginIntegrationTest.java similarity index 100% rename from core-java-sun/src/test/java/com/baeldung/javac/SampleJavacPluginIntegrationTest.java rename to core-java-modules/core-java-sun/src/test/java/com/baeldung/javac/SampleJavacPluginIntegrationTest.java diff --git a/core-java-sun/src/test/java/com/baeldung/javac/SimpleClassFile.java b/core-java-modules/core-java-sun/src/test/java/com/baeldung/javac/SimpleClassFile.java similarity index 100% rename from core-java-sun/src/test/java/com/baeldung/javac/SimpleClassFile.java rename to core-java-modules/core-java-sun/src/test/java/com/baeldung/javac/SimpleClassFile.java diff --git a/core-java-sun/src/test/java/com/baeldung/javac/SimpleFileManager.java b/core-java-modules/core-java-sun/src/test/java/com/baeldung/javac/SimpleFileManager.java similarity index 100% rename from core-java-sun/src/test/java/com/baeldung/javac/SimpleFileManager.java rename to core-java-modules/core-java-sun/src/test/java/com/baeldung/javac/SimpleFileManager.java diff --git a/core-java-sun/src/test/java/com/baeldung/javac/SimpleSourceFile.java b/core-java-modules/core-java-sun/src/test/java/com/baeldung/javac/SimpleSourceFile.java similarity index 100% rename from core-java-sun/src/test/java/com/baeldung/javac/SimpleSourceFile.java rename to core-java-modules/core-java-sun/src/test/java/com/baeldung/javac/SimpleSourceFile.java diff --git a/core-java-sun/src/test/java/com/baeldung/javac/TestCompiler.java b/core-java-modules/core-java-sun/src/test/java/com/baeldung/javac/TestCompiler.java similarity index 100% rename from core-java-sun/src/test/java/com/baeldung/javac/TestCompiler.java rename to core-java-modules/core-java-sun/src/test/java/com/baeldung/javac/TestCompiler.java diff --git a/core-java-sun/src/test/java/com/baeldung/javac/TestRunner.java b/core-java-modules/core-java-sun/src/test/java/com/baeldung/javac/TestRunner.java similarity index 100% rename from core-java-sun/src/test/java/com/baeldung/javac/TestRunner.java rename to core-java-modules/core-java-sun/src/test/java/com/baeldung/javac/TestRunner.java diff --git a/core-java-sun/src/test/java/com/baeldung/unsafe/CASCounter.java b/core-java-modules/core-java-sun/src/test/java/com/baeldung/unsafe/CASCounter.java similarity index 100% rename from core-java-sun/src/test/java/com/baeldung/unsafe/CASCounter.java rename to core-java-modules/core-java-sun/src/test/java/com/baeldung/unsafe/CASCounter.java diff --git a/core-java-sun/src/test/java/com/baeldung/unsafe/OffHeapArray.java b/core-java-modules/core-java-sun/src/test/java/com/baeldung/unsafe/OffHeapArray.java similarity index 100% rename from core-java-sun/src/test/java/com/baeldung/unsafe/OffHeapArray.java rename to core-java-modules/core-java-sun/src/test/java/com/baeldung/unsafe/OffHeapArray.java diff --git a/core-java-sun/src/test/java/com/baeldung/unsafe/UnsafeUnitTest.java b/core-java-modules/core-java-sun/src/test/java/com/baeldung/unsafe/UnsafeUnitTest.java similarity index 100% rename from core-java-sun/src/test/java/com/baeldung/unsafe/UnsafeUnitTest.java rename to core-java-modules/core-java-sun/src/test/java/com/baeldung/unsafe/UnsafeUnitTest.java diff --git a/core-java-sun/src/test/resources/.gitignore b/core-java-modules/core-java-sun/src/test/resources/.gitignore similarity index 100% rename from core-java-sun/src/test/resources/.gitignore rename to core-java-modules/core-java-sun/src/test/resources/.gitignore diff --git a/core-java-modules/core-java/.gitignore b/core-java-modules/core-java/.gitignore new file mode 100644 index 0000000000..374c8bf907 --- /dev/null +++ b/core-java-modules/core-java/.gitignore @@ -0,0 +1,25 @@ +*.class + +0.* + +#folders# +/target +/neoDb* +/data +/src/main/webapp/WEB-INF/classes +*/META-INF/* +.resourceCache + +# Packaged files # +*.jar +*.war +*.ear + +# Files generated by integration tests +backup-pom.xml +/bin/ +/temp + +#IntelliJ specific +.idea/ +*.iml \ No newline at end of file diff --git a/core-java/README.md b/core-java-modules/core-java/README.md similarity index 100% rename from core-java/README.md rename to core-java-modules/core-java/README.md diff --git a/core-java/customers.xml b/core-java-modules/core-java/customers.xml similarity index 100% rename from core-java/customers.xml rename to core-java-modules/core-java/customers.xml diff --git a/core-java/externalizable.txt b/core-java-modules/core-java/externalizable.txt similarity index 100% rename from core-java/externalizable.txt rename to core-java-modules/core-java/externalizable.txt diff --git a/core-java/pom.xml b/core-java-modules/core-java/pom.xml similarity index 99% rename from core-java/pom.xml rename to core-java-modules/core-java/pom.xml index 463b65a4ce..7942f3e7e2 100644 --- a/core-java/pom.xml +++ b/core-java-modules/core-java/pom.xml @@ -10,7 +10,7 @@ com.baeldung parent-java 0.0.1-SNAPSHOT - ../parent-java + ../../parent-java @@ -454,7 +454,7 @@ 2.8.2 - 3.5 + 3.9 2.5 3.6.1 1.0.3 diff --git a/core-java/src/main/java/com/baeldung/.gitignore b/core-java-modules/core-java/src/main/java/com/baeldung/.gitignore similarity index 100% rename from core-java/src/main/java/com/baeldung/.gitignore rename to core-java-modules/core-java/src/main/java/com/baeldung/.gitignore diff --git a/core-java/src/main/java/com/baeldung/README.md b/core-java-modules/core-java/src/main/java/com/baeldung/README.md similarity index 100% rename from core-java/src/main/java/com/baeldung/README.md rename to core-java-modules/core-java/src/main/java/com/baeldung/README.md diff --git a/core-java/src/main/java/com/baeldung/abstractclasses/application/Application.java b/core-java-modules/core-java/src/main/java/com/baeldung/abstractclasses/application/Application.java similarity index 97% rename from core-java/src/main/java/com/baeldung/abstractclasses/application/Application.java rename to core-java-modules/core-java/src/main/java/com/baeldung/abstractclasses/application/Application.java index 3180762227..5b250635ea 100644 --- a/core-java/src/main/java/com/baeldung/abstractclasses/application/Application.java +++ b/core-java-modules/core-java/src/main/java/com/baeldung/abstractclasses/application/Application.java @@ -1,29 +1,29 @@ -package com.baeldung.abstractclasses.application; - -import com.baeldung.abstractclasses.filereaders.BaseFileReader; -import com.baeldung.abstractclasses.filereaders.LowercaseFileReader; -import com.baeldung.abstractclasses.filereaders.UppercaseFileReader; -import java.io.IOException; -import java.net.URISyntaxException; -import java.nio.file.Path; -import java.nio.file.Paths; - -public class Application { - - public static void main(String[] args) throws IOException, URISyntaxException { - - Application application = new Application(); - Path path = application.getPathFromResourcesFile("files/test.txt"); - BaseFileReader lowercaseFileReader = new LowercaseFileReader(path); - lowercaseFileReader.readFile().forEach(line -> System.out.println(line)); - - BaseFileReader uppercaseFileReader = new UppercaseFileReader(path); - uppercaseFileReader.readFile().forEach(line -> System.out.println(line)); - - } - - private Path getPathFromResourcesFile(String filePath) throws URISyntaxException { - return Paths.get(getClass().getClassLoader().getResource(filePath).toURI()); - - } -} +package com.baeldung.abstractclasses.application; + +import com.baeldung.abstractclasses.filereaders.BaseFileReader; +import com.baeldung.abstractclasses.filereaders.LowercaseFileReader; +import com.baeldung.abstractclasses.filereaders.UppercaseFileReader; +import java.io.IOException; +import java.net.URISyntaxException; +import java.nio.file.Path; +import java.nio.file.Paths; + +public class Application { + + public static void main(String[] args) throws IOException, URISyntaxException { + + Application application = new Application(); + Path path = application.getPathFromResourcesFile("files/test.txt"); + BaseFileReader lowercaseFileReader = new LowercaseFileReader(path); + lowercaseFileReader.readFile().forEach(line -> System.out.println(line)); + + BaseFileReader uppercaseFileReader = new UppercaseFileReader(path); + uppercaseFileReader.readFile().forEach(line -> System.out.println(line)); + + } + + private Path getPathFromResourcesFile(String filePath) throws URISyntaxException { + return Paths.get(getClass().getClassLoader().getResource(filePath).toURI()); + + } +} diff --git a/core-java/src/main/java/com/baeldung/abstractclasses/filereaders/BaseFileReader.java b/core-java-modules/core-java/src/main/java/com/baeldung/abstractclasses/filereaders/BaseFileReader.java similarity index 96% rename from core-java/src/main/java/com/baeldung/abstractclasses/filereaders/BaseFileReader.java rename to core-java-modules/core-java/src/main/java/com/baeldung/abstractclasses/filereaders/BaseFileReader.java index 97452a9eca..376147aa13 100644 --- a/core-java/src/main/java/com/baeldung/abstractclasses/filereaders/BaseFileReader.java +++ b/core-java-modules/core-java/src/main/java/com/baeldung/abstractclasses/filereaders/BaseFileReader.java @@ -1,27 +1,27 @@ -package com.baeldung.abstractclasses.filereaders; - -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Path; -import java.util.List; -import java.util.stream.Collectors; - -public abstract class BaseFileReader { - - protected Path filePath; - - protected BaseFileReader(Path filePath) { - this.filePath = filePath; - } - - public Path getFilePath() { - return filePath; - } - - public List readFile() throws IOException { - return Files.lines(filePath) - .map(this::mapFileLine).collect(Collectors.toList()); - } - - protected abstract String mapFileLine(String line); -} +package com.baeldung.abstractclasses.filereaders; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.List; +import java.util.stream.Collectors; + +public abstract class BaseFileReader { + + protected Path filePath; + + protected BaseFileReader(Path filePath) { + this.filePath = filePath; + } + + public Path getFilePath() { + return filePath; + } + + public List readFile() throws IOException { + return Files.lines(filePath) + .map(this::mapFileLine).collect(Collectors.toList()); + } + + protected abstract String mapFileLine(String line); +} diff --git a/core-java/src/main/java/com/baeldung/abstractclasses/filereaders/LowercaseFileReader.java b/core-java-modules/core-java/src/main/java/com/baeldung/abstractclasses/filereaders/LowercaseFileReader.java similarity index 95% rename from core-java/src/main/java/com/baeldung/abstractclasses/filereaders/LowercaseFileReader.java rename to core-java-modules/core-java/src/main/java/com/baeldung/abstractclasses/filereaders/LowercaseFileReader.java index 53820d393c..33a3e098a0 100644 --- a/core-java/src/main/java/com/baeldung/abstractclasses/filereaders/LowercaseFileReader.java +++ b/core-java-modules/core-java/src/main/java/com/baeldung/abstractclasses/filereaders/LowercaseFileReader.java @@ -1,15 +1,15 @@ -package com.baeldung.abstractclasses.filereaders; - -import java.nio.file.Path; - -public class LowercaseFileReader extends BaseFileReader { - - public LowercaseFileReader(Path filePath) { - super(filePath); - } - - @Override - public String mapFileLine(String line) { - return line.toLowerCase(); - } -} +package com.baeldung.abstractclasses.filereaders; + +import java.nio.file.Path; + +public class LowercaseFileReader extends BaseFileReader { + + public LowercaseFileReader(Path filePath) { + super(filePath); + } + + @Override + public String mapFileLine(String line) { + return line.toLowerCase(); + } +} diff --git a/core-java/src/main/java/com/baeldung/abstractclasses/filereaders/UppercaseFileReader.java b/core-java-modules/core-java/src/main/java/com/baeldung/abstractclasses/filereaders/UppercaseFileReader.java similarity index 95% rename from core-java/src/main/java/com/baeldung/abstractclasses/filereaders/UppercaseFileReader.java rename to core-java-modules/core-java/src/main/java/com/baeldung/abstractclasses/filereaders/UppercaseFileReader.java index 3144a4f27f..4c93e75df7 100644 --- a/core-java/src/main/java/com/baeldung/abstractclasses/filereaders/UppercaseFileReader.java +++ b/core-java-modules/core-java/src/main/java/com/baeldung/abstractclasses/filereaders/UppercaseFileReader.java @@ -1,15 +1,15 @@ -package com.baeldung.abstractclasses.filereaders; - -import java.nio.file.Path; - -public class UppercaseFileReader extends BaseFileReader { - - public UppercaseFileReader(Path filePath) { - super(filePath); - } - - @Override - public String mapFileLine(String line) { - return line.toUpperCase(); - } -} +package com.baeldung.abstractclasses.filereaders; + +import java.nio.file.Path; + +public class UppercaseFileReader extends BaseFileReader { + + public UppercaseFileReader(Path filePath) { + super(filePath); + } + + @Override + public String mapFileLine(String line) { + return line.toUpperCase(); + } +} diff --git a/core-java/src/main/java/com/baeldung/asciiart/AsciiArt.java b/core-java-modules/core-java/src/main/java/com/baeldung/asciiart/AsciiArt.java similarity index 100% rename from core-java/src/main/java/com/baeldung/asciiart/AsciiArt.java rename to core-java-modules/core-java/src/main/java/com/baeldung/asciiart/AsciiArt.java diff --git a/core-java/src/main/java/com/baeldung/basicsyntax/SimpleAddition.java b/core-java-modules/core-java/src/main/java/com/baeldung/basicsyntax/SimpleAddition.java similarity index 100% rename from core-java/src/main/java/com/baeldung/basicsyntax/SimpleAddition.java rename to core-java-modules/core-java/src/main/java/com/baeldung/basicsyntax/SimpleAddition.java diff --git a/core-java/src/main/java/com/baeldung/classloader/CustomClassLoader.java b/core-java-modules/core-java/src/main/java/com/baeldung/classloader/CustomClassLoader.java similarity index 100% rename from core-java/src/main/java/com/baeldung/classloader/CustomClassLoader.java rename to core-java-modules/core-java/src/main/java/com/baeldung/classloader/CustomClassLoader.java diff --git a/core-java/src/main/java/com/baeldung/classloader/PrintClassLoader.java b/core-java-modules/core-java/src/main/java/com/baeldung/classloader/PrintClassLoader.java similarity index 100% rename from core-java/src/main/java/com/baeldung/classloader/PrintClassLoader.java rename to core-java-modules/core-java/src/main/java/com/baeldung/classloader/PrintClassLoader.java diff --git a/core-java/src/main/java/com/baeldung/console/ConsoleConsoleClass.java b/core-java-modules/core-java/src/main/java/com/baeldung/console/ConsoleConsoleClass.java similarity index 100% rename from core-java/src/main/java/com/baeldung/console/ConsoleConsoleClass.java rename to core-java-modules/core-java/src/main/java/com/baeldung/console/ConsoleConsoleClass.java diff --git a/core-java/src/main/java/com/baeldung/console/ConsoleScannerClass.java b/core-java-modules/core-java/src/main/java/com/baeldung/console/ConsoleScannerClass.java similarity index 100% rename from core-java/src/main/java/com/baeldung/console/ConsoleScannerClass.java rename to core-java-modules/core-java/src/main/java/com/baeldung/console/ConsoleScannerClass.java diff --git a/core-java/src/main/java/com/baeldung/curltojava/JavaCurlExamples.java b/core-java-modules/core-java/src/main/java/com/baeldung/curltojava/JavaCurlExamples.java similarity index 100% rename from core-java/src/main/java/com/baeldung/curltojava/JavaCurlExamples.java rename to core-java-modules/core-java/src/main/java/com/baeldung/curltojava/JavaCurlExamples.java diff --git a/core-java/src/main/java/com/baeldung/deserialization/AppleProduct.java b/core-java-modules/core-java/src/main/java/com/baeldung/deserialization/AppleProduct.java similarity index 100% rename from core-java/src/main/java/com/baeldung/deserialization/AppleProduct.java rename to core-java-modules/core-java/src/main/java/com/baeldung/deserialization/AppleProduct.java diff --git a/core-java/src/main/java/com/baeldung/deserialization/DeserializationUtility.java b/core-java-modules/core-java/src/main/java/com/baeldung/deserialization/DeserializationUtility.java similarity index 100% rename from core-java/src/main/java/com/baeldung/deserialization/DeserializationUtility.java rename to core-java-modules/core-java/src/main/java/com/baeldung/deserialization/DeserializationUtility.java diff --git a/core-java/src/main/java/com/baeldung/deserialization/SerializationUtility.java b/core-java-modules/core-java/src/main/java/com/baeldung/deserialization/SerializationUtility.java similarity index 100% rename from core-java/src/main/java/com/baeldung/deserialization/SerializationUtility.java rename to core-java-modules/core-java/src/main/java/com/baeldung/deserialization/SerializationUtility.java diff --git a/core-java/src/main/java/com/baeldung/encoding/CharacterEncodingExamples.java b/core-java-modules/core-java/src/main/java/com/baeldung/encoding/CharacterEncodingExamples.java similarity index 100% rename from core-java/src/main/java/com/baeldung/encoding/CharacterEncodingExamples.java rename to core-java-modules/core-java/src/main/java/com/baeldung/encoding/CharacterEncodingExamples.java diff --git a/core-java/src/main/java/com/baeldung/exceptions/Arithmetic.java b/core-java-modules/core-java/src/main/java/com/baeldung/exceptions/Arithmetic.java similarity index 100% rename from core-java/src/main/java/com/baeldung/exceptions/Arithmetic.java rename to core-java-modules/core-java/src/main/java/com/baeldung/exceptions/Arithmetic.java diff --git a/core-java/src/main/java/com/baeldung/exceptions/ArrayIndexOutOfBounds.java b/core-java-modules/core-java/src/main/java/com/baeldung/exceptions/ArrayIndexOutOfBounds.java similarity index 100% rename from core-java/src/main/java/com/baeldung/exceptions/ArrayIndexOutOfBounds.java rename to core-java-modules/core-java/src/main/java/com/baeldung/exceptions/ArrayIndexOutOfBounds.java diff --git a/core-java/src/main/java/com/baeldung/exceptions/ClassCast.java b/core-java-modules/core-java/src/main/java/com/baeldung/exceptions/ClassCast.java similarity index 100% rename from core-java/src/main/java/com/baeldung/exceptions/ClassCast.java rename to core-java-modules/core-java/src/main/java/com/baeldung/exceptions/ClassCast.java diff --git a/core-java/src/main/java/com/baeldung/exceptions/FileNotFound.java b/core-java-modules/core-java/src/main/java/com/baeldung/exceptions/FileNotFound.java similarity index 100% rename from core-java/src/main/java/com/baeldung/exceptions/FileNotFound.java rename to core-java-modules/core-java/src/main/java/com/baeldung/exceptions/FileNotFound.java diff --git a/core-java/src/main/java/com/baeldung/exceptions/GlobalExceptionHandler.java b/core-java-modules/core-java/src/main/java/com/baeldung/exceptions/GlobalExceptionHandler.java similarity index 100% rename from core-java/src/main/java/com/baeldung/exceptions/GlobalExceptionHandler.java rename to core-java-modules/core-java/src/main/java/com/baeldung/exceptions/GlobalExceptionHandler.java diff --git a/core-java/src/main/java/com/baeldung/exceptions/IllegalArgument.java b/core-java-modules/core-java/src/main/java/com/baeldung/exceptions/IllegalArgument.java similarity index 100% rename from core-java/src/main/java/com/baeldung/exceptions/IllegalArgument.java rename to core-java-modules/core-java/src/main/java/com/baeldung/exceptions/IllegalArgument.java diff --git a/core-java/src/main/java/com/baeldung/exceptions/IllegalState.java b/core-java-modules/core-java/src/main/java/com/baeldung/exceptions/IllegalState.java similarity index 100% rename from core-java/src/main/java/com/baeldung/exceptions/IllegalState.java rename to core-java-modules/core-java/src/main/java/com/baeldung/exceptions/IllegalState.java diff --git a/core-java/src/main/java/com/baeldung/exceptions/InterruptedExceptionExample.java b/core-java-modules/core-java/src/main/java/com/baeldung/exceptions/InterruptedExceptionExample.java similarity index 100% rename from core-java/src/main/java/com/baeldung/exceptions/InterruptedExceptionExample.java rename to core-java-modules/core-java/src/main/java/com/baeldung/exceptions/InterruptedExceptionExample.java diff --git a/core-java/src/main/java/com/baeldung/exceptions/MalformedURL.java b/core-java-modules/core-java/src/main/java/com/baeldung/exceptions/MalformedURL.java similarity index 100% rename from core-java/src/main/java/com/baeldung/exceptions/MalformedURL.java rename to core-java-modules/core-java/src/main/java/com/baeldung/exceptions/MalformedURL.java diff --git a/core-java/src/main/java/com/baeldung/exceptions/NullPointer.java b/core-java-modules/core-java/src/main/java/com/baeldung/exceptions/NullPointer.java similarity index 100% rename from core-java/src/main/java/com/baeldung/exceptions/NullPointer.java rename to core-java-modules/core-java/src/main/java/com/baeldung/exceptions/NullPointer.java diff --git a/core-java/src/main/java/com/baeldung/exceptions/NumberFormat.java b/core-java-modules/core-java/src/main/java/com/baeldung/exceptions/NumberFormat.java similarity index 100% rename from core-java/src/main/java/com/baeldung/exceptions/NumberFormat.java rename to core-java-modules/core-java/src/main/java/com/baeldung/exceptions/NumberFormat.java diff --git a/core-java/src/main/java/com/baeldung/exceptions/ParseExceptionExample.java b/core-java-modules/core-java/src/main/java/com/baeldung/exceptions/ParseExceptionExample.java similarity index 100% rename from core-java/src/main/java/com/baeldung/exceptions/ParseExceptionExample.java rename to core-java-modules/core-java/src/main/java/com/baeldung/exceptions/ParseExceptionExample.java diff --git a/core-java-modules/core-java/src/main/java/com/baeldung/exceptions/RootCauseFinder.java b/core-java-modules/core-java/src/main/java/com/baeldung/exceptions/RootCauseFinder.java new file mode 100644 index 0000000000..cf449110e6 --- /dev/null +++ b/core-java-modules/core-java/src/main/java/com/baeldung/exceptions/RootCauseFinder.java @@ -0,0 +1,98 @@ +package com.baeldung.exceptions; + +import java.time.LocalDate; +import java.time.Period; +import java.time.format.DateTimeParseException; +import java.util.Objects; + +/** + * Utility class to find root cause exceptions. + */ +public class RootCauseFinder { + + private RootCauseFinder() { + } + + public static Throwable findCauseUsingPlainJava(Throwable throwable) { + Objects.requireNonNull(throwable); + Throwable rootCause = throwable; + while (rootCause.getCause() != null && rootCause.getCause() != rootCause) { + rootCause = rootCause.getCause(); + } + return rootCause; + } + + /** + * Calculates the age of a person from a given date. + */ + static class AgeCalculator { + + private AgeCalculator() { + } + + public static int calculateAge(String birthDate) { + if (birthDate == null || birthDate.isEmpty()) { + throw new IllegalArgumentException(); + } + + try { + return Period + .between(parseDate(birthDate), LocalDate.now()) + .getYears(); + } catch (DateParseException ex) { + throw new CalculationException(ex); + } + } + + private static LocalDate parseDate(String birthDateAsString) { + + LocalDate birthDate; + try { + birthDate = LocalDate.parse(birthDateAsString); + } catch (DateTimeParseException ex) { + throw new InvalidFormatException(birthDateAsString, ex); + } + + if (birthDate.isAfter(LocalDate.now())) { + throw new DateOutOfRangeException(birthDateAsString); + } + + return birthDate; + } + + } + + static class CalculationException extends RuntimeException { + + CalculationException(DateParseException ex) { + super(ex); + } + } + + static class DateParseException extends RuntimeException { + + DateParseException(String input) { + super(input); + } + + DateParseException(String input, Throwable thr) { + super(input, thr); + } + } + + static class InvalidFormatException extends DateParseException { + + InvalidFormatException(String input, Throwable thr) { + super("Invalid date format: " + input, thr); + } + } + + static class DateOutOfRangeException extends DateParseException { + + DateOutOfRangeException(String date) { + super("Date out of range: " + date); + } + + } + +} diff --git a/core-java/src/main/java/com/baeldung/exceptions/StackTraceToString.java b/core-java-modules/core-java/src/main/java/com/baeldung/exceptions/StackTraceToString.java similarity index 100% rename from core-java/src/main/java/com/baeldung/exceptions/StackTraceToString.java rename to core-java-modules/core-java/src/main/java/com/baeldung/exceptions/StackTraceToString.java diff --git a/core-java/src/main/java/com/baeldung/exceptions/StringIndexOutOfBounds.java b/core-java-modules/core-java/src/main/java/com/baeldung/exceptions/StringIndexOutOfBounds.java similarity index 100% rename from core-java/src/main/java/com/baeldung/exceptions/StringIndexOutOfBounds.java rename to core-java-modules/core-java/src/main/java/com/baeldung/exceptions/StringIndexOutOfBounds.java diff --git a/core-java/src/main/java/com/baeldung/executable/ExecutableMavenJar.java b/core-java-modules/core-java/src/main/java/com/baeldung/executable/ExecutableMavenJar.java similarity index 100% rename from core-java/src/main/java/com/baeldung/executable/ExecutableMavenJar.java rename to core-java-modules/core-java/src/main/java/com/baeldung/executable/ExecutableMavenJar.java diff --git a/core-java/src/main/java/com/baeldung/externalizable/Community.java b/core-java-modules/core-java/src/main/java/com/baeldung/externalizable/Community.java similarity index 100% rename from core-java/src/main/java/com/baeldung/externalizable/Community.java rename to core-java-modules/core-java/src/main/java/com/baeldung/externalizable/Community.java diff --git a/core-java/src/main/java/com/baeldung/externalizable/Country.java b/core-java-modules/core-java/src/main/java/com/baeldung/externalizable/Country.java similarity index 100% rename from core-java/src/main/java/com/baeldung/externalizable/Country.java rename to core-java-modules/core-java/src/main/java/com/baeldung/externalizable/Country.java diff --git a/core-java/src/main/java/com/baeldung/externalizable/Region.java b/core-java-modules/core-java/src/main/java/com/baeldung/externalizable/Region.java similarity index 100% rename from core-java/src/main/java/com/baeldung/externalizable/Region.java rename to core-java-modules/core-java/src/main/java/com/baeldung/externalizable/Region.java diff --git a/core-java/src/main/java/com/baeldung/fileparser/BufferedReaderExample.java b/core-java-modules/core-java/src/main/java/com/baeldung/fileparser/BufferedReaderExample.java similarity index 100% rename from core-java/src/main/java/com/baeldung/fileparser/BufferedReaderExample.java rename to core-java-modules/core-java/src/main/java/com/baeldung/fileparser/BufferedReaderExample.java diff --git a/core-java/src/main/java/com/baeldung/fileparser/FileReaderExample.java b/core-java-modules/core-java/src/main/java/com/baeldung/fileparser/FileReaderExample.java similarity index 100% rename from core-java/src/main/java/com/baeldung/fileparser/FileReaderExample.java rename to core-java-modules/core-java/src/main/java/com/baeldung/fileparser/FileReaderExample.java diff --git a/core-java/src/main/java/com/baeldung/fileparser/FilesReadLinesExample.java b/core-java-modules/core-java/src/main/java/com/baeldung/fileparser/FilesReadLinesExample.java similarity index 100% rename from core-java/src/main/java/com/baeldung/fileparser/FilesReadLinesExample.java rename to core-java-modules/core-java/src/main/java/com/baeldung/fileparser/FilesReadLinesExample.java diff --git a/core-java/src/main/java/com/baeldung/fileparser/ScannerIntExample.java b/core-java-modules/core-java/src/main/java/com/baeldung/fileparser/ScannerIntExample.java similarity index 100% rename from core-java/src/main/java/com/baeldung/fileparser/ScannerIntExample.java rename to core-java-modules/core-java/src/main/java/com/baeldung/fileparser/ScannerIntExample.java diff --git a/core-java/src/main/java/com/baeldung/fileparser/ScannerStringExample.java b/core-java-modules/core-java/src/main/java/com/baeldung/fileparser/ScannerStringExample.java similarity index 100% rename from core-java/src/main/java/com/baeldung/fileparser/ScannerStringExample.java rename to core-java-modules/core-java/src/main/java/com/baeldung/fileparser/ScannerStringExample.java diff --git a/core-java/src/main/java/com/baeldung/filesystem/jndi/LookupFSJNDI.java b/core-java-modules/core-java/src/main/java/com/baeldung/filesystem/jndi/LookupFSJNDI.java similarity index 100% rename from core-java/src/main/java/com/baeldung/filesystem/jndi/LookupFSJNDI.java rename to core-java-modules/core-java/src/main/java/com/baeldung/filesystem/jndi/LookupFSJNDI.java diff --git a/core-java/src/main/java/com/baeldung/graph/Graph.java b/core-java-modules/core-java/src/main/java/com/baeldung/graph/Graph.java similarity index 68% rename from core-java/src/main/java/com/baeldung/graph/Graph.java rename to core-java-modules/core-java/src/main/java/com/baeldung/graph/Graph.java index 43b5c0aa08..3f2e17c43c 100644 --- a/core-java/src/main/java/com/baeldung/graph/Graph.java +++ b/core-java-modules/core-java/src/main/java/com/baeldung/graph/Graph.java @@ -59,18 +59,43 @@ public class Graph { Vertex(String label) { this.label = label; } - @Override - public boolean equals(Object obj) { - Vertex vertex = (Vertex) obj; - return vertex.label == label; - } + @Override public int hashCode() { - return label.hashCode(); + final int prime = 31; + int result = 1; + result = prime * result + getOuterType().hashCode(); + result = prime * result + ((label == null) ? 0 : label.hashCode()); + return result; } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + Vertex other = (Vertex) obj; + if (!getOuterType().equals(other.getOuterType())) + return false; + if (label == null) { + if (other.label != null) + return false; + } else if (!label.equals(other.label)) + return false; + return true; + } + @Override public String toString() { return label; } + + + private Graph getOuterType() { + return Graph.this; + } } } \ No newline at end of file diff --git a/core-java/src/main/java/com/baeldung/graph/GraphTraversal.java b/core-java-modules/core-java/src/main/java/com/baeldung/graph/GraphTraversal.java similarity index 100% rename from core-java/src/main/java/com/baeldung/graph/GraphTraversal.java rename to core-java-modules/core-java/src/main/java/com/baeldung/graph/GraphTraversal.java diff --git a/core-java/src/main/java/com/baeldung/instrumentation/agent/AtmTransformer.java b/core-java-modules/core-java/src/main/java/com/baeldung/instrumentation/agent/AtmTransformer.java similarity index 100% rename from core-java/src/main/java/com/baeldung/instrumentation/agent/AtmTransformer.java rename to core-java-modules/core-java/src/main/java/com/baeldung/instrumentation/agent/AtmTransformer.java diff --git a/core-java/src/main/java/com/baeldung/instrumentation/agent/MyInstrumentationAgent.java b/core-java-modules/core-java/src/main/java/com/baeldung/instrumentation/agent/MyInstrumentationAgent.java similarity index 100% rename from core-java/src/main/java/com/baeldung/instrumentation/agent/MyInstrumentationAgent.java rename to core-java-modules/core-java/src/main/java/com/baeldung/instrumentation/agent/MyInstrumentationAgent.java diff --git a/core-java/src/main/java/com/baeldung/instrumentation/application/AgentLoader.java b/core-java-modules/core-java/src/main/java/com/baeldung/instrumentation/application/AgentLoader.java similarity index 100% rename from core-java/src/main/java/com/baeldung/instrumentation/application/AgentLoader.java rename to core-java-modules/core-java/src/main/java/com/baeldung/instrumentation/application/AgentLoader.java diff --git a/core-java/src/main/java/com/baeldung/instrumentation/application/Launcher.java b/core-java-modules/core-java/src/main/java/com/baeldung/instrumentation/application/Launcher.java similarity index 100% rename from core-java/src/main/java/com/baeldung/instrumentation/application/Launcher.java rename to core-java-modules/core-java/src/main/java/com/baeldung/instrumentation/application/Launcher.java diff --git a/core-java/src/main/java/com/baeldung/instrumentation/application/MyAtm.java b/core-java-modules/core-java/src/main/java/com/baeldung/instrumentation/application/MyAtm.java similarity index 100% rename from core-java/src/main/java/com/baeldung/instrumentation/application/MyAtm.java rename to core-java-modules/core-java/src/main/java/com/baeldung/instrumentation/application/MyAtm.java diff --git a/core-java/src/main/java/com/baeldung/instrumentation/application/MyAtmApplication.java b/core-java-modules/core-java/src/main/java/com/baeldung/instrumentation/application/MyAtmApplication.java similarity index 100% rename from core-java/src/main/java/com/baeldung/instrumentation/application/MyAtmApplication.java rename to core-java-modules/core-java/src/main/java/com/baeldung/instrumentation/application/MyAtmApplication.java diff --git a/core-java/src/main/java/com/baeldung/jar/JarExample.java b/core-java-modules/core-java/src/main/java/com/baeldung/jar/JarExample.java similarity index 100% rename from core-java/src/main/java/com/baeldung/jar/JarExample.java rename to core-java-modules/core-java/src/main/java/com/baeldung/jar/JarExample.java diff --git a/core-java/src/main/java/com/baeldung/jar/example_manifest.txt b/core-java-modules/core-java/src/main/java/com/baeldung/jar/example_manifest.txt similarity index 100% rename from core-java/src/main/java/com/baeldung/jar/example_manifest.txt rename to core-java-modules/core-java/src/main/java/com/baeldung/jar/example_manifest.txt diff --git a/core-java/src/main/java/com/baeldung/javac/Data.java b/core-java-modules/core-java/src/main/java/com/baeldung/javac/Data.java similarity index 100% rename from core-java/src/main/java/com/baeldung/javac/Data.java rename to core-java-modules/core-java/src/main/java/com/baeldung/javac/Data.java diff --git a/core-java/src/main/java/com/baeldung/javadoc/Person.java b/core-java-modules/core-java/src/main/java/com/baeldung/javadoc/Person.java similarity index 100% rename from core-java/src/main/java/com/baeldung/javadoc/Person.java rename to core-java-modules/core-java/src/main/java/com/baeldung/javadoc/Person.java diff --git a/core-java/src/main/java/com/baeldung/javadoc/SuperHero.java b/core-java-modules/core-java/src/main/java/com/baeldung/javadoc/SuperHero.java similarity index 100% rename from core-java/src/main/java/com/baeldung/javadoc/SuperHero.java rename to core-java-modules/core-java/src/main/java/com/baeldung/javadoc/SuperHero.java diff --git a/core-java/src/main/java/com/baeldung/logforging/LogForgingDemo.java b/core-java-modules/core-java/src/main/java/com/baeldung/logforging/LogForgingDemo.java similarity index 100% rename from core-java/src/main/java/com/baeldung/logforging/LogForgingDemo.java rename to core-java-modules/core-java/src/main/java/com/baeldung/logforging/LogForgingDemo.java diff --git a/core-java/src/main/java/com/baeldung/manifest/AppExample.java b/core-java-modules/core-java/src/main/java/com/baeldung/manifest/AppExample.java similarity index 100% rename from core-java/src/main/java/com/baeldung/manifest/AppExample.java rename to core-java-modules/core-java/src/main/java/com/baeldung/manifest/AppExample.java diff --git a/core-java/src/main/java/com/baeldung/manifest/ExecuteJarFile.java b/core-java-modules/core-java/src/main/java/com/baeldung/manifest/ExecuteJarFile.java similarity index 100% rename from core-java/src/main/java/com/baeldung/manifest/ExecuteJarFile.java rename to core-java-modules/core-java/src/main/java/com/baeldung/manifest/ExecuteJarFile.java diff --git a/core-java-modules/core-java/src/main/java/com/baeldung/manifest/MANIFEST.MF b/core-java-modules/core-java/src/main/java/com/baeldung/manifest/MANIFEST.MF new file mode 100644 index 0000000000..a363171952 --- /dev/null +++ b/core-java-modules/core-java/src/main/java/com/baeldung/manifest/MANIFEST.MF @@ -0,0 +1 @@ +Main-Class: com.baeldung.manifest.AppExample diff --git a/core-java/src/main/java/com/baeldung/money/JavaMoney.java b/core-java-modules/core-java/src/main/java/com/baeldung/money/JavaMoney.java similarity index 97% rename from core-java/src/main/java/com/baeldung/money/JavaMoney.java rename to core-java-modules/core-java/src/main/java/com/baeldung/money/JavaMoney.java index 3171d226ed..aa507071cf 100644 --- a/core-java/src/main/java/com/baeldung/money/JavaMoney.java +++ b/core-java-modules/core-java/src/main/java/com/baeldung/money/JavaMoney.java @@ -1,151 +1,151 @@ -package com.baeldung.money; - -import java.util.Locale; -import java.util.logging.Logger; - -import javax.money.CurrencyUnit; -import javax.money.Monetary; -import javax.money.MonetaryAmount; -import javax.money.UnknownCurrencyException; -import javax.money.convert.ConversionQueryBuilder; -import javax.money.convert.CurrencyConversion; -import javax.money.convert.MonetaryConversions; -import javax.money.format.AmountFormatQueryBuilder; -import javax.money.format.MonetaryAmountFormat; -import javax.money.format.MonetaryFormats; - -import org.javamoney.moneta.FastMoney; -import org.javamoney.moneta.Money; -import org.javamoney.moneta.format.CurrencyStyle; - -public class JavaMoney { - final static Logger LOGGER = Logger.getLogger(JavaMoney.class.getName()); - CurrencyUnit USD; - MonetaryAmount fstAmtUSD; - MonetaryAmount fstAmtEUR; - MonetaryAmount oneDolar; - MonetaryAmount moneyof; - MonetaryAmount fastmoneyof; - MonetaryAmount roundEUR; - MonetaryAmount calcAmtUSD; - MonetaryAmount[] monetaryAmounts; - MonetaryAmount sumAmtCHF; - MonetaryAmount calcMoneyFastMoney; - MonetaryAmount convertedAmountEURtoUSD; - MonetaryAmount convertedAmountEURtoUSD2; - MonetaryAmount convertedAmountUSDtoEUR; - MonetaryAmount convertedAmountUSDtoEUR2; - MonetaryAmount multiplyAmount; - MonetaryAmount divideAmount; - MonetaryAmount oneDivThree; - CurrencyConversion convEUR; - CurrencyConversion convUSD; - CurrencyConversion conversionUSD; - CurrencyConversion conversionEUR; - MonetaryAmount oneEuro; - MonetaryAmountFormat formatUSD; - MonetaryAmountFormat customFormat; - String usFormatted; - String customFormatted; - - public JavaMoney() { - USD = Monetary.getCurrency("USD"); - fstAmtUSD = Monetary.getDefaultAmountFactory().setCurrency(USD).setNumber(200.50).create(); - fstAmtEUR = Monetary.getDefaultAmountFactory().setCurrency("EUR").setNumber(1.30473908).create(); - oneDolar = Monetary.getDefaultAmountFactory().setCurrency("USD").setNumber(1).create(); - moneyof = Money.of(12, USD); - fastmoneyof = FastMoney.of(2, USD); - - LOGGER.info("First Amount in USD : " + fstAmtUSD); - LOGGER.info("First Amount in EUR : " + fstAmtEUR); - LOGGER.info("One Dolar : " + oneDolar); - LOGGER.info("MoneyOf : " + moneyof); - LOGGER.info("FastMoneyOf : " + fastmoneyof); - - try{ - @SuppressWarnings("unused") - CurrencyUnit AAA = Monetary.getCurrency("AAA"); - } catch (UnknownCurrencyException e) { - LOGGER.severe("Unknown Currency"); - } - - roundEUR = fstAmtEUR.with(Monetary.getDefaultRounding()); - - LOGGER.info("Rounded EUR : " + roundEUR); - - calcAmtUSD = Money.of(1, "USD").subtract(fstAmtUSD); - - LOGGER.info("Substracting amounts : " + calcAmtUSD); - - calcMoneyFastMoney = moneyof.subtract(fastmoneyof); - - LOGGER.info("Money & FastMoney operations : " + calcMoneyFastMoney); - - monetaryAmounts = - new MonetaryAmount[] { - Money.of(100, "CHF"), - Money.of(10.20, "CHF"), - Money.of(1.15, "CHF"), }; - sumAmtCHF = Money.of(0, "CHF"); - for (MonetaryAmount monetaryAmount : monetaryAmounts) { - sumAmtCHF = sumAmtCHF.add(monetaryAmount); - } - - LOGGER.info("Adding amounts : " + sumAmtCHF); - - multiplyAmount = oneDolar.multiply(0.25); - LOGGER.info("Multiply Amount : " + multiplyAmount); - - divideAmount = oneDolar.divide(0.25); - LOGGER.info("Divide Amount : " + divideAmount); - - try{ - oneDivThree = oneDolar.divide(3); - }catch (ArithmeticException e) { - LOGGER.severe("One divide by Three is an infinite number"); - } - - convEUR = MonetaryConversions.getConversion(ConversionQueryBuilder.of().setTermCurrency("EUR").build()); - convUSD = MonetaryConversions.getConversion(ConversionQueryBuilder.of().setTermCurrency(USD).build()); - - conversionUSD = MonetaryConversions.getConversion("USD"); - conversionEUR = MonetaryConversions.getConversion("EUR"); - - convertedAmountEURtoUSD = fstAmtEUR.with(conversionUSD); - convertedAmountEURtoUSD2 = fstAmtEUR.with(convUSD); - convertedAmountUSDtoEUR = oneDolar.with(conversionEUR); - convertedAmountUSDtoEUR2 = oneDolar.with(convEUR); - LOGGER.info("C1 - " + convertedAmountEURtoUSD); - LOGGER.info("C2 - " + convertedAmountEURtoUSD2); - LOGGER.info("One Euro -> " + convertedAmountUSDtoEUR); - LOGGER.info("One Euro2 -> " + convertedAmountUSDtoEUR2); - - oneEuro = Money.of(1, "EUR"); - - if (oneEuro.equals(FastMoney.of(1, "EUR"))) { - LOGGER.info("Money == FastMoney"); - } else { - LOGGER.info("Money != FastMoney"); - } - - if (oneDolar.equals(Money.of(1, "USD"))) { - LOGGER.info("Factory == Money"); - } else { - LOGGER.info("Factory != Money"); - } - - formatUSD = MonetaryFormats.getAmountFormat(Locale.US); - usFormatted = formatUSD.format(oneDolar); - LOGGER.info("One dolar standard formatted : " + usFormatted); - - customFormat = MonetaryFormats.getAmountFormat(AmountFormatQueryBuilder.of(Locale.US).set(CurrencyStyle.NAME).set("pattern", "00000.00 ¤").build()); - customFormatted = customFormat.format(oneDolar); - LOGGER.info("One dolar custom formatted : " + customFormatted); - } - - public static void main(String[] args) { - @SuppressWarnings("unused") - JavaMoney java9Money = new JavaMoney(); - } - -} +package com.baeldung.money; + +import java.util.Locale; +import java.util.logging.Logger; + +import javax.money.CurrencyUnit; +import javax.money.Monetary; +import javax.money.MonetaryAmount; +import javax.money.UnknownCurrencyException; +import javax.money.convert.ConversionQueryBuilder; +import javax.money.convert.CurrencyConversion; +import javax.money.convert.MonetaryConversions; +import javax.money.format.AmountFormatQueryBuilder; +import javax.money.format.MonetaryAmountFormat; +import javax.money.format.MonetaryFormats; + +import org.javamoney.moneta.FastMoney; +import org.javamoney.moneta.Money; +import org.javamoney.moneta.format.CurrencyStyle; + +public class JavaMoney { + final static Logger LOGGER = Logger.getLogger(JavaMoney.class.getName()); + CurrencyUnit USD; + MonetaryAmount fstAmtUSD; + MonetaryAmount fstAmtEUR; + MonetaryAmount oneDolar; + MonetaryAmount moneyof; + MonetaryAmount fastmoneyof; + MonetaryAmount roundEUR; + MonetaryAmount calcAmtUSD; + MonetaryAmount[] monetaryAmounts; + MonetaryAmount sumAmtCHF; + MonetaryAmount calcMoneyFastMoney; + MonetaryAmount convertedAmountEURtoUSD; + MonetaryAmount convertedAmountEURtoUSD2; + MonetaryAmount convertedAmountUSDtoEUR; + MonetaryAmount convertedAmountUSDtoEUR2; + MonetaryAmount multiplyAmount; + MonetaryAmount divideAmount; + MonetaryAmount oneDivThree; + CurrencyConversion convEUR; + CurrencyConversion convUSD; + CurrencyConversion conversionUSD; + CurrencyConversion conversionEUR; + MonetaryAmount oneEuro; + MonetaryAmountFormat formatUSD; + MonetaryAmountFormat customFormat; + String usFormatted; + String customFormatted; + + public JavaMoney() { + USD = Monetary.getCurrency("USD"); + fstAmtUSD = Monetary.getDefaultAmountFactory().setCurrency(USD).setNumber(200.50).create(); + fstAmtEUR = Monetary.getDefaultAmountFactory().setCurrency("EUR").setNumber(1.30473908).create(); + oneDolar = Monetary.getDefaultAmountFactory().setCurrency("USD").setNumber(1).create(); + moneyof = Money.of(12, USD); + fastmoneyof = FastMoney.of(2, USD); + + LOGGER.info("First Amount in USD : " + fstAmtUSD); + LOGGER.info("First Amount in EUR : " + fstAmtEUR); + LOGGER.info("One Dolar : " + oneDolar); + LOGGER.info("MoneyOf : " + moneyof); + LOGGER.info("FastMoneyOf : " + fastmoneyof); + + try{ + @SuppressWarnings("unused") + CurrencyUnit AAA = Monetary.getCurrency("AAA"); + } catch (UnknownCurrencyException e) { + LOGGER.severe("Unknown Currency"); + } + + roundEUR = fstAmtEUR.with(Monetary.getDefaultRounding()); + + LOGGER.info("Rounded EUR : " + roundEUR); + + calcAmtUSD = Money.of(1, "USD").subtract(fstAmtUSD); + + LOGGER.info("Substracting amounts : " + calcAmtUSD); + + calcMoneyFastMoney = moneyof.subtract(fastmoneyof); + + LOGGER.info("Money & FastMoney operations : " + calcMoneyFastMoney); + + monetaryAmounts = + new MonetaryAmount[] { + Money.of(100, "CHF"), + Money.of(10.20, "CHF"), + Money.of(1.15, "CHF"), }; + sumAmtCHF = Money.of(0, "CHF"); + for (MonetaryAmount monetaryAmount : monetaryAmounts) { + sumAmtCHF = sumAmtCHF.add(monetaryAmount); + } + + LOGGER.info("Adding amounts : " + sumAmtCHF); + + multiplyAmount = oneDolar.multiply(0.25); + LOGGER.info("Multiply Amount : " + multiplyAmount); + + divideAmount = oneDolar.divide(0.25); + LOGGER.info("Divide Amount : " + divideAmount); + + try{ + oneDivThree = oneDolar.divide(3); + }catch (ArithmeticException e) { + LOGGER.severe("One divide by Three is an infinite number"); + } + + convEUR = MonetaryConversions.getConversion(ConversionQueryBuilder.of().setTermCurrency("EUR").build()); + convUSD = MonetaryConversions.getConversion(ConversionQueryBuilder.of().setTermCurrency(USD).build()); + + conversionUSD = MonetaryConversions.getConversion("USD"); + conversionEUR = MonetaryConversions.getConversion("EUR"); + + convertedAmountEURtoUSD = fstAmtEUR.with(conversionUSD); + convertedAmountEURtoUSD2 = fstAmtEUR.with(convUSD); + convertedAmountUSDtoEUR = oneDolar.with(conversionEUR); + convertedAmountUSDtoEUR2 = oneDolar.with(convEUR); + LOGGER.info("C1 - " + convertedAmountEURtoUSD); + LOGGER.info("C2 - " + convertedAmountEURtoUSD2); + LOGGER.info("One Euro -> " + convertedAmountUSDtoEUR); + LOGGER.info("One Euro2 -> " + convertedAmountUSDtoEUR2); + + oneEuro = Money.of(1, "EUR"); + + if (oneEuro.equals(FastMoney.of(1, "EUR"))) { + LOGGER.info("Money == FastMoney"); + } else { + LOGGER.info("Money != FastMoney"); + } + + if (oneDolar.equals(Money.of(1, "USD"))) { + LOGGER.info("Factory == Money"); + } else { + LOGGER.info("Factory != Money"); + } + + formatUSD = MonetaryFormats.getAmountFormat(Locale.US); + usFormatted = formatUSD.format(oneDolar); + LOGGER.info("One dolar standard formatted : " + usFormatted); + + customFormat = MonetaryFormats.getAmountFormat(AmountFormatQueryBuilder.of(Locale.US).set(CurrencyStyle.NAME).set("pattern", "00000.00 ¤").build()); + customFormatted = customFormat.format(oneDolar); + LOGGER.info("One dolar custom formatted : " + customFormatted); + } + + public static void main(String[] args) { + @SuppressWarnings("unused") + JavaMoney java9Money = new JavaMoney(); + } + +} diff --git a/core-java/src/main/java/com/baeldung/objectsize/InstrumentationAgent.java b/core-java-modules/core-java/src/main/java/com/baeldung/objectsize/InstrumentationAgent.java similarity index 100% rename from core-java/src/main/java/com/baeldung/objectsize/InstrumentationAgent.java rename to core-java-modules/core-java/src/main/java/com/baeldung/objectsize/InstrumentationAgent.java diff --git a/core-java/src/main/java/com/baeldung/objectsize/InstrumentationExample.java b/core-java-modules/core-java/src/main/java/com/baeldung/objectsize/InstrumentationExample.java similarity index 100% rename from core-java/src/main/java/com/baeldung/objectsize/InstrumentationExample.java rename to core-java-modules/core-java/src/main/java/com/baeldung/objectsize/InstrumentationExample.java diff --git a/core-java/src/main/java/com/baeldung/objectsize/MANIFEST.MF b/core-java-modules/core-java/src/main/java/com/baeldung/objectsize/MANIFEST.MF similarity index 100% rename from core-java/src/main/java/com/baeldung/objectsize/MANIFEST.MF rename to core-java-modules/core-java/src/main/java/com/baeldung/objectsize/MANIFEST.MF diff --git a/core-java/src/main/java/com/baeldung/printf/PrintfExamples.java b/core-java-modules/core-java/src/main/java/com/baeldung/printf/PrintfExamples.java similarity index 100% rename from core-java/src/main/java/com/baeldung/printf/PrintfExamples.java rename to core-java-modules/core-java/src/main/java/com/baeldung/printf/PrintfExamples.java diff --git a/core-java/src/main/java/com/baeldung/printscreen/README.md b/core-java-modules/core-java/src/main/java/com/baeldung/printscreen/README.md similarity index 100% rename from core-java/src/main/java/com/baeldung/printscreen/README.md rename to core-java-modules/core-java/src/main/java/com/baeldung/printscreen/README.md diff --git a/core-java/src/main/java/com/baeldung/printscreen/Screenshot.java b/core-java-modules/core-java/src/main/java/com/baeldung/printscreen/Screenshot.java similarity index 100% rename from core-java/src/main/java/com/baeldung/printscreen/Screenshot.java rename to core-java-modules/core-java/src/main/java/com/baeldung/printscreen/Screenshot.java diff --git a/core-java/src/main/java/com/baeldung/reflection/BaeldungReflectionUtils.java b/core-java-modules/core-java/src/main/java/com/baeldung/reflection/BaeldungReflectionUtils.java similarity index 100% rename from core-java/src/main/java/com/baeldung/reflection/BaeldungReflectionUtils.java rename to core-java-modules/core-java/src/main/java/com/baeldung/reflection/BaeldungReflectionUtils.java diff --git a/core-java/src/main/java/com/baeldung/reflection/Customer.java b/core-java-modules/core-java/src/main/java/com/baeldung/reflection/Customer.java similarity index 100% rename from core-java/src/main/java/com/baeldung/reflection/Customer.java rename to core-java-modules/core-java/src/main/java/com/baeldung/reflection/Customer.java diff --git a/core-java/src/main/java/com/baeldung/reflection/Employee.java b/core-java-modules/core-java/src/main/java/com/baeldung/reflection/Employee.java similarity index 100% rename from core-java/src/main/java/com/baeldung/reflection/Employee.java rename to core-java-modules/core-java/src/main/java/com/baeldung/reflection/Employee.java diff --git a/core-java/src/main/java/com/baeldung/reflection/MonthEmployee.java b/core-java-modules/core-java/src/main/java/com/baeldung/reflection/MonthEmployee.java similarity index 100% rename from core-java/src/main/java/com/baeldung/reflection/MonthEmployee.java rename to core-java-modules/core-java/src/main/java/com/baeldung/reflection/MonthEmployee.java diff --git a/core-java/src/main/java/com/baeldung/reflection/Person.java b/core-java-modules/core-java/src/main/java/com/baeldung/reflection/Person.java similarity index 100% rename from core-java/src/main/java/com/baeldung/reflection/Person.java rename to core-java-modules/core-java/src/main/java/com/baeldung/reflection/Person.java diff --git a/core-java/src/main/java/com/baeldung/resourcebundle/ExampleControl.java b/core-java-modules/core-java/src/main/java/com/baeldung/resourcebundle/ExampleControl.java similarity index 100% rename from core-java/src/main/java/com/baeldung/resourcebundle/ExampleControl.java rename to core-java-modules/core-java/src/main/java/com/baeldung/resourcebundle/ExampleControl.java diff --git a/core-java/src/main/java/com/baeldung/resourcebundle/ExampleResource.java b/core-java-modules/core-java/src/main/java/com/baeldung/resourcebundle/ExampleResource.java similarity index 100% rename from core-java/src/main/java/com/baeldung/resourcebundle/ExampleResource.java rename to core-java-modules/core-java/src/main/java/com/baeldung/resourcebundle/ExampleResource.java diff --git a/core-java/src/main/java/com/baeldung/resourcebundle/ExampleResource_pl.java b/core-java-modules/core-java/src/main/java/com/baeldung/resourcebundle/ExampleResource_pl.java similarity index 100% rename from core-java/src/main/java/com/baeldung/resourcebundle/ExampleResource_pl.java rename to core-java-modules/core-java/src/main/java/com/baeldung/resourcebundle/ExampleResource_pl.java diff --git a/core-java/src/main/java/com/baeldung/resourcebundle/ExampleResource_pl_PL.java b/core-java-modules/core-java/src/main/java/com/baeldung/resourcebundle/ExampleResource_pl_PL.java similarity index 100% rename from core-java/src/main/java/com/baeldung/resourcebundle/ExampleResource_pl_PL.java rename to core-java-modules/core-java/src/main/java/com/baeldung/resourcebundle/ExampleResource_pl_PL.java diff --git a/core-java/src/main/java/com/baeldung/serialization/Address.java b/core-java-modules/core-java/src/main/java/com/baeldung/serialization/Address.java similarity index 100% rename from core-java/src/main/java/com/baeldung/serialization/Address.java rename to core-java-modules/core-java/src/main/java/com/baeldung/serialization/Address.java diff --git a/core-java/src/main/java/com/baeldung/serialization/Employee.java b/core-java-modules/core-java/src/main/java/com/baeldung/serialization/Employee.java similarity index 100% rename from core-java/src/main/java/com/baeldung/serialization/Employee.java rename to core-java-modules/core-java/src/main/java/com/baeldung/serialization/Employee.java diff --git a/core-java/src/main/java/com/baeldung/serialization/Person.java b/core-java-modules/core-java/src/main/java/com/baeldung/serialization/Person.java similarity index 100% rename from core-java/src/main/java/com/baeldung/serialization/Person.java rename to core-java-modules/core-java/src/main/java/com/baeldung/serialization/Person.java diff --git a/core-java/src/main/java/com/baeldung/staticclass/Pizza.java b/core-java-modules/core-java/src/main/java/com/baeldung/staticclass/Pizza.java similarity index 100% rename from core-java/src/main/java/com/baeldung/staticclass/Pizza.java rename to core-java-modules/core-java/src/main/java/com/baeldung/staticclass/Pizza.java diff --git a/core-java/src/main/java/com/baeldung/system/DetectOS.java b/core-java-modules/core-java/src/main/java/com/baeldung/system/DetectOS.java similarity index 100% rename from core-java/src/main/java/com/baeldung/system/DetectOS.java rename to core-java-modules/core-java/src/main/java/com/baeldung/system/DetectOS.java diff --git a/core-java/src/main/java/com/baeldung/urlconnection/PostJSONWithHttpURLConnection.java b/core-java-modules/core-java/src/main/java/com/baeldung/urlconnection/PostJSONWithHttpURLConnection.java similarity index 100% rename from core-java/src/main/java/com/baeldung/urlconnection/PostJSONWithHttpURLConnection.java rename to core-java-modules/core-java/src/main/java/com/baeldung/urlconnection/PostJSONWithHttpURLConnection.java diff --git a/core-java/src/main/java/com/baeldung/util/PropertiesLoader.java b/core-java-modules/core-java/src/main/java/com/baeldung/util/PropertiesLoader.java similarity index 100% rename from core-java/src/main/java/com/baeldung/util/PropertiesLoader.java rename to core-java-modules/core-java/src/main/java/com/baeldung/util/PropertiesLoader.java diff --git a/core-java/src/main/java/com/baeldung/uuid/UUIDGenerator.java b/core-java-modules/core-java/src/main/java/com/baeldung/uuid/UUIDGenerator.java similarity index 100% rename from core-java/src/main/java/com/baeldung/uuid/UUIDGenerator.java rename to core-java-modules/core-java/src/main/java/com/baeldung/uuid/UUIDGenerator.java diff --git a/core-java/src/main/java/javac-args/arguments b/core-java-modules/core-java/src/main/java/javac-args/arguments similarity index 100% rename from core-java/src/main/java/javac-args/arguments rename to core-java-modules/core-java/src/main/java/javac-args/arguments diff --git a/core-java/src/main/java/javac-args/options b/core-java-modules/core-java/src/main/java/javac-args/options similarity index 100% rename from core-java/src/main/java/javac-args/options rename to core-java-modules/core-java/src/main/java/javac-args/options diff --git a/core-java/src/main/java/javac-args/types b/core-java-modules/core-java/src/main/java/javac-args/types similarity index 100% rename from core-java/src/main/java/javac-args/types rename to core-java-modules/core-java/src/main/java/javac-args/types diff --git a/core-java/src/main/java/javac-args/xlint-ops b/core-java-modules/core-java/src/main/java/javac-args/xlint-ops similarity index 100% rename from core-java/src/main/java/javac-args/xlint-ops rename to core-java-modules/core-java/src/main/java/javac-args/xlint-ops diff --git a/core-java/src/main/java/log4j.properties b/core-java-modules/core-java/src/main/java/log4j.properties similarity index 100% rename from core-java/src/main/java/log4j.properties rename to core-java-modules/core-java/src/main/java/log4j.properties diff --git a/core-java/src/main/java/org/baeldung/executable/ExecutableMavenJar.java b/core-java-modules/core-java/src/main/java/org/baeldung/executable/ExecutableMavenJar.java similarity index 100% rename from core-java/src/main/java/org/baeldung/executable/ExecutableMavenJar.java rename to core-java-modules/core-java/src/main/java/org/baeldung/executable/ExecutableMavenJar.java diff --git a/core-java/src/main/resources/ESAPI.properties b/core-java-modules/core-java/src/main/resources/ESAPI.properties similarity index 100% rename from core-java/src/main/resources/ESAPI.properties rename to core-java-modules/core-java/src/main/resources/ESAPI.properties diff --git a/core-java/src/main/resources/META-INF/BenchmarkList b/core-java-modules/core-java/src/main/resources/META-INF/BenchmarkList old mode 100755 new mode 100644 similarity index 100% rename from core-java/src/main/resources/META-INF/BenchmarkList rename to core-java-modules/core-java/src/main/resources/META-INF/BenchmarkList diff --git a/core-java/src/main/resources/META-INF/MANIFEST.MF b/core-java-modules/core-java/src/main/resources/META-INF/MANIFEST.MF similarity index 100% rename from core-java/src/main/resources/META-INF/MANIFEST.MF rename to core-java-modules/core-java/src/main/resources/META-INF/MANIFEST.MF diff --git a/core-java/src/main/resources/META-INF/persistence.xml b/core-java-modules/core-java/src/main/resources/META-INF/persistence.xml similarity index 100% rename from core-java/src/main/resources/META-INF/persistence.xml rename to core-java-modules/core-java/src/main/resources/META-INF/persistence.xml diff --git a/core-java/src/main/resources/countries.properties b/core-java-modules/core-java/src/main/resources/countries.properties similarity index 100% rename from core-java/src/main/resources/countries.properties rename to core-java-modules/core-java/src/main/resources/countries.properties diff --git a/core-java/src/main/resources/datasource.properties b/core-java-modules/core-java/src/main/resources/datasource.properties similarity index 100% rename from core-java/src/main/resources/datasource.properties rename to core-java-modules/core-java/src/main/resources/datasource.properties diff --git a/core-java/src/main/resources/files/test.txt b/core-java-modules/core-java/src/main/resources/files/test.txt similarity index 100% rename from core-java/src/main/resources/files/test.txt rename to core-java-modules/core-java/src/main/resources/files/test.txt diff --git a/core-java/src/main/resources/js/bind.js b/core-java-modules/core-java/src/main/resources/js/bind.js similarity index 100% rename from core-java/src/main/resources/js/bind.js rename to core-java-modules/core-java/src/main/resources/js/bind.js diff --git a/core-java/src/main/resources/js/locations.js b/core-java-modules/core-java/src/main/resources/js/locations.js similarity index 100% rename from core-java/src/main/resources/js/locations.js rename to core-java-modules/core-java/src/main/resources/js/locations.js diff --git a/core-java/src/main/resources/js/math_module.js b/core-java-modules/core-java/src/main/resources/js/math_module.js similarity index 100% rename from core-java/src/main/resources/js/math_module.js rename to core-java-modules/core-java/src/main/resources/js/math_module.js diff --git a/core-java/src/main/resources/js/no_such.js b/core-java-modules/core-java/src/main/resources/js/no_such.js similarity index 100% rename from core-java/src/main/resources/js/no_such.js rename to core-java-modules/core-java/src/main/resources/js/no_such.js diff --git a/core-java/src/main/resources/js/script.js b/core-java-modules/core-java/src/main/resources/js/script.js similarity index 100% rename from core-java/src/main/resources/js/script.js rename to core-java-modules/core-java/src/main/resources/js/script.js diff --git a/core-java/src/main/resources/js/trim.js b/core-java-modules/core-java/src/main/resources/js/trim.js similarity index 100% rename from core-java/src/main/resources/js/trim.js rename to core-java-modules/core-java/src/main/resources/js/trim.js diff --git a/core-java/src/main/resources/js/typed_arrays.js b/core-java-modules/core-java/src/main/resources/js/typed_arrays.js similarity index 100% rename from core-java/src/main/resources/js/typed_arrays.js rename to core-java-modules/core-java/src/main/resources/js/typed_arrays.js diff --git a/core-java/src/main/resources/log4j.properties b/core-java-modules/core-java/src/main/resources/log4j.properties similarity index 100% rename from core-java/src/main/resources/log4j.properties rename to core-java-modules/core-java/src/main/resources/log4j.properties diff --git a/core-java/src/main/resources/log4j2.xml b/core-java-modules/core-java/src/main/resources/log4j2.xml similarity index 100% rename from core-java/src/main/resources/log4j2.xml rename to core-java-modules/core-java/src/main/resources/log4j2.xml diff --git a/core-java/src/main/resources/log4jstructuraldp.properties b/core-java-modules/core-java/src/main/resources/log4jstructuraldp.properties similarity index 100% rename from core-java/src/main/resources/log4jstructuraldp.properties rename to core-java-modules/core-java/src/main/resources/log4jstructuraldp.properties diff --git a/core-java/src/main/resources/logback.xml b/core-java-modules/core-java/src/main/resources/logback.xml similarity index 100% rename from core-java/src/main/resources/logback.xml rename to core-java-modules/core-java/src/main/resources/logback.xml diff --git a/core-java/src/main/resources/product.png b/core-java-modules/core-java/src/main/resources/product.png similarity index 100% rename from core-java/src/main/resources/product.png rename to core-java-modules/core-java/src/main/resources/product.png diff --git a/core-java/src/main/resources/resourcebundle/resource.properties b/core-java-modules/core-java/src/main/resources/resourcebundle/resource.properties similarity index 100% rename from core-java/src/main/resources/resourcebundle/resource.properties rename to core-java-modules/core-java/src/main/resources/resourcebundle/resource.properties diff --git a/core-java/src/main/resources/resourcebundle/resource_en.properties b/core-java-modules/core-java/src/main/resources/resourcebundle/resource_en.properties similarity index 100% rename from core-java/src/main/resources/resourcebundle/resource_en.properties rename to core-java-modules/core-java/src/main/resources/resourcebundle/resource_en.properties diff --git a/core-java/src/main/resources/resourcebundle/resource_pl_PL.properties b/core-java-modules/core-java/src/main/resources/resourcebundle/resource_pl_PL.properties similarity index 100% rename from core-java/src/main/resources/resourcebundle/resource_pl_PL.properties rename to core-java-modules/core-java/src/main/resources/resourcebundle/resource_pl_PL.properties diff --git a/core-java/src/test/java/com/baeldung/abstractclasses/test/LowercaseFileReaderUnitTest.java b/core-java-modules/core-java/src/test/java/com/baeldung/abstractclasses/test/LowercaseFileReaderUnitTest.java similarity index 97% rename from core-java/src/test/java/com/baeldung/abstractclasses/test/LowercaseFileReaderUnitTest.java rename to core-java-modules/core-java/src/test/java/com/baeldung/abstractclasses/test/LowercaseFileReaderUnitTest.java index 4f0d3a7cd5..45e16f0d25 100644 --- a/core-java/src/test/java/com/baeldung/abstractclasses/test/LowercaseFileReaderUnitTest.java +++ b/core-java-modules/core-java/src/test/java/com/baeldung/abstractclasses/test/LowercaseFileReaderUnitTest.java @@ -1,20 +1,20 @@ -package com.baeldung.abstractclasses.test; - -import com.baeldung.abstractclasses.filereaders.BaseFileReader; -import com.baeldung.abstractclasses.filereaders.LowercaseFileReader; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.util.List; -import static org.assertj.core.api.Assertions.assertThat; -import org.junit.Test; - -public class LowercaseFileReaderUnitTest { - - @Test - public void givenLowercaseFileReaderInstance_whenCalledreadFile_thenCorrect() throws Exception { - Path path = Paths.get(getClass().getClassLoader().getResource("files/test.txt").toURI()); - BaseFileReader lowercaseFileReader = new LowercaseFileReader(path); - - assertThat(lowercaseFileReader.readFile()).isInstanceOf(List.class); - } -} +package com.baeldung.abstractclasses.test; + +import com.baeldung.abstractclasses.filereaders.BaseFileReader; +import com.baeldung.abstractclasses.filereaders.LowercaseFileReader; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.List; +import static org.assertj.core.api.Assertions.assertThat; +import org.junit.Test; + +public class LowercaseFileReaderUnitTest { + + @Test + public void givenLowercaseFileReaderInstance_whenCalledreadFile_thenCorrect() throws Exception { + Path path = Paths.get(getClass().getClassLoader().getResource("files/test.txt").toURI()); + BaseFileReader lowercaseFileReader = new LowercaseFileReader(path); + + assertThat(lowercaseFileReader.readFile()).isInstanceOf(List.class); + } +} diff --git a/core-java/src/test/java/com/baeldung/abstractclasses/test/UppercaseFileReaderUnitTest.java b/core-java-modules/core-java/src/test/java/com/baeldung/abstractclasses/test/UppercaseFileReaderUnitTest.java similarity index 97% rename from core-java/src/test/java/com/baeldung/abstractclasses/test/UppercaseFileReaderUnitTest.java rename to core-java-modules/core-java/src/test/java/com/baeldung/abstractclasses/test/UppercaseFileReaderUnitTest.java index e11db57000..dc4df900e4 100644 --- a/core-java/src/test/java/com/baeldung/abstractclasses/test/UppercaseFileReaderUnitTest.java +++ b/core-java-modules/core-java/src/test/java/com/baeldung/abstractclasses/test/UppercaseFileReaderUnitTest.java @@ -1,20 +1,20 @@ -package com.baeldung.abstractclasses.test; - -import com.baeldung.abstractclasses.filereaders.BaseFileReader; -import com.baeldung.abstractclasses.filereaders.UppercaseFileReader; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.util.List; -import static org.assertj.core.api.Assertions.assertThat; -import org.junit.Test; - -public class UppercaseFileReaderUnitTest { - - @Test - public void givenUppercaseFileReaderInstance_whenCalledreadFile_thenCorrect() throws Exception { - Path path = Paths.get(getClass().getClassLoader().getResource("files/test.txt").toURI()); - BaseFileReader uppercaseFileReader = new UppercaseFileReader(path); - - assertThat(uppercaseFileReader.readFile()).isInstanceOf(List.class); - } -} +package com.baeldung.abstractclasses.test; + +import com.baeldung.abstractclasses.filereaders.BaseFileReader; +import com.baeldung.abstractclasses.filereaders.UppercaseFileReader; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.List; +import static org.assertj.core.api.Assertions.assertThat; +import org.junit.Test; + +public class UppercaseFileReaderUnitTest { + + @Test + public void givenUppercaseFileReaderInstance_whenCalledreadFile_thenCorrect() throws Exception { + Path path = Paths.get(getClass().getClassLoader().getResource("files/test.txt").toURI()); + BaseFileReader uppercaseFileReader = new UppercaseFileReader(path); + + assertThat(uppercaseFileReader.readFile()).isInstanceOf(List.class); + } +} diff --git a/core-java/src/test/java/com/baeldung/asciiart/AsciiArtIntegrationTest.java b/core-java-modules/core-java/src/test/java/com/baeldung/asciiart/AsciiArtIntegrationTest.java similarity index 100% rename from core-java/src/test/java/com/baeldung/asciiart/AsciiArtIntegrationTest.java rename to core-java-modules/core-java/src/test/java/com/baeldung/asciiart/AsciiArtIntegrationTest.java diff --git a/core-java/src/test/java/com/baeldung/bitwiseoperator/test/BitwiseOperatorUnitTest.java b/core-java-modules/core-java/src/test/java/com/baeldung/bitwiseoperator/test/BitwiseOperatorUnitTest.java similarity index 96% rename from core-java/src/test/java/com/baeldung/bitwiseoperator/test/BitwiseOperatorUnitTest.java rename to core-java-modules/core-java/src/test/java/com/baeldung/bitwiseoperator/test/BitwiseOperatorUnitTest.java index f74e181e36..1ca7b7281e 100644 --- a/core-java/src/test/java/com/baeldung/bitwiseoperator/test/BitwiseOperatorUnitTest.java +++ b/core-java-modules/core-java/src/test/java/com/baeldung/bitwiseoperator/test/BitwiseOperatorUnitTest.java @@ -1,81 +1,81 @@ -package com.baeldung.bitwiseoperator.test; - -import static org.junit.Assert.assertEquals; -import org.junit.jupiter.api.Test; - -public class BitwiseOperatorUnitTest { - - @Test - public void givenTwoIntegers_whenAndOperator_thenNewDecimalNumber() { - int value1 = 6; - int value2 = 5; - int result = value1 & value2; - assertEquals(4, result); - } - - @Test - public void givenTwoIntegers_whenOrOperator_thenNewDecimalNumber() { - int value1 = 6; - int value2 = 5; - int result = value1 | value2; - assertEquals(7, result); - } - - @Test - public void givenTwoIntegers_whenXorOperator_thenNewDecimalNumber() { - int value1 = 6; - int value2 = 5; - int result = value1 ^ value2; - assertEquals(3, result); - } - - @Test - public void givenOneInteger_whenNotOperator_thenNewDecimalNumber() { - int value1 = 6; - int result = ~value1; - assertEquals(result, -7); - } - - @Test - public void givenOnePositiveInteger_whenSignedRightShiftOperator_thenNewDecimalNumber() { - int value = 12; - int rightShift = value >> 2; - assertEquals(3, rightShift); - } - - @Test - public void givenOneNegativeInteger_whenSignedRightShiftOperator_thenNewDecimalNumber() { - int value = -12; - int rightShift = value >> 2; - assertEquals(-3, rightShift); - } - - @Test - public void givenOnePositiveInteger_whenLeftShiftOperator_thenNewDecimalNumber() { - int value = 12; - int leftShift = value << 2; - assertEquals(48, leftShift); - } - - @Test - public void givenOneNegativeInteger_whenLeftShiftOperator_thenNewDecimalNumber() { - int value = -12; - int leftShift = value << 2; - assertEquals(-48, leftShift); - } - - @Test - public void givenOnePositiveInteger_whenUnsignedRightShiftOperator_thenNewDecimalNumber() { - int value = 12; - int unsignedRightShift = value >>> 2; - assertEquals(3, unsignedRightShift); - } - - @Test - public void givenOneNegativeInteger_whenUnsignedRightShiftOperator_thenNewDecimalNumber() { - int value = -12; - int unsignedRightShift = value >>> 2; - assertEquals(1073741821, unsignedRightShift); - } - -} +package com.baeldung.bitwiseoperator.test; + +import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; + +public class BitwiseOperatorUnitTest { + + @Test + public void givenTwoIntegers_whenAndOperator_thenNewDecimalNumber() { + int value1 = 6; + int value2 = 5; + int result = value1 & value2; + assertEquals(4, result); + } + + @Test + public void givenTwoIntegers_whenOrOperator_thenNewDecimalNumber() { + int value1 = 6; + int value2 = 5; + int result = value1 | value2; + assertEquals(7, result); + } + + @Test + public void givenTwoIntegers_whenXorOperator_thenNewDecimalNumber() { + int value1 = 6; + int value2 = 5; + int result = value1 ^ value2; + assertEquals(3, result); + } + + @Test + public void givenOneInteger_whenNotOperator_thenNewDecimalNumber() { + int value1 = 6; + int result = ~value1; + assertEquals(result, -7); + } + + @Test + public void givenOnePositiveInteger_whenSignedRightShiftOperator_thenNewDecimalNumber() { + int value = 12; + int rightShift = value >> 2; + assertEquals(3, rightShift); + } + + @Test + public void givenOneNegativeInteger_whenSignedRightShiftOperator_thenNewDecimalNumber() { + int value = -12; + int rightShift = value >> 2; + assertEquals(-3, rightShift); + } + + @Test + public void givenOnePositiveInteger_whenLeftShiftOperator_thenNewDecimalNumber() { + int value = 12; + int leftShift = value << 2; + assertEquals(48, leftShift); + } + + @Test + public void givenOneNegativeInteger_whenLeftShiftOperator_thenNewDecimalNumber() { + int value = -12; + int leftShift = value << 2; + assertEquals(-48, leftShift); + } + + @Test + public void givenOnePositiveInteger_whenUnsignedRightShiftOperator_thenNewDecimalNumber() { + int value = 12; + int unsignedRightShift = value >>> 2; + assertEquals(3, unsignedRightShift); + } + + @Test + public void givenOneNegativeInteger_whenUnsignedRightShiftOperator_thenNewDecimalNumber() { + int value = -12; + int unsignedRightShift = value >>> 2; + assertEquals(1073741821, unsignedRightShift); + } + +} diff --git a/core-java/src/test/java/com/baeldung/classloader/CustomClassLoaderUnitTest.java b/core-java-modules/core-java/src/test/java/com/baeldung/classloader/CustomClassLoaderUnitTest.java similarity index 100% rename from core-java/src/test/java/com/baeldung/classloader/CustomClassLoaderUnitTest.java rename to core-java-modules/core-java/src/test/java/com/baeldung/classloader/CustomClassLoaderUnitTest.java diff --git a/core-java/src/test/java/com/baeldung/classloader/PrintClassLoaderUnitTest.java b/core-java-modules/core-java/src/test/java/com/baeldung/classloader/PrintClassLoaderUnitTest.java similarity index 100% rename from core-java/src/test/java/com/baeldung/classloader/PrintClassLoaderUnitTest.java rename to core-java-modules/core-java/src/test/java/com/baeldung/classloader/PrintClassLoaderUnitTest.java diff --git a/core-java/src/test/java/com/baeldung/curltojava/JavaCurlExamplesLiveTest.java b/core-java-modules/core-java/src/test/java/com/baeldung/curltojava/JavaCurlExamplesLiveTest.java similarity index 100% rename from core-java/src/test/java/com/baeldung/curltojava/JavaCurlExamplesLiveTest.java rename to core-java-modules/core-java/src/test/java/com/baeldung/curltojava/JavaCurlExamplesLiveTest.java diff --git a/core-java/src/test/java/com/baeldung/deserialization/DeserializationUnitTest.java b/core-java-modules/core-java/src/test/java/com/baeldung/deserialization/DeserializationUnitTest.java similarity index 100% rename from core-java/src/test/java/com/baeldung/deserialization/DeserializationUnitTest.java rename to core-java-modules/core-java/src/test/java/com/baeldung/deserialization/DeserializationUnitTest.java diff --git a/core-java/src/test/java/com/baeldung/encoding/CharacterEncodingExamplesUnitTest.java b/core-java-modules/core-java/src/test/java/com/baeldung/encoding/CharacterEncodingExamplesUnitTest.java similarity index 100% rename from core-java/src/test/java/com/baeldung/encoding/CharacterEncodingExamplesUnitTest.java rename to core-java-modules/core-java/src/test/java/com/baeldung/encoding/CharacterEncodingExamplesUnitTest.java diff --git a/core-java/src/test/java/com/baeldung/exceptions/GlobalExceptionHandlerUnitTest.java b/core-java-modules/core-java/src/test/java/com/baeldung/exceptions/GlobalExceptionHandlerUnitTest.java similarity index 100% rename from core-java/src/test/java/com/baeldung/exceptions/GlobalExceptionHandlerUnitTest.java rename to core-java-modules/core-java/src/test/java/com/baeldung/exceptions/GlobalExceptionHandlerUnitTest.java diff --git a/core-java-modules/core-java/src/test/java/com/baeldung/exceptions/RootCauseFinderUnitTest.java b/core-java-modules/core-java/src/test/java/com/baeldung/exceptions/RootCauseFinderUnitTest.java new file mode 100644 index 0000000000..5d0f3b9c3e --- /dev/null +++ b/core-java-modules/core-java/src/test/java/com/baeldung/exceptions/RootCauseFinderUnitTest.java @@ -0,0 +1,114 @@ +package com.baeldung.exceptions; + +import com.google.common.base.Throwables; +import org.apache.commons.lang3.exception.ExceptionUtils; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +import java.time.LocalDate; +import java.time.format.DateTimeParseException; +import java.time.temporal.ChronoUnit; + +import static com.baeldung.exceptions.RootCauseFinder.*; +import static org.junit.jupiter.api.Assertions.assertTrue; + +/** + * Tests the {@link RootCauseFinder}. + */ +public class RootCauseFinderUnitTest { + + @Test + public void givenBirthDate_whenCalculatingAge_thenAgeReturned() { + try { + int age = AgeCalculator.calculateAge("1990-01-01"); + Assertions.assertEquals(1990, LocalDate + .now() + .minus(age, ChronoUnit.YEARS) + .getYear()); + } catch (CalculationException e) { + Assertions.fail(e.getMessage()); + } + } + + @Test + public void givenWrongFormatDate_whenFindingRootCauseUsingJava_thenRootCauseFound() { + try { + AgeCalculator.calculateAge("010102"); + } catch (CalculationException ex) { + assertTrue(findCauseUsingPlainJava(ex) instanceof DateTimeParseException); + } + } + + @Test + public void givenOutOfRangeDate_whenFindingRootCauseUsingJava_thenRootCauseFound() { + try { + AgeCalculator.calculateAge("2020-04-04"); + } catch (CalculationException ex) { + assertTrue(findCauseUsingPlainJava(ex) instanceof DateOutOfRangeException); + } + } + + @Test + public void givenNullDate_whenFindingRootCauseUsingJava_thenRootCauseFound() { + try { + AgeCalculator.calculateAge(null); + } catch (Exception ex) { + assertTrue(findCauseUsingPlainJava(ex) instanceof IllegalArgumentException); + } + } + + @Test + public void givenWrongFormatDate_whenFindingRootCauseUsingApacheCommons_thenRootCauseFound() { + try { + AgeCalculator.calculateAge("010102"); + } catch (CalculationException ex) { + assertTrue(ExceptionUtils.getRootCause(ex) instanceof DateTimeParseException); + } + } + + @Test + public void givenOutOfRangeDate_whenFindingRootCauseUsingApacheCommons_thenRootCauseFound() { + try { + AgeCalculator.calculateAge("2020-04-04"); + } catch (CalculationException ex) { + assertTrue(ExceptionUtils.getRootCause(ex) instanceof DateOutOfRangeException); + } + } + + @Test + public void givenNullDate_whenFindingRootCauseUsingApacheCommons_thenRootCauseNotFound() { + try { + AgeCalculator.calculateAge(null); + } catch (Exception ex) { + assertTrue(ExceptionUtils.getRootCause(ex) instanceof IllegalArgumentException); + } + } + + @Test + public void givenWrongFormatDate_whenFindingRootCauseUsingGuava_thenRootCauseFound() { + try { + AgeCalculator.calculateAge("010102"); + } catch (CalculationException ex) { + assertTrue(Throwables.getRootCause(ex) instanceof DateTimeParseException); + } + } + + @Test + public void givenOutOfRangeDate_whenFindingRootCauseUsingGuava_thenRootCauseFound() { + try { + AgeCalculator.calculateAge("2020-04-04"); + } catch (CalculationException ex) { + assertTrue(Throwables.getRootCause(ex) instanceof DateOutOfRangeException); + } + } + + @Test + public void givenNullDate_whenFindingRootCauseUsingGuava_thenRootCauseFound() { + try { + AgeCalculator.calculateAge(null); + } catch (Exception ex) { + assertTrue(Throwables.getRootCause(ex) instanceof IllegalArgumentException); + } + } + +} diff --git a/core-java/src/test/java/com/baeldung/externalizable/ExternalizableUnitTest.java b/core-java-modules/core-java/src/test/java/com/baeldung/externalizable/ExternalizableUnitTest.java similarity index 100% rename from core-java/src/test/java/com/baeldung/externalizable/ExternalizableUnitTest.java rename to core-java-modules/core-java/src/test/java/com/baeldung/externalizable/ExternalizableUnitTest.java diff --git a/core-java/src/test/java/com/baeldung/fileparser/BufferedReaderUnitTest.java b/core-java-modules/core-java/src/test/java/com/baeldung/fileparser/BufferedReaderUnitTest.java similarity index 100% rename from core-java/src/test/java/com/baeldung/fileparser/BufferedReaderUnitTest.java rename to core-java-modules/core-java/src/test/java/com/baeldung/fileparser/BufferedReaderUnitTest.java diff --git a/core-java/src/test/java/com/baeldung/fileparser/FileReaderUnitTest.java b/core-java-modules/core-java/src/test/java/com/baeldung/fileparser/FileReaderUnitTest.java similarity index 100% rename from core-java/src/test/java/com/baeldung/fileparser/FileReaderUnitTest.java rename to core-java-modules/core-java/src/test/java/com/baeldung/fileparser/FileReaderUnitTest.java diff --git a/core-java/src/test/java/com/baeldung/fileparser/FilesReadAllLinesUnitTest.java b/core-java-modules/core-java/src/test/java/com/baeldung/fileparser/FilesReadAllLinesUnitTest.java similarity index 100% rename from core-java/src/test/java/com/baeldung/fileparser/FilesReadAllLinesUnitTest.java rename to core-java-modules/core-java/src/test/java/com/baeldung/fileparser/FilesReadAllLinesUnitTest.java diff --git a/core-java/src/test/java/com/baeldung/fileparser/ScannerIntUnitTest.java b/core-java-modules/core-java/src/test/java/com/baeldung/fileparser/ScannerIntUnitTest.java similarity index 100% rename from core-java/src/test/java/com/baeldung/fileparser/ScannerIntUnitTest.java rename to core-java-modules/core-java/src/test/java/com/baeldung/fileparser/ScannerIntUnitTest.java diff --git a/core-java/src/test/java/com/baeldung/fileparser/ScannerStringUnitTest.java b/core-java-modules/core-java/src/test/java/com/baeldung/fileparser/ScannerStringUnitTest.java similarity index 100% rename from core-java/src/test/java/com/baeldung/fileparser/ScannerStringUnitTest.java rename to core-java-modules/core-java/src/test/java/com/baeldung/fileparser/ScannerStringUnitTest.java diff --git a/core-java/src/test/java/com/baeldung/graph/GraphTraversalUnitTest.java b/core-java-modules/core-java/src/test/java/com/baeldung/graph/GraphTraversalUnitTest.java similarity index 100% rename from core-java/src/test/java/com/baeldung/graph/GraphTraversalUnitTest.java rename to core-java-modules/core-java/src/test/java/com/baeldung/graph/GraphTraversalUnitTest.java diff --git a/core-java/src/test/java/com/baeldung/grep/GrepWithUnix4JIntegrationTest.java b/core-java-modules/core-java/src/test/java/com/baeldung/grep/GrepWithUnix4JIntegrationTest.java similarity index 100% rename from core-java/src/test/java/com/baeldung/grep/GrepWithUnix4JIntegrationTest.java rename to core-java-modules/core-java/src/test/java/com/baeldung/grep/GrepWithUnix4JIntegrationTest.java diff --git a/core-java/src/test/java/com/baeldung/hexToAscii/HexToAsciiUnitTest.java b/core-java-modules/core-java/src/test/java/com/baeldung/hexToAscii/HexToAsciiUnitTest.java similarity index 100% rename from core-java/src/test/java/com/baeldung/hexToAscii/HexToAsciiUnitTest.java rename to core-java-modules/core-java/src/test/java/com/baeldung/hexToAscii/HexToAsciiUnitTest.java diff --git a/core-java/src/test/java/com/baeldung/hexToAscii/README.md b/core-java-modules/core-java/src/test/java/com/baeldung/hexToAscii/README.md similarity index 100% rename from core-java/src/test/java/com/baeldung/hexToAscii/README.md rename to core-java-modules/core-java/src/test/java/com/baeldung/hexToAscii/README.md diff --git a/core-java/src/test/java/com/baeldung/java/clock/ClockUnitTest.java b/core-java-modules/core-java/src/test/java/com/baeldung/java/clock/ClockUnitTest.java similarity index 100% rename from core-java/src/test/java/com/baeldung/java/clock/ClockUnitTest.java rename to core-java-modules/core-java/src/test/java/com/baeldung/java/clock/ClockUnitTest.java diff --git a/core-java/src/test/java/com/baeldung/java/currentmethod/CurrentlyExecutedMethodFinderUnitTest.java b/core-java-modules/core-java/src/test/java/com/baeldung/java/currentmethod/CurrentlyExecutedMethodFinderUnitTest.java similarity index 100% rename from core-java/src/test/java/com/baeldung/java/currentmethod/CurrentlyExecutedMethodFinderUnitTest.java rename to core-java-modules/core-java/src/test/java/com/baeldung/java/currentmethod/CurrentlyExecutedMethodFinderUnitTest.java diff --git a/core-java/src/test/java/com/baeldung/java/properties/PropertiesUnitTest.java b/core-java-modules/core-java/src/test/java/com/baeldung/java/properties/PropertiesUnitTest.java similarity index 100% rename from core-java/src/test/java/com/baeldung/java/properties/PropertiesUnitTest.java rename to core-java-modules/core-java/src/test/java/com/baeldung/java/properties/PropertiesUnitTest.java diff --git a/core-java/src/test/java/com/baeldung/java/regex/RegexUnitTest.java b/core-java-modules/core-java/src/test/java/com/baeldung/java/regex/RegexUnitTest.java similarity index 100% rename from core-java/src/test/java/com/baeldung/java/regex/RegexUnitTest.java rename to core-java-modules/core-java/src/test/java/com/baeldung/java/regex/RegexUnitTest.java diff --git a/core-java/src/test/java/com/baeldung/java8/Java8MapAndFlatMap.java b/core-java-modules/core-java/src/test/java/com/baeldung/java8/Java8MapAndFlatMap.java similarity index 100% rename from core-java/src/test/java/com/baeldung/java8/Java8MapAndFlatMap.java rename to core-java-modules/core-java/src/test/java/com/baeldung/java8/Java8MapAndFlatMap.java diff --git a/core-java/src/test/java/com/baeldung/junit4vstestng/DivisibilityUnitTest.java b/core-java-modules/core-java/src/test/java/com/baeldung/junit4vstestng/DivisibilityUnitTest.java similarity index 100% rename from core-java/src/test/java/com/baeldung/junit4vstestng/DivisibilityUnitTest.java rename to core-java-modules/core-java/src/test/java/com/baeldung/junit4vstestng/DivisibilityUnitTest.java diff --git a/core-java/src/test/java/com/baeldung/junit4vstestng/ParametrizedUnitTest.java b/core-java-modules/core-java/src/test/java/com/baeldung/junit4vstestng/ParametrizedUnitTest.java similarity index 100% rename from core-java/src/test/java/com/baeldung/junit4vstestng/ParametrizedUnitTest.java rename to core-java-modules/core-java/src/test/java/com/baeldung/junit4vstestng/ParametrizedUnitTest.java diff --git a/core-java/src/test/java/com/baeldung/junit4vstestng/RegistrationUnitTest.java b/core-java-modules/core-java/src/test/java/com/baeldung/junit4vstestng/RegistrationUnitTest.java similarity index 100% rename from core-java/src/test/java/com/baeldung/junit4vstestng/RegistrationUnitTest.java rename to core-java-modules/core-java/src/test/java/com/baeldung/junit4vstestng/RegistrationUnitTest.java diff --git a/core-java/src/test/java/com/baeldung/junit4vstestng/SignInUnitTest.java b/core-java-modules/core-java/src/test/java/com/baeldung/junit4vstestng/SignInUnitTest.java similarity index 100% rename from core-java/src/test/java/com/baeldung/junit4vstestng/SignInUnitTest.java rename to core-java-modules/core-java/src/test/java/com/baeldung/junit4vstestng/SignInUnitTest.java diff --git a/core-java/src/test/java/com/baeldung/junit4vstestng/StringCaseUnitTest.java b/core-java-modules/core-java/src/test/java/com/baeldung/junit4vstestng/StringCaseUnitTest.java similarity index 100% rename from core-java/src/test/java/com/baeldung/junit4vstestng/StringCaseUnitTest.java rename to core-java-modules/core-java/src/test/java/com/baeldung/junit4vstestng/StringCaseUnitTest.java diff --git a/core-java/src/test/java/com/baeldung/junit4vstestng/SuiteUnitTest.java b/core-java-modules/core-java/src/test/java/com/baeldung/junit4vstestng/SuiteUnitTest.java similarity index 100% rename from core-java/src/test/java/com/baeldung/junit4vstestng/SuiteUnitTest.java rename to core-java-modules/core-java/src/test/java/com/baeldung/junit4vstestng/SuiteUnitTest.java diff --git a/core-java/src/test/java/com/baeldung/leapyear/LeapYearUnitTest.java b/core-java-modules/core-java/src/test/java/com/baeldung/leapyear/LeapYearUnitTest.java similarity index 100% rename from core-java/src/test/java/com/baeldung/leapyear/LeapYearUnitTest.java rename to core-java-modules/core-java/src/test/java/com/baeldung/leapyear/LeapYearUnitTest.java diff --git a/core-java/src/test/java/com/baeldung/manifest/ExecuteJarFileUnitTest.java b/core-java-modules/core-java/src/test/java/com/baeldung/manifest/ExecuteJarFileUnitTest.java similarity index 100% rename from core-java/src/test/java/com/baeldung/manifest/ExecuteJarFileUnitTest.java rename to core-java-modules/core-java/src/test/java/com/baeldung/manifest/ExecuteJarFileUnitTest.java diff --git a/core-java/src/test/java/com/baeldung/money/JavaMoneyUnitManualTest.java b/core-java-modules/core-java/src/test/java/com/baeldung/money/JavaMoneyUnitManualTest.java similarity index 100% rename from core-java/src/test/java/com/baeldung/money/JavaMoneyUnitManualTest.java rename to core-java-modules/core-java/src/test/java/com/baeldung/money/JavaMoneyUnitManualTest.java diff --git a/core-java/src/test/java/com/baeldung/printscreen/ScreenshotLiveTest.java b/core-java-modules/core-java/src/test/java/com/baeldung/printscreen/ScreenshotLiveTest.java similarity index 100% rename from core-java/src/test/java/com/baeldung/printscreen/ScreenshotLiveTest.java rename to core-java-modules/core-java/src/test/java/com/baeldung/printscreen/ScreenshotLiveTest.java diff --git a/core-java/src/test/java/com/baeldung/properties/MergePropertiesUnitTest.java b/core-java-modules/core-java/src/test/java/com/baeldung/properties/MergePropertiesUnitTest.java similarity index 97% rename from core-java/src/test/java/com/baeldung/properties/MergePropertiesUnitTest.java rename to core-java-modules/core-java/src/test/java/com/baeldung/properties/MergePropertiesUnitTest.java index 8720aff36b..50daaed950 100644 --- a/core-java/src/test/java/com/baeldung/properties/MergePropertiesUnitTest.java +++ b/core-java-modules/core-java/src/test/java/com/baeldung/properties/MergePropertiesUnitTest.java @@ -1,84 +1,84 @@ -package com.baeldung.properties; - -import static org.hamcrest.CoreMatchers.equalTo; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertThat; - -import java.util.Map; -import java.util.Properties; -import java.util.Set; -import java.util.stream.Stream; - -import org.junit.Test; - -public class MergePropertiesUnitTest { - - @Test - public void givenTwoProperties_whenMergedUsingIteration_thenAllPropertiesInResult() { - Properties globalProperties = mergePropertiesByIteratingKeySet(propertiesA(), propertiesB()); - - testMergedProperties(globalProperties); - } - - @Test - public void givenTwoProperties_whenMergedUsingPutAll_thenAllPropertiesInResult() { - Properties globalProperties = mergePropertiesByUsingPutAll(propertiesA(), propertiesB()); - - testMergedProperties(globalProperties); - } - - @Test - public void givenTwoProperties_whenMergedUsingStreamAPI_thenAllPropertiesInResult() { - Properties globalProperties = mergePropertiesByUsingStreamApi(propertiesB(), propertiesA()); - - testMergedProperties(globalProperties); - } - - private Properties mergePropertiesByIteratingKeySet(Properties... properties) { - Properties mergedProperties = new Properties(); - for (Properties property : properties) { - Set propertyNames = property.stringPropertyNames(); - for (String name : propertyNames) { - String propertyValue = property.getProperty(name); - mergedProperties.setProperty(name, propertyValue); - } - } - return mergedProperties; - } - - private Properties mergePropertiesByUsingPutAll(Properties... properties) { - Properties mergedProperties = new Properties(); - for (Properties property : properties) { - mergedProperties.putAll(property); - } - return mergedProperties; - } - - private Properties mergePropertiesByUsingStreamApi(Properties... properties) { - return Stream.of(properties) - .collect(Properties::new, Map::putAll, Map::putAll); - } - - private Properties propertiesA() { - Properties properties = new Properties(); - properties.setProperty("application.name", "my-app"); - properties.setProperty("application.version", "1.0"); - return properties; - } - - private Properties propertiesB() { - Properties properties = new Properties(); - properties.setProperty("property-1", "sample property"); - properties.setProperty("property-2", "another sample property"); - return properties; - } - - private void testMergedProperties(Properties globalProperties) { - assertThat("There should be 4 properties", globalProperties.size(), equalTo(4)); - assertEquals("Property should be", globalProperties.getProperty("application.name"), "my-app"); - assertEquals("Property should be", globalProperties.getProperty("application.version"), "1.0"); - assertEquals("Property should be", globalProperties.getProperty("property-1"), "sample property"); - assertEquals("Property should be", globalProperties.getProperty("property-2"), "another sample property"); - } - -} +package com.baeldung.properties; + +import static org.hamcrest.CoreMatchers.equalTo; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThat; + +import java.util.Map; +import java.util.Properties; +import java.util.Set; +import java.util.stream.Stream; + +import org.junit.Test; + +public class MergePropertiesUnitTest { + + @Test + public void givenTwoProperties_whenMergedUsingIteration_thenAllPropertiesInResult() { + Properties globalProperties = mergePropertiesByIteratingKeySet(propertiesA(), propertiesB()); + + testMergedProperties(globalProperties); + } + + @Test + public void givenTwoProperties_whenMergedUsingPutAll_thenAllPropertiesInResult() { + Properties globalProperties = mergePropertiesByUsingPutAll(propertiesA(), propertiesB()); + + testMergedProperties(globalProperties); + } + + @Test + public void givenTwoProperties_whenMergedUsingStreamAPI_thenAllPropertiesInResult() { + Properties globalProperties = mergePropertiesByUsingStreamApi(propertiesB(), propertiesA()); + + testMergedProperties(globalProperties); + } + + private Properties mergePropertiesByIteratingKeySet(Properties... properties) { + Properties mergedProperties = new Properties(); + for (Properties property : properties) { + Set propertyNames = property.stringPropertyNames(); + for (String name : propertyNames) { + String propertyValue = property.getProperty(name); + mergedProperties.setProperty(name, propertyValue); + } + } + return mergedProperties; + } + + private Properties mergePropertiesByUsingPutAll(Properties... properties) { + Properties mergedProperties = new Properties(); + for (Properties property : properties) { + mergedProperties.putAll(property); + } + return mergedProperties; + } + + private Properties mergePropertiesByUsingStreamApi(Properties... properties) { + return Stream.of(properties) + .collect(Properties::new, Map::putAll, Map::putAll); + } + + private Properties propertiesA() { + Properties properties = new Properties(); + properties.setProperty("application.name", "my-app"); + properties.setProperty("application.version", "1.0"); + return properties; + } + + private Properties propertiesB() { + Properties properties = new Properties(); + properties.setProperty("property-1", "sample property"); + properties.setProperty("property-2", "another sample property"); + return properties; + } + + private void testMergedProperties(Properties globalProperties) { + assertThat("There should be 4 properties", globalProperties.size(), equalTo(4)); + assertEquals("Property should be", globalProperties.getProperty("application.name"), "my-app"); + assertEquals("Property should be", globalProperties.getProperty("application.version"), "1.0"); + assertEquals("Property should be", globalProperties.getProperty("property-1"), "sample property"); + assertEquals("Property should be", globalProperties.getProperty("property-2"), "another sample property"); + } + +} diff --git a/core-java/src/test/java/com/baeldung/reflection/BaeldungReflectionUtilsUnitTest.java b/core-java-modules/core-java/src/test/java/com/baeldung/reflection/BaeldungReflectionUtilsUnitTest.java similarity index 100% rename from core-java/src/test/java/com/baeldung/reflection/BaeldungReflectionUtilsUnitTest.java rename to core-java-modules/core-java/src/test/java/com/baeldung/reflection/BaeldungReflectionUtilsUnitTest.java diff --git a/core-java/src/test/java/com/baeldung/reflection/PersonAndEmployeeReflectionUnitTest.java b/core-java-modules/core-java/src/test/java/com/baeldung/reflection/PersonAndEmployeeReflectionUnitTest.java similarity index 100% rename from core-java/src/test/java/com/baeldung/reflection/PersonAndEmployeeReflectionUnitTest.java rename to core-java-modules/core-java/src/test/java/com/baeldung/reflection/PersonAndEmployeeReflectionUnitTest.java diff --git a/core-java/src/test/java/com/baeldung/regexp/EscapingCharsUnitTest.java b/core-java-modules/core-java/src/test/java/com/baeldung/regexp/EscapingCharsUnitTest.java similarity index 100% rename from core-java/src/test/java/com/baeldung/regexp/EscapingCharsUnitTest.java rename to core-java-modules/core-java/src/test/java/com/baeldung/regexp/EscapingCharsUnitTest.java diff --git a/core-java/src/test/java/com/baeldung/regexp/optmization/OptimizedMatcherManualTest.java b/core-java-modules/core-java/src/test/java/com/baeldung/regexp/optmization/OptimizedMatcherManualTest.java similarity index 100% rename from core-java/src/test/java/com/baeldung/regexp/optmization/OptimizedMatcherManualTest.java rename to core-java-modules/core-java/src/test/java/com/baeldung/regexp/optmization/OptimizedMatcherManualTest.java diff --git a/core-java/src/test/java/com/baeldung/resourcebundle/ExampleResourceUnitTest.java b/core-java-modules/core-java/src/test/java/com/baeldung/resourcebundle/ExampleResourceUnitTest.java similarity index 100% rename from core-java/src/test/java/com/baeldung/resourcebundle/ExampleResourceUnitTest.java rename to core-java-modules/core-java/src/test/java/com/baeldung/resourcebundle/ExampleResourceUnitTest.java diff --git a/core-java/src/test/java/com/baeldung/resourcebundle/PropertyResourceUnitTest.java b/core-java-modules/core-java/src/test/java/com/baeldung/resourcebundle/PropertyResourceUnitTest.java similarity index 100% rename from core-java/src/test/java/com/baeldung/resourcebundle/PropertyResourceUnitTest.java rename to core-java-modules/core-java/src/test/java/com/baeldung/resourcebundle/PropertyResourceUnitTest.java diff --git a/core-java/src/test/java/com/baeldung/scripting/NashornUnitTest.java b/core-java-modules/core-java/src/test/java/com/baeldung/scripting/NashornUnitTest.java similarity index 100% rename from core-java/src/test/java/com/baeldung/scripting/NashornUnitTest.java rename to core-java-modules/core-java/src/test/java/com/baeldung/scripting/NashornUnitTest.java diff --git a/core-java/src/test/java/com/baeldung/serialization/PersonUnitTest.java b/core-java-modules/core-java/src/test/java/com/baeldung/serialization/PersonUnitTest.java similarity index 100% rename from core-java/src/test/java/com/baeldung/serialization/PersonUnitTest.java rename to core-java-modules/core-java/src/test/java/com/baeldung/serialization/PersonUnitTest.java diff --git a/core-java/src/test/java/com/baeldung/stack/StackUnitTest.java b/core-java-modules/core-java/src/test/java/com/baeldung/stack/StackUnitTest.java similarity index 100% rename from core-java/src/test/java/com/baeldung/stack/StackUnitTest.java rename to core-java-modules/core-java/src/test/java/com/baeldung/stack/StackUnitTest.java diff --git a/core-java/src/test/java/com/baeldung/stringisnumeric.zip b/core-java-modules/core-java/src/test/java/com/baeldung/stringisnumeric.zip similarity index 100% rename from core-java/src/test/java/com/baeldung/stringisnumeric.zip rename to core-java-modules/core-java/src/test/java/com/baeldung/stringisnumeric.zip diff --git a/core-java/src/test/java/com/baeldung/system/WhenDetectingOSUnitTest.java b/core-java-modules/core-java/src/test/java/com/baeldung/system/WhenDetectingOSUnitTest.java similarity index 100% rename from core-java/src/test/java/com/baeldung/system/WhenDetectingOSUnitTest.java rename to core-java-modules/core-java/src/test/java/com/baeldung/system/WhenDetectingOSUnitTest.java diff --git a/core-java/src/test/java/com/baeldung/util/PropertiesLoaderUnitTest.java b/core-java-modules/core-java/src/test/java/com/baeldung/util/PropertiesLoaderUnitTest.java similarity index 100% rename from core-java/src/test/java/com/baeldung/util/PropertiesLoaderUnitTest.java rename to core-java-modules/core-java/src/test/java/com/baeldung/util/PropertiesLoaderUnitTest.java diff --git a/core-java/src/test/java/org/baeldung/java/JavaIoUnitTest.java b/core-java-modules/core-java/src/test/java/org/baeldung/java/JavaIoUnitTest.java similarity index 100% rename from core-java/src/test/java/org/baeldung/java/JavaIoUnitTest.java rename to core-java-modules/core-java/src/test/java/org/baeldung/java/JavaIoUnitTest.java diff --git a/core-java/src/test/java/org/baeldung/java/JavaTimerLongRunningUnitTest.java b/core-java-modules/core-java/src/test/java/org/baeldung/java/JavaTimerLongRunningUnitTest.java similarity index 100% rename from core-java/src/test/java/org/baeldung/java/JavaTimerLongRunningUnitTest.java rename to core-java-modules/core-java/src/test/java/org/baeldung/java/JavaTimerLongRunningUnitTest.java diff --git a/core-java/src/test/java/org/baeldung/java/arrays/ArraysJoinAndSplitJUnitTest.java b/core-java-modules/core-java/src/test/java/org/baeldung/java/arrays/ArraysJoinAndSplitJUnitTest.java similarity index 100% rename from core-java/src/test/java/org/baeldung/java/arrays/ArraysJoinAndSplitJUnitTest.java rename to core-java-modules/core-java/src/test/java/org/baeldung/java/arrays/ArraysJoinAndSplitJUnitTest.java diff --git a/core-java/src/test/java/org/baeldung/java/rawtypes/RawTypesUnitTest.java b/core-java-modules/core-java/src/test/java/org/baeldung/java/rawtypes/RawTypesUnitTest.java similarity index 100% rename from core-java/src/test/java/org/baeldung/java/rawtypes/RawTypesUnitTest.java rename to core-java-modules/core-java/src/test/java/org/baeldung/java/rawtypes/RawTypesUnitTest.java diff --git a/core-java/src/test/java/org/baeldung/java/sandbox/SandboxJavaManualTest.java b/core-java-modules/core-java/src/test/java/org/baeldung/java/sandbox/SandboxJavaManualTest.java similarity index 100% rename from core-java/src/test/java/org/baeldung/java/sandbox/SandboxJavaManualTest.java rename to core-java-modules/core-java/src/test/java/org/baeldung/java/sandbox/SandboxJavaManualTest.java diff --git a/core-java/src/test/java/org/baeldung/java/shell/JavaProcessUnitIntegrationTest.java b/core-java-modules/core-java/src/test/java/org/baeldung/java/shell/JavaProcessUnitIntegrationTest.java similarity index 100% rename from core-java/src/test/java/org/baeldung/java/shell/JavaProcessUnitIntegrationTest.java rename to core-java-modules/core-java/src/test/java/org/baeldung/java/shell/JavaProcessUnitIntegrationTest.java diff --git a/core-java/src/test/resources/.gitignore b/core-java-modules/core-java/src/test/resources/.gitignore similarity index 100% rename from core-java/src/test/resources/.gitignore rename to core-java-modules/core-java/src/test/resources/.gitignore diff --git a/core-java/src/test/resources/app.properties b/core-java-modules/core-java/src/test/resources/app.properties similarity index 100% rename from core-java/src/test/resources/app.properties rename to core-java-modules/core-java/src/test/resources/app.properties diff --git a/core-java/src/test/resources/catalog b/core-java-modules/core-java/src/test/resources/catalog similarity index 100% rename from core-java/src/test/resources/catalog rename to core-java-modules/core-java/src/test/resources/catalog diff --git a/core-java/src/test/resources/configuration.properties b/core-java-modules/core-java/src/test/resources/configuration.properties similarity index 100% rename from core-java/src/test/resources/configuration.properties rename to core-java-modules/core-java/src/test/resources/configuration.properties diff --git a/core-java/src/test/resources/default.properties b/core-java-modules/core-java/src/test/resources/default.properties similarity index 100% rename from core-java/src/test/resources/default.properties rename to core-java-modules/core-java/src/test/resources/default.properties diff --git a/core-java/src/test/resources/dictionary.in b/core-java-modules/core-java/src/test/resources/dictionary.in similarity index 100% rename from core-java/src/test/resources/dictionary.in rename to core-java-modules/core-java/src/test/resources/dictionary.in diff --git a/core-java/src/test/resources/encoding.txt b/core-java-modules/core-java/src/test/resources/encoding.txt similarity index 100% rename from core-java/src/test/resources/encoding.txt rename to core-java-modules/core-java/src/test/resources/encoding.txt diff --git a/core-java/src/test/resources/icons.xml b/core-java-modules/core-java/src/test/resources/icons.xml similarity index 100% rename from core-java/src/test/resources/icons.xml rename to core-java-modules/core-java/src/test/resources/icons.xml diff --git a/core-java/src/test/resources/newFile1.txt b/core-java-modules/core-java/src/test/resources/newFile1.txt similarity index 100% rename from core-java/src/test/resources/newFile1.txt rename to core-java-modules/core-java/src/test/resources/newFile1.txt diff --git a/core-java/src/test/resources/newFile2.txt b/core-java-modules/core-java/src/test/resources/newFile2.txt similarity index 100% rename from core-java/src/test/resources/newFile2.txt rename to core-java-modules/core-java/src/test/resources/newFile2.txt diff --git a/core-java/src/test/resources/newFile3.txt b/core-java-modules/core-java/src/test/resources/newFile3.txt similarity index 100% rename from core-java/src/test/resources/newFile3.txt rename to core-java-modules/core-java/src/test/resources/newFile3.txt diff --git a/core-java/src/test/resources/original.txt b/core-java-modules/core-java/src/test/resources/original.txt similarity index 98% rename from core-java/src/test/resources/original.txt rename to core-java-modules/core-java/src/test/resources/original.txt index cf8c89d389..8511f56bef 100644 --- a/core-java/src/test/resources/original.txt +++ b/core-java-modules/core-java/src/test/resources/original.txt @@ -1,2 +1,2 @@ -#Copy a File with Java (www.Baeldung.com) +#Copy a File with Java (www.Baeldung.com) Copying Files with Java is Fun! \ No newline at end of file diff --git a/core-java/src/test/resources/sampleNumberFile.txt b/core-java-modules/core-java/src/test/resources/sampleNumberFile.txt similarity index 100% rename from core-java/src/test/resources/sampleNumberFile.txt rename to core-java-modules/core-java/src/test/resources/sampleNumberFile.txt diff --git a/core-java/src/test/resources/sampleTextFile.txt b/core-java-modules/core-java/src/test/resources/sampleTextFile.txt similarity index 100% rename from core-java/src/test/resources/sampleTextFile.txt rename to core-java-modules/core-java/src/test/resources/sampleTextFile.txt diff --git a/core-java/src/test/resources/sourceFile.txt b/core-java-modules/core-java/src/test/resources/sourceFile.txt similarity index 100% rename from core-java/src/test/resources/sourceFile.txt rename to core-java-modules/core-java/src/test/resources/sourceFile.txt diff --git a/core-java/src/test/resources/test.find b/core-java-modules/core-java/src/test/resources/test.find similarity index 100% rename from core-java/src/test/resources/test.find rename to core-java-modules/core-java/src/test/resources/test.find diff --git a/core-java/src/test/resources/test_read.in b/core-java-modules/core-java/src/test/resources/test_read.in similarity index 100% rename from core-java/src/test/resources/test_read.in rename to core-java-modules/core-java/src/test/resources/test_read.in diff --git a/core-java/src/test/resources/test_read1.in b/core-java-modules/core-java/src/test/resources/test_read1.in similarity index 100% rename from core-java/src/test/resources/test_read1.in rename to core-java-modules/core-java/src/test/resources/test_read1.in diff --git a/core-java/src/test/resources/test_read2.in b/core-java-modules/core-java/src/test/resources/test_read2.in similarity index 100% rename from core-java/src/test/resources/test_read2.in rename to core-java-modules/core-java/src/test/resources/test_read2.in diff --git a/core-java/src/test/resources/test_read3.in b/core-java-modules/core-java/src/test/resources/test_read3.in similarity index 100% rename from core-java/src/test/resources/test_read3.in rename to core-java-modules/core-java/src/test/resources/test_read3.in diff --git a/core-java/src/test/resources/test_read4.in b/core-java-modules/core-java/src/test/resources/test_read4.in similarity index 100% rename from core-java/src/test/resources/test_read4.in rename to core-java-modules/core-java/src/test/resources/test_read4.in diff --git a/core-java/src/test/resources/test_read7.in b/core-java-modules/core-java/src/test/resources/test_read7.in similarity index 100% rename from core-java/src/test/resources/test_read7.in rename to core-java-modules/core-java/src/test/resources/test_read7.in diff --git a/core-java/src/test/resources/test_read8.in b/core-java-modules/core-java/src/test/resources/test_read8.in similarity index 100% rename from core-java/src/test/resources/test_read8.in rename to core-java-modules/core-java/src/test/resources/test_read8.in diff --git a/core-java/src/test/resources/test_read_d.in b/core-java-modules/core-java/src/test/resources/test_read_d.in similarity index 100% rename from core-java/src/test/resources/test_read_d.in rename to core-java-modules/core-java/src/test/resources/test_read_d.in diff --git a/core-java/src/test/resources/test_read_multiple.in b/core-java-modules/core-java/src/test/resources/test_read_multiple.in similarity index 100% rename from core-java/src/test/resources/test_read_multiple.in rename to core-java-modules/core-java/src/test/resources/test_read_multiple.in diff --git a/core-java/yofile.txt b/core-java-modules/core-java/yofile.txt similarity index 100% rename from core-java/yofile.txt rename to core-java-modules/core-java/yofile.txt diff --git a/core-java/yofile2.txt b/core-java-modules/core-java/yofile2.txt similarity index 100% rename from core-java/yofile2.txt rename to core-java-modules/core-java/yofile2.txt diff --git a/core-java-modules/multimodulemavenproject/daomodule/pom.xml b/core-java-modules/multimodulemavenproject/daomodule/pom.xml new file mode 100644 index 0000000000..a260e15e6d --- /dev/null +++ b/core-java-modules/multimodulemavenproject/daomodule/pom.xml @@ -0,0 +1,27 @@ + + + 4.0.0 + + com.baeldung.multimodulemavenproject + multimodulemavenproject + 1.0 + + com.baeldung.daomodule + daomodule + 1.0 + jar + + + + + org.apache.maven.plugins + maven-compiler-plugin + + + + + + 9 + 9 + + \ No newline at end of file diff --git a/core-java-modules/multimodulemavenproject/daomodule/src/main/java/com/baeldung/daomodule/Dao.java b/core-java-modules/multimodulemavenproject/daomodule/src/main/java/com/baeldung/daomodule/Dao.java new file mode 100644 index 0000000000..9568bae9d9 --- /dev/null +++ b/core-java-modules/multimodulemavenproject/daomodule/src/main/java/com/baeldung/daomodule/Dao.java @@ -0,0 +1,11 @@ +package com.baeldung.daomodule; +import java.util.List; +import java.util.Optional; + +public interface Dao { + + Optional findById(int id); + + List findAll(); + +} diff --git a/core-java-modules/multimodulemavenproject/daomodule/src/main/java/module-info.java b/core-java-modules/multimodulemavenproject/daomodule/src/main/java/module-info.java new file mode 100644 index 0000000000..20c51d316a --- /dev/null +++ b/core-java-modules/multimodulemavenproject/daomodule/src/main/java/module-info.java @@ -0,0 +1,3 @@ +module com.baeldung.daomodule { + exports com.baeldung.daomodule; +} diff --git a/core-java-modules/multimodulemavenproject/entitymodule/pom.xml b/core-java-modules/multimodulemavenproject/entitymodule/pom.xml new file mode 100644 index 0000000000..1fd672d03e --- /dev/null +++ b/core-java-modules/multimodulemavenproject/entitymodule/pom.xml @@ -0,0 +1,28 @@ + + + 4.0.0 + + com.baeldung.multimodulemavenproject + multimodulemavenproject + 1.0 + + com.baeldung.entitymodule + entitymodule + 1.0 + jar + + + + + org.apache.maven.plugins + maven-compiler-plugin + + + + + + 9 + 9 + + + \ No newline at end of file diff --git a/core-java-modules/multimodulemavenproject/entitymodule/src/main/java/com/baeldung/entitymodule/User.java b/core-java-modules/multimodulemavenproject/entitymodule/src/main/java/com/baeldung/entitymodule/User.java new file mode 100644 index 0000000000..c025bffd87 --- /dev/null +++ b/core-java-modules/multimodulemavenproject/entitymodule/src/main/java/com/baeldung/entitymodule/User.java @@ -0,0 +1,19 @@ +package com.baeldung.entitymodule; + +public class User { + + private final String name; + + public User(String name) { + this.name = name; + } + + public String getName() { + return name; + } + + @Override + public String toString() { + return "User{" + "name=" + name + '}'; + } +} \ No newline at end of file diff --git a/core-java-modules/multimodulemavenproject/entitymodule/src/main/java/module-info.java b/core-java-modules/multimodulemavenproject/entitymodule/src/main/java/module-info.java new file mode 100644 index 0000000000..b2c4553357 --- /dev/null +++ b/core-java-modules/multimodulemavenproject/entitymodule/src/main/java/module-info.java @@ -0,0 +1,3 @@ +module com.baeldung.entitymodule { + exports com.baeldung.entitymodule; +} diff --git a/core-java-modules/multimodulemavenproject/mainappmodule/pom.xml b/core-java-modules/multimodulemavenproject/mainappmodule/pom.xml new file mode 100644 index 0000000000..26e6a15b1e --- /dev/null +++ b/core-java-modules/multimodulemavenproject/mainappmodule/pom.xml @@ -0,0 +1,45 @@ + + + 4.0.0 + + com.baeldung.multimodulemavenproject + multimodulemavenproject + 1.0 + + com.baeldung.mainappmodule + mainappmodule + 1.0 + jar + + + + com.baeldung.entitymodule + entitymodule + 1.0 + + + com.baeldung.daomodule + daomodule + 1.0 + + + com.baeldung.userdaomodule + userdaomodule + 1.0 + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + + + + + 9 + 9 + + \ No newline at end of file diff --git a/core-java-modules/multimodulemavenproject/mainappmodule/src/main/java/com/baeldung/mainappmodule/Application.java b/core-java-modules/multimodulemavenproject/mainappmodule/src/main/java/com/baeldung/mainappmodule/Application.java new file mode 100644 index 0000000000..cf0ba1d9bc --- /dev/null +++ b/core-java-modules/multimodulemavenproject/mainappmodule/src/main/java/com/baeldung/mainappmodule/Application.java @@ -0,0 +1,19 @@ +package com.baeldung.mainappmodule; + +import com.baeldung.daomodule.Dao; +import com.baeldung.entitymodule.User; +import com.baeldung.userdaomodule.UserDao; +import java.util.HashMap; +import java.util.Map; + +public class Application { + + public static void main(String args[]) { + Map users = new HashMap<>(); + users.put(1, new User("Julie")); + users.put(2, new User("David")); + Dao userDao = new UserDao(users); + userDao.findAll().forEach(System.out::println); + } + +} diff --git a/core-java-modules/multimodulemavenproject/mainappmodule/src/main/java/module-info.java b/core-java-modules/multimodulemavenproject/mainappmodule/src/main/java/module-info.java new file mode 100644 index 0000000000..dd7620c7bf --- /dev/null +++ b/core-java-modules/multimodulemavenproject/mainappmodule/src/main/java/module-info.java @@ -0,0 +1,8 @@ +module com.baeldung.mainppmodule { + + requires com.baeldung.entitymodule; + requires com.baeldung.daomodule; + requires com.baeldung.userdaomodule; + uses com.baeldung.userdaomodule.UserDao; + +} diff --git a/core-java-modules/multimodulemavenproject/pom.xml b/core-java-modules/multimodulemavenproject/pom.xml new file mode 100644 index 0000000000..3d56f1356b --- /dev/null +++ b/core-java-modules/multimodulemavenproject/pom.xml @@ -0,0 +1,62 @@ + + + 4.0.0 + com.baeldung.multimodulemavenproject + multimodulemavenproject + 1.0 + pom + multimodulemavenproject + + + parent-modules + com.baeldung + 1.0.0-SNAPSHOT + ../../ + + + + + + junit + junit + 4.12 + test + + + org.assertj + assertj-core + 3.12.2 + test + + + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.8.0 + + + 1.9 + 1.9 + + + + + + + + + entitymodule + daomodule + userdaomodule + mainappmodule + + + + UTF-8 + + diff --git a/core-java-modules/multimodulemavenproject/userdaomodule/pom.xml b/core-java-modules/multimodulemavenproject/userdaomodule/pom.xml new file mode 100644 index 0000000000..63968452db --- /dev/null +++ b/core-java-modules/multimodulemavenproject/userdaomodule/pom.xml @@ -0,0 +1,41 @@ + + + 4.0.0 + + com.baeldung.multimodulemavenproject + multimodulemavenproject + 1.0 + + com.baeldung.userdaomodule + userdaomodule + 1.0 + jar + + + + + org.apache.maven.plugins + maven-compiler-plugin + + + + + + + com.baeldung.entitymodule + entitymodule + 1.0 + + + com.baeldung.daomodule + daomodule + 1.0 + + + + + 9 + 9 + + + \ No newline at end of file diff --git a/core-java-modules/multimodulemavenproject/userdaomodule/src/main/java/com/baeldung/userdaomodule/UserDao.java b/core-java-modules/multimodulemavenproject/userdaomodule/src/main/java/com/baeldung/userdaomodule/UserDao.java new file mode 100644 index 0000000000..aba157b431 --- /dev/null +++ b/core-java-modules/multimodulemavenproject/userdaomodule/src/main/java/com/baeldung/userdaomodule/UserDao.java @@ -0,0 +1,32 @@ +package com.baeldung.userdaomodule; + +import com.baeldung.daomodule.Dao; +import com.baeldung.entitymodule.User; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; + +public class UserDao implements Dao { + + private final Map users; + + public UserDao() { + users = new HashMap<>(); + } + + public UserDao(Map users) { + this.users = users; + } + + @Override + public List findAll() { + return new ArrayList<>(users.values()); + } + + @Override + public Optional findById(int id) { + return Optional.ofNullable(users.get(id)); + } +} \ No newline at end of file diff --git a/core-java-modules/multimodulemavenproject/userdaomodule/src/main/java/module-info.java b/core-java-modules/multimodulemavenproject/userdaomodule/src/main/java/module-info.java new file mode 100644 index 0000000000..6dd81dabe5 --- /dev/null +++ b/core-java-modules/multimodulemavenproject/userdaomodule/src/main/java/module-info.java @@ -0,0 +1,6 @@ +module com.baeldung.userdaomodule { + requires com.baeldung.entitymodule; + requires com.baeldung.daomodule; + provides com.baeldung.daomodule.Dao with com.baeldung.userdaomodule.UserDao; + exports com.baeldung.userdaomodule; +} diff --git a/core-java-modules/pom.xml b/core-java-modules/pom.xml index ad49cceb9d..2b563a7be4 100644 --- a/core-java-modules/pom.xml +++ b/core-java-modules/pom.xml @@ -2,6 +2,7 @@ 4.0.0 + com.baeldung.core-java-modules core-java-modules core-java-modules pom @@ -14,6 +15,7 @@ pre-jpms + core-java-exceptions - - \ No newline at end of file + + diff --git a/core-kotlin/src/main/kotlin/com/baeldung/filesystem/FileReader.kt b/core-kotlin/src/main/kotlin/com/baeldung/filesystem/FileReader.kt index 8539378c91..886a3fc51e 100644 --- a/core-kotlin/src/main/kotlin/com/baeldung/filesystem/FileReader.kt +++ b/core-kotlin/src/main/kotlin/com/baeldung/filesystem/FileReader.kt @@ -17,4 +17,8 @@ class FileReader { File(fileName).inputStream().readBytes().toString(Charsets.UTF_8) fun readFileDirectlyAsText(fileName: String): String = File(fileName).readText(Charsets.UTF_8) + + fun readFileUsingGetResource(fileName: String) = this::class.java.getResource(fileName).readText(Charsets.UTF_8) + + fun readFileAsLinesUsingGetResourceAsStream(fileName: String) = this::class.java.getResourceAsStream(fileName).bufferedReader().readLines() } \ No newline at end of file diff --git a/core-kotlin/src/test/kotlin/com/baeldung/filesystem/FileReaderTest.kt b/core-kotlin/src/test/kotlin/com/baeldung/filesystem/FileReaderTest.kt index 67795dda14..ad541c446e 100644 --- a/core-kotlin/src/test/kotlin/com/baeldung/filesystem/FileReaderTest.kt +++ b/core-kotlin/src/test/kotlin/com/baeldung/filesystem/FileReaderTest.kt @@ -48,4 +48,20 @@ internal class FileReaderTest { assertTrue { text.contains("Hello to Kotlin") } } + + @Test + fun whenReadFileAsTextUsingGetResource_thenCorrect() { + val text = fileReader.readFileUsingGetResource("/Kotlin.in") + + assertTrue { text.contains("1. Concise") } + } + + @Test + fun whenReadFileUsingGetResourceAsStream_thenCorrect() { + val lines = fileReader.readFileAsLinesUsingGetResourceAsStream("/Kotlin.in") + + assertTrue { lines.contains("3. Interoperable") } + } + + } \ No newline at end of file diff --git a/ethereum/pom.xml b/ethereum/pom.xml index baa74b58a5..80e1c04676 100644 --- a/ethereum/pom.xml +++ b/ethereum/pom.xml @@ -88,7 +88,7 @@ javax.servlet javax.servlet-api - ${javax-servlet.version} + ${javax.servlet-api.version} javax.servlet.jsp.jstl @@ -98,7 +98,7 @@ javax.servlet.jsp javax.servlet.jsp-api - ${javax-jsp.version} + ${javax.servlet.jsp-api.version} @@ -160,7 +160,7 @@ org.hamcrest hamcrest-library - ${hamcrest.version} + ${org.hamcrest.version} test @@ -213,12 +213,7 @@ 3.3.1 1.5.6.RELEASE 2.21.0 - 1.3 - 2.3.1 - 3.1.0 2.4.0 - 1.2 - 4.12 1.2.3 1.7.25 2.0.4.RELEASE diff --git a/google-cloud/pom.xml b/google-cloud/pom.xml index e39e186f05..ec53b78070 100644 --- a/google-cloud/pom.xml +++ b/google-cloud/pom.xml @@ -30,7 +30,6 @@ - 1.16.18 1.16.0 diff --git a/google-web-toolkit/pom.xml b/google-web-toolkit/pom.xml index f4c6a0ab39..0723cd3be2 100644 --- a/google-web-toolkit/pom.xml +++ b/google-web-toolkit/pom.xml @@ -120,7 +120,6 @@ UTF-8 UTF-8 - 4.11 2.8.2 diff --git a/gson/pom.xml b/gson/pom.xml index 8222cb50e1..a21d783c39 100644 --- a/gson/pom.xml +++ b/gson/pom.xml @@ -67,7 +67,6 @@ 3.5 4.1 2.9.6 - 1.16.10 \ No newline at end of file diff --git a/guest/junit5-example/pom.xml b/guest/junit5-example/pom.xml index 7c0cc3e776..c6370941d1 100644 --- a/guest/junit5-example/pom.xml +++ b/guest/junit5-example/pom.xml @@ -60,7 +60,6 @@ 5.0.0-M4 4.12.0-M4 - 1.4.195 2.8.2 1.0.0-M4 diff --git a/guest/log4j2-example/pom.xml b/guest/log4j2-example/pom.xml index 045ff7325b..31a32a4562 100644 --- a/guest/log4j2-example/pom.xml +++ b/guest/log4j2-example/pom.xml @@ -41,7 +41,6 @@ - 2.9.7 2.8.2 diff --git a/guest/tomcat-app/pom.xml b/guest/tomcat-app/pom.xml index 9ce77c758a..ab18023f70 100644 --- a/guest/tomcat-app/pom.xml +++ b/guest/tomcat-app/pom.xml @@ -31,9 +31,9 @@ ${rest-assured.version} - com.h2database + com.h2 h2 - ${h2database.version} + ${h2.version} runtime @@ -62,7 +62,6 @@ 2.25.1 - 1.4.195 3.0.3 2.8.2 1.69.0 diff --git a/httpclient-simple/README.md b/httpclient-simple/README.md index 492f3bc5b4..e3535a133e 100644 --- a/httpclient-simple/README.md +++ b/httpclient-simple/README.md @@ -1,11 +1,5 @@ ========= -## HttpClient 4.x Cookbooks and Examples - -###The Course -The "REST With Spring" Classes: http://bit.ly/restwithspring - - -### Relevant Articles: +## This module contains articles that are part of the HTTPClient Ebook - [HttpClient 4 – Get the Status Code](http://www.baeldung.com/httpclient-status-code) - [HttpClient with SSL](http://www.baeldung.com/httpclient-ssl) @@ -14,3 +8,9 @@ The "REST With Spring" Classes: http://bit.ly/restwithspring - [Custom HTTP Header with the HttpClient](http://www.baeldung.com/httpclient-custom-http-header) - [HttpClient Basic Authentication](http://www.baeldung.com/httpclient-4-basic-authentication) - [Posting with HttpClient](https://www.baeldung.com/httpclient-post-http-request) + + +### Running the Tests +To run the live tests, use the command: mvn clean install -Plive +This will start an embedded Jetty server on port 8082 using the Cargo plugin configured in the pom.xml file, +for the live Maven profile diff --git a/httpclient-simple/pom.xml b/httpclient-simple/pom.xml index f3d00251d7..efcf0452e2 100644 --- a/httpclient-simple/pom.xml +++ b/httpclient-simple/pom.xml @@ -172,7 +172,7 @@ javax.servlet javax.servlet-api - ${javax.servlet.version} + ${javax.servlet-api.version} provided @@ -295,9 +295,6 @@ - - 1.2 - 3.1.0 19.0 3.5 diff --git a/httpclient-simple/src/main/java/org/baeldung/basic/MyBasicAuthenticationEntryPoint.java b/httpclient-simple/src/main/java/com/baeldung/basic/MyBasicAuthenticationEntryPoint.java similarity index 97% rename from httpclient-simple/src/main/java/org/baeldung/basic/MyBasicAuthenticationEntryPoint.java rename to httpclient-simple/src/main/java/com/baeldung/basic/MyBasicAuthenticationEntryPoint.java index 6e580e7a22..380ff9df6b 100644 --- a/httpclient-simple/src/main/java/org/baeldung/basic/MyBasicAuthenticationEntryPoint.java +++ b/httpclient-simple/src/main/java/com/baeldung/basic/MyBasicAuthenticationEntryPoint.java @@ -1,4 +1,4 @@ -package org.baeldung.basic; +package com.baeldung.basic; import org.springframework.security.core.AuthenticationException; import org.springframework.security.web.authentication.www.BasicAuthenticationEntryPoint; diff --git a/httpclient-simple/src/main/java/org/baeldung/client/HttpComponentsClientHttpRequestFactoryBasicAuth.java b/httpclient-simple/src/main/java/com/baeldung/client/HttpComponentsClientHttpRequestFactoryBasicAuth.java similarity index 97% rename from httpclient-simple/src/main/java/org/baeldung/client/HttpComponentsClientHttpRequestFactoryBasicAuth.java rename to httpclient-simple/src/main/java/com/baeldung/client/HttpComponentsClientHttpRequestFactoryBasicAuth.java index a2f51d343b..81f82a2c1c 100644 --- a/httpclient-simple/src/main/java/org/baeldung/client/HttpComponentsClientHttpRequestFactoryBasicAuth.java +++ b/httpclient-simple/src/main/java/com/baeldung/client/HttpComponentsClientHttpRequestFactoryBasicAuth.java @@ -1,4 +1,4 @@ -package org.baeldung.client; +package com.baeldung.client; import java.net.URI; diff --git a/httpclient-simple/src/main/java/org/baeldung/client/RestTemplateFactory.java b/httpclient-simple/src/main/java/com/baeldung/client/RestTemplateFactory.java similarity index 97% rename from httpclient-simple/src/main/java/org/baeldung/client/RestTemplateFactory.java rename to httpclient-simple/src/main/java/com/baeldung/client/RestTemplateFactory.java index 3ed0bc82b7..aac4f8cebd 100644 --- a/httpclient-simple/src/main/java/org/baeldung/client/RestTemplateFactory.java +++ b/httpclient-simple/src/main/java/com/baeldung/client/RestTemplateFactory.java @@ -1,4 +1,4 @@ -package org.baeldung.client; +package com.baeldung.client; import org.apache.http.HttpHost; import org.springframework.beans.factory.FactoryBean; diff --git a/httpclient-simple/src/main/java/org/baeldung/client/spring/ClientConfig.java b/httpclient-simple/src/main/java/com/baeldung/client/spring/ClientConfig.java similarity index 76% rename from httpclient-simple/src/main/java/org/baeldung/client/spring/ClientConfig.java rename to httpclient-simple/src/main/java/com/baeldung/client/spring/ClientConfig.java index 73e602855c..03994b55a5 100644 --- a/httpclient-simple/src/main/java/org/baeldung/client/spring/ClientConfig.java +++ b/httpclient-simple/src/main/java/com/baeldung/client/spring/ClientConfig.java @@ -1,10 +1,10 @@ -package org.baeldung.client.spring; +package com.baeldung.client.spring; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; @Configuration -@ComponentScan("org.baeldung.client") +@ComponentScan("com.baeldung.client") public class ClientConfig { public ClientConfig() { diff --git a/httpclient-simple/src/main/java/org/baeldung/filter/CustomFilter.java b/httpclient-simple/src/main/java/com/baeldung/filter/CustomFilter.java similarity index 94% rename from httpclient-simple/src/main/java/org/baeldung/filter/CustomFilter.java rename to httpclient-simple/src/main/java/com/baeldung/filter/CustomFilter.java index 01e5b0b59d..6bb12610fa 100644 --- a/httpclient-simple/src/main/java/org/baeldung/filter/CustomFilter.java +++ b/httpclient-simple/src/main/java/com/baeldung/filter/CustomFilter.java @@ -1,4 +1,4 @@ -package org.baeldung.filter; +package com.baeldung.filter; import org.springframework.web.filter.GenericFilterBean; diff --git a/httpclient-simple/src/main/java/org/baeldung/filter/CustomWebSecurityConfigurerAdapter.java b/httpclient-simple/src/main/java/com/baeldung/filter/CustomWebSecurityConfigurerAdapter.java similarity index 95% rename from httpclient-simple/src/main/java/org/baeldung/filter/CustomWebSecurityConfigurerAdapter.java rename to httpclient-simple/src/main/java/com/baeldung/filter/CustomWebSecurityConfigurerAdapter.java index 7ca2a80c52..fb597e46c8 100644 --- a/httpclient-simple/src/main/java/org/baeldung/filter/CustomWebSecurityConfigurerAdapter.java +++ b/httpclient-simple/src/main/java/com/baeldung/filter/CustomWebSecurityConfigurerAdapter.java @@ -1,6 +1,6 @@ -package org.baeldung.filter; +package com.baeldung.filter; -import org.baeldung.security.RestAuthenticationEntryPoint; +import com.baeldung.security.RestAuthenticationEntryPoint; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; diff --git a/httpclient-simple/src/main/java/org/baeldung/security/MySavedRequestAwareAuthenticationSuccessHandler.java b/httpclient-simple/src/main/java/com/baeldung/security/MySavedRequestAwareAuthenticationSuccessHandler.java similarity index 98% rename from httpclient-simple/src/main/java/org/baeldung/security/MySavedRequestAwareAuthenticationSuccessHandler.java rename to httpclient-simple/src/main/java/com/baeldung/security/MySavedRequestAwareAuthenticationSuccessHandler.java index 698052fa2b..7dc53e3e1e 100644 --- a/httpclient-simple/src/main/java/org/baeldung/security/MySavedRequestAwareAuthenticationSuccessHandler.java +++ b/httpclient-simple/src/main/java/com/baeldung/security/MySavedRequestAwareAuthenticationSuccessHandler.java @@ -1,4 +1,4 @@ -package org.baeldung.security; +package com.baeldung.security; import java.io.IOException; diff --git a/httpclient-simple/src/main/java/org/baeldung/security/RestAuthenticationEntryPoint.java b/httpclient-simple/src/main/java/com/baeldung/security/RestAuthenticationEntryPoint.java similarity index 96% rename from httpclient-simple/src/main/java/org/baeldung/security/RestAuthenticationEntryPoint.java rename to httpclient-simple/src/main/java/com/baeldung/security/RestAuthenticationEntryPoint.java index 77aa32ff97..1ae89adb89 100644 --- a/httpclient-simple/src/main/java/org/baeldung/security/RestAuthenticationEntryPoint.java +++ b/httpclient-simple/src/main/java/com/baeldung/security/RestAuthenticationEntryPoint.java @@ -1,4 +1,4 @@ -package org.baeldung.security; +package com.baeldung.security; import java.io.IOException; diff --git a/httpclient-simple/src/main/java/org/baeldung/spring/SecSecurityConfig.java b/httpclient-simple/src/main/java/com/baeldung/spring/SecSecurityConfig.java similarity index 83% rename from httpclient-simple/src/main/java/org/baeldung/spring/SecSecurityConfig.java rename to httpclient-simple/src/main/java/com/baeldung/spring/SecSecurityConfig.java index 4ce80dab9f..4ba9d47f8d 100644 --- a/httpclient-simple/src/main/java/org/baeldung/spring/SecSecurityConfig.java +++ b/httpclient-simple/src/main/java/com/baeldung/spring/SecSecurityConfig.java @@ -1,4 +1,4 @@ -package org.baeldung.spring; +package com.baeldung.spring; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; @@ -6,7 +6,7 @@ import org.springframework.context.annotation.ImportResource; @Configuration @ImportResource({ "classpath:webSecurityConfig.xml" }) -@ComponentScan("org.baeldung.security") +@ComponentScan("com.baeldung.security") public class SecSecurityConfig { public SecSecurityConfig() { diff --git a/httpclient-simple/src/main/java/org/baeldung/spring/WebConfig.java b/httpclient-simple/src/main/java/com/baeldung/spring/WebConfig.java similarity index 92% rename from httpclient-simple/src/main/java/org/baeldung/spring/WebConfig.java rename to httpclient-simple/src/main/java/com/baeldung/spring/WebConfig.java index 5876e1307b..8d5c1dc7f1 100644 --- a/httpclient-simple/src/main/java/org/baeldung/spring/WebConfig.java +++ b/httpclient-simple/src/main/java/com/baeldung/spring/WebConfig.java @@ -1,4 +1,4 @@ -package org.baeldung.spring; +package com.baeldung.spring; import java.util.List; @@ -11,7 +11,7 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; @Configuration @EnableWebMvc -@ComponentScan("org.baeldung.web") +@ComponentScan("com.baeldung.web") public class WebConfig implements WebMvcConfigurer { public WebConfig() { diff --git a/httpclient-simple/src/main/java/org/baeldung/web/controller/BarController.java b/httpclient-simple/src/main/java/com/baeldung/web/controller/BarController.java similarity index 92% rename from httpclient-simple/src/main/java/org/baeldung/web/controller/BarController.java rename to httpclient-simple/src/main/java/com/baeldung/web/controller/BarController.java index 2bc314baa2..02e6af03af 100644 --- a/httpclient-simple/src/main/java/org/baeldung/web/controller/BarController.java +++ b/httpclient-simple/src/main/java/com/baeldung/web/controller/BarController.java @@ -1,6 +1,6 @@ -package org.baeldung.web.controller; +package com.baeldung.web.controller; -import org.baeldung.web.dto.Bar; +import com.baeldung.web.dto.Bar; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationEventPublisher; import org.springframework.stereotype.Controller; diff --git a/httpclient-simple/src/main/java/org/baeldung/web/controller/FooController.java b/httpclient-simple/src/main/java/com/baeldung/web/controller/FooController.java similarity index 92% rename from httpclient-simple/src/main/java/org/baeldung/web/controller/FooController.java rename to httpclient-simple/src/main/java/com/baeldung/web/controller/FooController.java index b50edb2dcf..461a5e351a 100644 --- a/httpclient-simple/src/main/java/org/baeldung/web/controller/FooController.java +++ b/httpclient-simple/src/main/java/com/baeldung/web/controller/FooController.java @@ -1,6 +1,6 @@ -package org.baeldung.web.controller; +package com.baeldung.web.controller; -import org.baeldung.web.dto.Foo; +import com.baeldung.web.dto.Foo; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationEventPublisher; import org.springframework.security.access.prepost.PreAuthorize; diff --git a/httpclient-simple/src/main/java/org/baeldung/web/dto/Bar.java b/httpclient-simple/src/main/java/com/baeldung/web/dto/Bar.java similarity index 86% rename from httpclient-simple/src/main/java/org/baeldung/web/dto/Bar.java rename to httpclient-simple/src/main/java/com/baeldung/web/dto/Bar.java index d33e39a823..eb139b0ec1 100644 --- a/httpclient-simple/src/main/java/org/baeldung/web/dto/Bar.java +++ b/httpclient-simple/src/main/java/com/baeldung/web/dto/Bar.java @@ -1,4 +1,4 @@ -package org.baeldung.web.dto; +package com.baeldung.web.dto; import java.io.Serializable; diff --git a/httpclient-simple/src/main/java/org/baeldung/web/dto/Foo.java b/httpclient-simple/src/main/java/com/baeldung/web/dto/Foo.java similarity index 86% rename from httpclient-simple/src/main/java/org/baeldung/web/dto/Foo.java rename to httpclient-simple/src/main/java/com/baeldung/web/dto/Foo.java index 09c1dac933..23cfab132d 100644 --- a/httpclient-simple/src/main/java/org/baeldung/web/dto/Foo.java +++ b/httpclient-simple/src/main/java/com/baeldung/web/dto/Foo.java @@ -1,4 +1,4 @@ -package org.baeldung.web.dto; +package com.baeldung.web.dto; import java.io.Serializable; diff --git a/httpclient-simple/src/main/resources/webSecurityConfig.xml b/httpclient-simple/src/main/resources/webSecurityConfig.xml index a93dc841b6..2ff9a1de15 100644 --- a/httpclient-simple/src/main/resources/webSecurityConfig.xml +++ b/httpclient-simple/src/main/resources/webSecurityConfig.xml @@ -23,6 +23,6 @@ - + \ No newline at end of file diff --git a/httpclient-simple/src/main/webapp/WEB-INF/web.xml b/httpclient-simple/src/main/webapp/WEB-INF/web.xml index 83b4aeb0a7..4b2dd54266 100644 --- a/httpclient-simple/src/main/webapp/WEB-INF/web.xml +++ b/httpclient-simple/src/main/webapp/WEB-INF/web.xml @@ -12,7 +12,7 @@ contextConfigLocation - org.baeldung.spring + com.baeldung.spring diff --git a/httpclient-simple/src/test/java/org/baeldung/client/ClientLiveTest.java b/httpclient-simple/src/test/java/com/baeldung/client/ClientLiveTest.java similarity index 94% rename from httpclient-simple/src/test/java/org/baeldung/client/ClientLiveTest.java rename to httpclient-simple/src/test/java/com/baeldung/client/ClientLiveTest.java index 286ee3c900..78e9813f06 100644 --- a/httpclient-simple/src/test/java/org/baeldung/client/ClientLiveTest.java +++ b/httpclient-simple/src/test/java/com/baeldung/client/ClientLiveTest.java @@ -1,11 +1,11 @@ -package org.baeldung.client; +package com.baeldung.client; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.is; import static org.junit.Assert.assertThat; -import org.baeldung.client.spring.ClientConfig; -import org.baeldung.web.dto.Foo; +import com.baeldung.client.spring.ClientConfig; +import com.baeldung.web.dto.Foo; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; diff --git a/httpclient-simple/src/test/java/org/baeldung/client/RestClientLiveManualTest.java b/httpclient-simple/src/test/java/com/baeldung/client/RestClientLiveManualTest.java similarity index 99% rename from httpclient-simple/src/test/java/org/baeldung/client/RestClientLiveManualTest.java rename to httpclient-simple/src/test/java/com/baeldung/client/RestClientLiveManualTest.java index 696d414ae7..a485641b34 100644 --- a/httpclient-simple/src/test/java/org/baeldung/client/RestClientLiveManualTest.java +++ b/httpclient-simple/src/test/java/com/baeldung/client/RestClientLiveManualTest.java @@ -1,4 +1,4 @@ -package org.baeldung.client; +package com.baeldung.client; import static org.apache.http.conn.ssl.SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER; import static org.hamcrest.Matchers.equalTo; @@ -51,6 +51,7 @@ public class RestClientLiveManualTest { final CloseableHttpClient httpClient = (CloseableHttpClient) requestFactory.getHttpClient(); final TrustStrategy acceptingTrustStrategy = (cert, authType) -> true; + final SSLSocketFactory sf = new SSLSocketFactory(acceptingTrustStrategy, ALLOW_ALL_HOSTNAME_VERIFIER); httpClient.getConnectionManager().getSchemeRegistry().register(new Scheme("https", 8443, sf)); diff --git a/httpclient-simple/src/test/java/org/baeldung/httpclient/HttpClientHeadersLiveTest.java b/httpclient-simple/src/test/java/com/baeldung/httpclient/HttpClientHeadersLiveTest.java similarity index 99% rename from httpclient-simple/src/test/java/org/baeldung/httpclient/HttpClientHeadersLiveTest.java rename to httpclient-simple/src/test/java/com/baeldung/httpclient/HttpClientHeadersLiveTest.java index 51c3817da5..44262851fd 100644 --- a/httpclient-simple/src/test/java/org/baeldung/httpclient/HttpClientHeadersLiveTest.java +++ b/httpclient-simple/src/test/java/com/baeldung/httpclient/HttpClientHeadersLiveTest.java @@ -1,4 +1,4 @@ -package org.baeldung.httpclient; +package com.baeldung.httpclient; import com.google.common.collect.Lists; import org.apache.http.Header; diff --git a/httpclient-simple/src/test/java/org/baeldung/httpclient/HttpClientPostingLiveTest.java b/httpclient-simple/src/test/java/com/baeldung/httpclient/HttpClientPostingLiveTest.java similarity index 93% rename from httpclient-simple/src/test/java/org/baeldung/httpclient/HttpClientPostingLiveTest.java rename to httpclient-simple/src/test/java/com/baeldung/httpclient/HttpClientPostingLiveTest.java index 39ed8f09ef..f5dff8d757 100644 --- a/httpclient-simple/src/test/java/org/baeldung/httpclient/HttpClientPostingLiveTest.java +++ b/httpclient-simple/src/test/java/com/baeldung/httpclient/HttpClientPostingLiveTest.java @@ -1,4 +1,4 @@ -package org.baeldung.httpclient; +package com.baeldung.httpclient; import org.apache.http.HttpEntity; import org.apache.http.HttpResponse; @@ -32,7 +32,7 @@ import static org.junit.Assert.assertThat; * NOTE : Need module spring-rest to be running */ public class HttpClientPostingLiveTest { - private static final String SAMPLE_URL = "http://localhost:8082/spring-rest/users"; + private static final String SAMPLE_URL = "http://www.example.com"; private static final String URL_SECURED_BY_BASIC_AUTHENTICATION = "http://browserspy.dk/password-ok.php"; private static final String DEFAULT_USER = "test"; private static final String DEFAULT_PASS = "test"; @@ -69,7 +69,7 @@ public class HttpClientPostingLiveTest { @Test public void whenPostJsonUsingHttpClient_thenCorrect() throws IOException { final CloseableHttpClient client = HttpClients.createDefault(); - final HttpPost httpPost = new HttpPost(SAMPLE_URL + "/detail"); + final HttpPost httpPost = new HttpPost(SAMPLE_URL); final String json = "{\"id\":1,\"name\":\"John\"}"; final StringEntity entity = new StringEntity(json); @@ -92,7 +92,7 @@ public class HttpClientPostingLiveTest { @Test public void whenSendMultipartRequestUsingHttpClient_thenCorrect() throws IOException { final CloseableHttpClient client = HttpClients.createDefault(); - final HttpPost httpPost = new HttpPost(SAMPLE_URL + "/multipart"); + final HttpPost httpPost = new HttpPost(SAMPLE_URL); final MultipartEntityBuilder builder = MultipartEntityBuilder.create(); builder.addTextBody("username", DEFAULT_USER); @@ -110,7 +110,7 @@ public class HttpClientPostingLiveTest { @Test public void whenUploadFileUsingHttpClient_thenCorrect() throws IOException { final CloseableHttpClient client = HttpClients.createDefault(); - final HttpPost httpPost = new HttpPost(SAMPLE_URL + "/upload"); + final HttpPost httpPost = new HttpPost(SAMPLE_URL); final MultipartEntityBuilder builder = MultipartEntityBuilder.create(); builder.addBinaryBody("file", new File("src/test/resources/test.in"), ContentType.APPLICATION_OCTET_STREAM, "file.ext"); @@ -126,7 +126,7 @@ public class HttpClientPostingLiveTest { @Test public void whenGetUploadFileProgressUsingHttpClient_thenCorrect() throws IOException { final CloseableHttpClient client = HttpClients.createDefault(); - final HttpPost httpPost = new HttpPost(SAMPLE_URL + "/upload"); + final HttpPost httpPost = new HttpPost(SAMPLE_URL); final MultipartEntityBuilder builder = MultipartEntityBuilder.create(); builder.addBinaryBody("file", new File("src/test/resources/test.in"), ContentType.APPLICATION_OCTET_STREAM, "file.ext"); diff --git a/httpclient-simple/src/test/java/org/baeldung/httpclient/HttpClientTimeoutLiveTest.java b/httpclient-simple/src/test/java/com/baeldung/httpclient/HttpClientTimeoutLiveTest.java similarity index 98% rename from httpclient-simple/src/test/java/org/baeldung/httpclient/HttpClientTimeoutLiveTest.java rename to httpclient-simple/src/test/java/com/baeldung/httpclient/HttpClientTimeoutLiveTest.java index 8041080b3d..8bd7042dc6 100644 --- a/httpclient-simple/src/test/java/org/baeldung/httpclient/HttpClientTimeoutLiveTest.java +++ b/httpclient-simple/src/test/java/com/baeldung/httpclient/HttpClientTimeoutLiveTest.java @@ -1,4 +1,4 @@ -package org.baeldung.httpclient; +package com.baeldung.httpclient; import static org.hamcrest.Matchers.equalTo; import static org.junit.Assert.assertThat; @@ -20,6 +20,7 @@ import org.apache.http.impl.client.HttpClientBuilder; import org.apache.http.params.CoreConnectionPNames; import org.apache.http.params.HttpParams; import org.junit.After; +import org.junit.Ignore; import org.junit.Test; public class HttpClientTimeoutLiveTest { @@ -91,6 +92,7 @@ public class HttpClientTimeoutLiveTest { * This simulates a timeout against a domain with multiple routes/IPs to it (not a single raw IP) */ @Test(expected = ConnectTimeoutException.class) + @Ignore public final void givenTimeoutIsConfigured_whenTimingOut_thenTimeoutException() throws IOException { final int timeout = 3; diff --git a/httpclient-simple/src/test/java/org/baeldung/httpclient/HttpsClientSslLiveTest.java b/httpclient-simple/src/test/java/com/baeldung/httpclient/HttpsClientSslLiveTest.java similarity index 99% rename from httpclient-simple/src/test/java/org/baeldung/httpclient/HttpsClientSslLiveTest.java rename to httpclient-simple/src/test/java/com/baeldung/httpclient/HttpsClientSslLiveTest.java index 9e95905c70..24ceab0069 100644 --- a/httpclient-simple/src/test/java/org/baeldung/httpclient/HttpsClientSslLiveTest.java +++ b/httpclient-simple/src/test/java/com/baeldung/httpclient/HttpsClientSslLiveTest.java @@ -1,4 +1,4 @@ -package org.baeldung.httpclient; +package com.baeldung.httpclient; import static org.hamcrest.CoreMatchers.equalTo; import static org.junit.Assert.assertThat; diff --git a/httpclient-simple/src/test/java/org/baeldung/httpclient/ProgressEntityWrapper.java b/httpclient-simple/src/test/java/com/baeldung/httpclient/ProgressEntityWrapper.java similarity index 98% rename from httpclient-simple/src/test/java/org/baeldung/httpclient/ProgressEntityWrapper.java rename to httpclient-simple/src/test/java/com/baeldung/httpclient/ProgressEntityWrapper.java index cd00d8711a..c7adf51b3e 100644 --- a/httpclient-simple/src/test/java/org/baeldung/httpclient/ProgressEntityWrapper.java +++ b/httpclient-simple/src/test/java/com/baeldung/httpclient/ProgressEntityWrapper.java @@ -1,4 +1,4 @@ -package org.baeldung.httpclient; +package com.baeldung.httpclient; import java.io.FilterOutputStream; import java.io.IOException; diff --git a/httpclient-simple/src/test/java/org/baeldung/httpclient/ResponseUtil.java b/httpclient-simple/src/test/java/com/baeldung/httpclient/ResponseUtil.java similarity index 94% rename from httpclient-simple/src/test/java/org/baeldung/httpclient/ResponseUtil.java rename to httpclient-simple/src/test/java/com/baeldung/httpclient/ResponseUtil.java index fd38b95cbe..e9ea08a723 100644 --- a/httpclient-simple/src/test/java/org/baeldung/httpclient/ResponseUtil.java +++ b/httpclient-simple/src/test/java/com/baeldung/httpclient/ResponseUtil.java @@ -1,4 +1,4 @@ -package org.baeldung.httpclient; +package com.baeldung.httpclient; import org.apache.http.HttpEntity; import org.apache.http.client.methods.CloseableHttpResponse; diff --git a/httpclient-simple/src/test/java/org/baeldung/httpclient/base/HttpClientBasicLiveTest.java b/httpclient-simple/src/test/java/com/baeldung/httpclient/base/HttpClientBasicLiveTest.java similarity index 96% rename from httpclient-simple/src/test/java/org/baeldung/httpclient/base/HttpClientBasicLiveTest.java rename to httpclient-simple/src/test/java/com/baeldung/httpclient/base/HttpClientBasicLiveTest.java index fee9dc4343..d1b093394e 100644 --- a/httpclient-simple/src/test/java/org/baeldung/httpclient/base/HttpClientBasicLiveTest.java +++ b/httpclient-simple/src/test/java/com/baeldung/httpclient/base/HttpClientBasicLiveTest.java @@ -1,4 +1,4 @@ -package org.baeldung.httpclient.base; +package com.baeldung.httpclient.base; import org.apache.http.HttpStatus; import org.apache.http.client.ClientProtocolException; @@ -8,7 +8,7 @@ import org.apache.http.entity.ContentType; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClientBuilder; import org.apache.http.util.EntityUtils; -import org.baeldung.httpclient.ResponseUtil; +import com.baeldung.httpclient.ResponseUtil; import org.junit.After; import org.junit.Before; import org.junit.Test; diff --git a/httpclient-simple/src/test/java/org/baeldung/httpclient/sec/HttpClientAuthLiveTest.java b/httpclient-simple/src/test/java/com/baeldung/httpclient/sec/HttpClientAuthLiveTest.java similarity index 98% rename from httpclient-simple/src/test/java/org/baeldung/httpclient/sec/HttpClientAuthLiveTest.java rename to httpclient-simple/src/test/java/com/baeldung/httpclient/sec/HttpClientAuthLiveTest.java index 96278b481a..0f7018a9ac 100644 --- a/httpclient-simple/src/test/java/org/baeldung/httpclient/sec/HttpClientAuthLiveTest.java +++ b/httpclient-simple/src/test/java/com/baeldung/httpclient/sec/HttpClientAuthLiveTest.java @@ -1,4 +1,4 @@ -package org.baeldung.httpclient.sec; +package com.baeldung.httpclient.sec; import org.apache.commons.codec.binary.Base64; import org.apache.http.HttpHeaders; @@ -17,7 +17,7 @@ import org.apache.http.impl.client.BasicCredentialsProvider; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClientBuilder; import org.apache.http.protocol.HttpContext; -import org.baeldung.httpclient.ResponseUtil; +import com.baeldung.httpclient.ResponseUtil; import org.junit.After; import org.junit.Before; import org.junit.Test; diff --git a/httpclient-simple/src/test/java/org/baeldung/httpclient/sec/HttpClientCookieLiveTest.java b/httpclient-simple/src/test/java/com/baeldung/httpclient/sec/HttpClientCookieLiveTest.java similarity index 97% rename from httpclient-simple/src/test/java/org/baeldung/httpclient/sec/HttpClientCookieLiveTest.java rename to httpclient-simple/src/test/java/com/baeldung/httpclient/sec/HttpClientCookieLiveTest.java index ba27aca08d..287b6e996c 100644 --- a/httpclient-simple/src/test/java/org/baeldung/httpclient/sec/HttpClientCookieLiveTest.java +++ b/httpclient-simple/src/test/java/com/baeldung/httpclient/sec/HttpClientCookieLiveTest.java @@ -1,4 +1,4 @@ -package org.baeldung.httpclient.sec; +package com.baeldung.httpclient.sec; import org.apache.http.client.HttpClient; import org.apache.http.client.methods.CloseableHttpResponse; @@ -10,7 +10,7 @@ import org.apache.http.impl.client.HttpClientBuilder; import org.apache.http.impl.cookie.BasicClientCookie; import org.apache.http.protocol.BasicHttpContext; import org.apache.http.protocol.HttpContext; -import org.baeldung.httpclient.ResponseUtil; +import com.baeldung.httpclient.ResponseUtil; import org.junit.After; import org.junit.Before; import org.junit.Test; diff --git a/httpclient-simple/src/test/java/org/baeldung/test/LiveTestSuite.java b/httpclient-simple/src/test/java/com/baeldung/test/LiveTestSuite.java similarity index 64% rename from httpclient-simple/src/test/java/org/baeldung/test/LiveTestSuite.java rename to httpclient-simple/src/test/java/com/baeldung/test/LiveTestSuite.java index 8c9b48d056..c864349e02 100644 --- a/httpclient-simple/src/test/java/org/baeldung/test/LiveTestSuite.java +++ b/httpclient-simple/src/test/java/com/baeldung/test/LiveTestSuite.java @@ -1,7 +1,7 @@ -package org.baeldung.test; +package com.baeldung.test; -import org.baeldung.client.ClientLiveTest; -import org.baeldung.client.RestClientLiveManualTest; +import com.baeldung.client.ClientLiveTest; +import com.baeldung.client.RestClientLiveManualTest; import org.junit.runner.RunWith; import org.junit.runners.Suite; diff --git a/httpclient-simple/src/test/resources/test.in b/httpclient-simple/src/test/resources/test.in new file mode 100644 index 0000000000..95d09f2b10 --- /dev/null +++ b/httpclient-simple/src/test/resources/test.in @@ -0,0 +1 @@ +hello world \ No newline at end of file diff --git a/hystrix/pom.xml b/hystrix/pom.xml index fb044588de..7bb3e98246 100644 --- a/hystrix/pom.xml +++ b/hystrix/pom.xml @@ -64,8 +64,6 @@ 1.5.8 0.20.7 - - 1.3 2.6 2.7 diff --git a/jackson-2/.gitignore b/jackson-2/.gitignore index 83c05e60c8..4b1cfaf098 100644 --- a/jackson-2/.gitignore +++ b/jackson-2/.gitignore @@ -10,4 +10,7 @@ # Packaged files # *.jar *.war -*.ear \ No newline at end of file +*.ear + +# Files +/src/main/resources/orderOutput.yaml \ No newline at end of file diff --git a/jackson-2/README.md b/jackson-2/README.md index 92fc11f61c..ee9f8458a0 100644 --- a/jackson-2/README.md +++ b/jackson-2/README.md @@ -8,3 +8,5 @@ The "REST With Spring" Classes: http://bit.ly/restwithspring ### Relevant Articles: - [Mapping Multiple JSON Fields to a Single Java Field](https://www.baeldung.com/json-multiple-fields-single-java-field) - [How to Process YAML with Jackson](https://www.baeldung.com/jackson-yaml) +- [Working with Tree Model Nodes in Jackson](https://www.baeldung.com/jackson-json-node-tree-model) + diff --git a/jackson-2/src/main/java/com/baeldung/jackson/node/JsonNodeIterator.java b/jackson-2/src/main/java/com/baeldung/jackson/node/JsonNodeIterator.java new file mode 100644 index 0000000000..f582772587 --- /dev/null +++ b/jackson-2/src/main/java/com/baeldung/jackson/node/JsonNodeIterator.java @@ -0,0 +1,62 @@ +package com.baeldung.jackson.node; + +import java.util.Iterator; +import java.util.Map.Entry; + +import com.fasterxml.jackson.databind.JsonNode; + +public class JsonNodeIterator { + + private static final String NEW_LINE = "\n"; + private static final String FIELD_DELIMITER = ": "; + private static final String ARRAY_PREFIX = "- "; + private static final String YAML_PREFIX = " "; + + public String toYaml(JsonNode root) { + StringBuilder yaml = new StringBuilder(); + processNode(root, yaml, 0); + return yaml.toString(); + } + + private void processNode(JsonNode jsonNode, StringBuilder yaml, int depth) { + if (jsonNode.isValueNode()) { + yaml.append(jsonNode.asText()); + } + else if (jsonNode.isArray()) { + for (JsonNode arrayItem : jsonNode) { + appendNodeToYaml(arrayItem, yaml, depth, true); + } + } + else if (jsonNode.isObject()) { + appendNodeToYaml(jsonNode, yaml, depth, false); + } + } + + private void appendNodeToYaml(JsonNode node, StringBuilder yaml, int depth, boolean isArrayItem) { + Iterator> fields = node.fields(); + boolean isFirst = true; + while (fields.hasNext()) { + Entry jsonField = fields.next(); + addFieldNameToYaml(yaml, jsonField.getKey(), depth, isArrayItem && isFirst); + processNode(jsonField.getValue(), yaml, depth+1); + isFirst = false; + } + + } + +private void addFieldNameToYaml(StringBuilder yaml, String fieldName, int depth, boolean isFirstInArray) { + if (yaml.length()>0) { + yaml.append(NEW_LINE); + int requiredDepth = (isFirstInArray) ? depth-1 : depth; + for(int i = 0; i < requiredDepth; i++) { + yaml.append(YAML_PREFIX); + } + if (isFirstInArray) { + yaml.append(ARRAY_PREFIX); + } + } + yaml.append(fieldName); + yaml.append(FIELD_DELIMITER); +} + +} diff --git a/jackson/src/test/java/com/baeldung/jackson/node/ExampleStructure.java b/jackson-2/src/test/java/com/baeldung/jackson/node/ExampleStructure.java similarity index 100% rename from jackson/src/test/java/com/baeldung/jackson/node/ExampleStructure.java rename to jackson-2/src/test/java/com/baeldung/jackson/node/ExampleStructure.java diff --git a/jackson-2/src/test/java/com/baeldung/jackson/node/JsonNodeIteratorUnitTest.java b/jackson-2/src/test/java/com/baeldung/jackson/node/JsonNodeIteratorUnitTest.java new file mode 100644 index 0000000000..05426fc844 --- /dev/null +++ b/jackson-2/src/test/java/com/baeldung/jackson/node/JsonNodeIteratorUnitTest.java @@ -0,0 +1,37 @@ +package com.baeldung.jackson.node; + +import static org.junit.Assert.assertEquals; + +import java.io.IOException; + +import org.junit.Test; + +import com.fasterxml.jackson.databind.JsonNode; + +public class JsonNodeIteratorUnitTest { + + private JsonNodeIterator onTest = new JsonNodeIterator(); + private static String expectedYaml = "name: \n" + + " first: Tatu\n" + + " last: Saloranta\n" + + "title: Jackson founder\n" + + "company: FasterXML\n" + + "pets: \n" + + "- type: dog\n" + + " number: 1\n" + + "- type: fish\n" + + " number: 50"; + +@Test +public void givenANodeTree_whenIteratingSubNodes_thenWeFindExpected() throws IOException { + final JsonNode rootNode = ExampleStructure.getExampleRoot(); + + String yaml = onTest.toYaml(rootNode); + System.out.println(yaml.toString()); + + assertEquals(expectedYaml, yaml); + +} + + +} diff --git a/jackson/src/test/java/com/baeldung/jackson/node/NodeBean.java b/jackson-2/src/test/java/com/baeldung/jackson/node/NodeBean.java similarity index 100% rename from jackson/src/test/java/com/baeldung/jackson/node/NodeBean.java rename to jackson-2/src/test/java/com/baeldung/jackson/node/NodeBean.java diff --git a/jackson/src/test/java/com/baeldung/jackson/node/NodeOperationUnitTest.java b/jackson-2/src/test/java/com/baeldung/jackson/node/NodeOperationUnitTest.java similarity index 100% rename from jackson/src/test/java/com/baeldung/jackson/node/NodeOperationUnitTest.java rename to jackson-2/src/test/java/com/baeldung/jackson/node/NodeOperationUnitTest.java diff --git a/jackson-2/src/test/resources/node_example.json b/jackson-2/src/test/resources/node_example.json new file mode 100644 index 0000000000..d57c1df6e3 --- /dev/null +++ b/jackson-2/src/test/resources/node_example.json @@ -0,0 +1,18 @@ +{ + "name": { + "first": "Tatu", + "last": "Saloranta" + }, + "title": "Jackson founder", + "company": "FasterXML", + "pets": [ + { + "type": "dog", + "number": 1 + }, + { + "type": "fish", + "number": 50 + } + ] +} \ No newline at end of file diff --git a/jackson/README.md b/jackson/README.md index 794ddc04d9..01d9419a27 100644 --- a/jackson/README.md +++ b/jackson/README.md @@ -15,7 +15,6 @@ The "REST With Spring" Classes: http://bit.ly/restwithspring - [Jackson JSON Tutorial](http://www.baeldung.com/jackson) - [Jackson – Working with Maps and nulls](http://www.baeldung.com/jackson-map-null-values-or-null-key) - [Jackson – Decide What Fields Get Serialized/Deserialized](http://www.baeldung.com/jackson-field-serializable-deserializable-or-not) -- [Working with Tree Model Nodes in Jackson](http://www.baeldung.com/jackson-json-node-tree-model) - [Jackson vs Gson](http://www.baeldung.com/jackson-vs-gson) - [XML Serialization and Deserialization with Jackson](http://www.baeldung.com/jackson-xml-serialization-and-deserialization) - [More Jackson Annotations](http://www.baeldung.com/jackson-advanced-annotations) diff --git a/jackson/src/main/resources/node_example.json b/jackson/src/main/resources/node_example.json deleted file mode 100644 index 69d37efbf6..0000000000 --- a/jackson/src/main/resources/node_example.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "name": - { - "first": "Tatu", - "last": "Saloranta" - }, - - "title": "Jackson founder", - "company": "FasterXML" -} \ No newline at end of file diff --git a/java-dates-2/pom.xml b/java-dates-2/pom.xml index c2464ed47f..9307a794b9 100644 --- a/java-dates-2/pom.xml +++ b/java-dates-2/pom.xml @@ -15,6 +15,12 @@ + + joda-time + joda-time + ${joda-time.version} + + org.assertj @@ -49,6 +55,7 @@ 3.6.1 + 2.10 1.9 1.9 diff --git a/java-dates-2/src/test/java/com/baeldung/convert/ConvertDateTimeUnitTest.java b/java-dates-2/src/test/java/com/baeldung/convert/ConvertDateTimeUnitTest.java new file mode 100644 index 0000000000..cd31ccc799 --- /dev/null +++ b/java-dates-2/src/test/java/com/baeldung/convert/ConvertDateTimeUnitTest.java @@ -0,0 +1,59 @@ +package com.baeldung.convert; + +import org.joda.time.Instant; +import org.junit.Assert; +import org.junit.Test; + +import java.time.LocalDateTime; +import java.time.ZoneId; +import java.time.ZonedDateTime; +import java.util.Calendar; +import java.util.Date; + +public class ConvertDateTimeUnitTest { + + public final long millis = 1556175797428L; + + @Test + public void givenLocalDateTime_WhenToEpochMillis_ThenMillis() { + ZoneId id = ZoneId.systemDefault(); + + LocalDateTime localDateTime = + LocalDateTime.ofInstant(java.time.Instant.ofEpochMilli(millis), id); + + ZonedDateTime zdt = ZonedDateTime.of(localDateTime, id); + + Assert.assertEquals(millis, zdt.toInstant().toEpochMilli()); + } + + @Test + public void givenJava8Instant_WhenGToEpochMillis_ThenMillis() { + java.time.Instant instant = java.time.Instant.ofEpochMilli(millis); + Assert.assertEquals(millis, instant.toEpochMilli()); + } + + @Test + public void givenDate_WhenGetTime_ThenMillis() { + Date date = new Date(millis); + Assert.assertEquals(millis, date.getTime()); + } + + @Test + public void givenCalendar_WhenGetTimeInMillis_ThenMillis() { + Calendar calendar = Calendar.getInstance(); + calendar.setTime(new Date(millis)); + Assert.assertEquals(millis, calendar.getTimeInMillis()); + } + + @Test + public void givenJodaInstant_WhenGetMillis_ThenMillis() { + Instant jodaInstant = Instant.ofEpochMilli(millis); + Assert.assertEquals(millis, jodaInstant.getMillis()); + } + + @Test + public void givenJODADateTime_WhenGetMillis_ThenMillis() { + org.joda.time.DateTime jodaDateTime = new org.joda.time.DateTime(millis); + Assert.assertEquals(millis, jodaDateTime.getMillis()); + } +} diff --git a/java-ee-8-security-api/app-auth-basic-store-db/pom.xml b/java-ee-8-security-api/app-auth-basic-store-db/pom.xml index cf92fe2ecd..582e82d8bb 100644 --- a/java-ee-8-security-api/app-auth-basic-store-db/pom.xml +++ b/java-ee-8-security-api/app-auth-basic-store-db/pom.xml @@ -53,7 +53,7 @@ com.h2database h2 - ${h2-version} + ${h2.version} jar ${project.build.directory}/liberty/wlp/usr/servers/defaultServer/lib/global @@ -64,8 +64,4 @@ - - - 1.4.197 - diff --git a/java-ee-8-security-api/app-auth-custom-no-store/pom.xml b/java-ee-8-security-api/app-auth-custom-no-store/pom.xml index f9d63f8623..51ee64097a 100644 --- a/java-ee-8-security-api/app-auth-custom-no-store/pom.xml +++ b/java-ee-8-security-api/app-auth-custom-no-store/pom.xml @@ -53,7 +53,7 @@ com.h2database h2 - ${h2-version} + ${h2.version} jar ${project.build.directory}/liberty/wlp/usr/servers/defaultServer/lib/global @@ -64,8 +64,4 @@ - - - 1.4.197 - diff --git a/java-ee-8-security-api/pom.xml b/java-ee-8-security-api/pom.xml index 0cce84e5f2..9b8356714f 100644 --- a/java-ee-8-security-api/pom.xml +++ b/java-ee-8-security-api/pom.xml @@ -72,7 +72,6 @@ 8.0 2.3 18.0.0.1 - 1.4.197 3.2.2 diff --git a/java-numbers/pom.xml b/java-numbers/pom.xml index eb75f85bf0..daed356f66 100644 --- a/java-numbers/pom.xml +++ b/java-numbers/pom.xml @@ -38,7 +38,7 @@ org.openjdk.jmh jmh-generator-annprocess - ${jmh-generator-annprocess.version} + ${jmh-generator.version} org.apache.commons @@ -127,8 +127,6 @@ 1.7.21 1.1.7 - 1.19 - 1.19 2.21.0 3.0.0-M1 diff --git a/java-streams-2/pom.xml b/java-streams-2/pom.xml index 5004249352..3e08e2f432 100644 --- a/java-streams-2/pom.xml +++ b/java-streams-2/pom.xml @@ -18,12 +18,12 @@ org.openjdk.jmh jmh-core - ${jmh.version} + ${jmh-core.version} org.openjdk.jmh jmh-generator-annprocess - ${jmh.version} + ${jmh-generator.version} junit @@ -44,7 +44,6 @@ UTF-8 1.8 1.8 - 1.21 3.11.1 \ No newline at end of file diff --git a/java-streams/pom.xml b/java-streams/pom.xml index 00384eeead..b0c56ecdf9 100644 --- a/java-streams/pom.xml +++ b/java-streams/pom.xml @@ -18,12 +18,12 @@ org.openjdk.jmh jmh-core - ${jmh.version} + ${jmh-core.version} org.openjdk.jmh jmh-generator-annprocess - ${jmh.version} + ${jmh-generator.version} provided @@ -106,7 +106,6 @@ - 1.21 3.5 0.9.0 1.15 diff --git a/java-strings-2/pom.xml b/java-strings-2/pom.xml index c314cd8cad..5279cf5777 100755 --- a/java-strings-2/pom.xml +++ b/java-strings-2/pom.xml @@ -83,7 +83,7 @@ org.hamcrest hamcrest-library - ${hamcrest-library.version} + ${org.hamcrest.version} test @@ -136,12 +136,10 @@ 1.10 3.6.1 - 1.19 61.1 27.0.1-jre 4.0.0 5.3.1 - 1.3 1.3.1 1.4 0.4.0 diff --git a/java-strings-2/src/main/java/com/baeldung/localization/App.java b/java-strings-2/src/main/java/com/baeldung/localization/App.java new file mode 100644 index 0000000000..c2b687933d --- /dev/null +++ b/java-strings-2/src/main/java/com/baeldung/localization/App.java @@ -0,0 +1,21 @@ +package com.baeldung.localization; + +import java.text.ParseException; +import java.util.Arrays; +import java.util.List; +import java.util.Locale; + +public class App { + + /** + * Runs all available formatter + * @throws ParseException + */ + public static void main(String[] args) { + List locales = Arrays.asList(new Locale[] { Locale.UK, Locale.ITALY, Locale.FRANCE, Locale.forLanguageTag("pl-PL") }); + Localization.run(locales); + JavaSEFormat.run(locales); + ICUFormat.run(locales); + } + +} diff --git a/java-strings-2/src/main/java/com/baeldung/localization/ICUFormat.java b/java-strings-2/src/main/java/com/baeldung/localization/ICUFormat.java new file mode 100644 index 0000000000..f7bc357933 --- /dev/null +++ b/java-strings-2/src/main/java/com/baeldung/localization/ICUFormat.java @@ -0,0 +1,29 @@ +package com.baeldung.localization; + +import java.util.List; +import java.util.Locale; +import java.util.ResourceBundle; + +import com.ibm.icu.text.MessageFormat; + +public class ICUFormat { + + public static String getLabel(Locale locale, Object[] data) { + ResourceBundle bundle = ResourceBundle.getBundle("formats", locale); + String format = bundle.getString("label-icu"); + MessageFormat formatter = new MessageFormat(format, locale); + return formatter.format(data); + } + + public static void run(List locales) { + System.out.println("ICU formatter"); + locales.forEach(locale -> System.out.println(getLabel(locale, new Object[] { "Alice", "female", 0 }))); + locales.forEach(locale -> System.out.println(getLabel(locale, new Object[] { "Alice", "female", 1 }))); + locales.forEach(locale -> System.out.println(getLabel(locale, new Object[] { "Alice", "female", 2 }))); + locales.forEach(locale -> System.out.println(getLabel(locale, new Object[] { "Alice", "female", 3 }))); + locales.forEach(locale -> System.out.println(getLabel(locale, new Object[] { "Bob", "male", 0 }))); + locales.forEach(locale -> System.out.println(getLabel(locale, new Object[] { "Bob", "male", 1 }))); + locales.forEach(locale -> System.out.println(getLabel(locale, new Object[] { "Bob", "male", 2 }))); + locales.forEach(locale -> System.out.println(getLabel(locale, new Object[] { "Bob", "male", 3 }))); + } +} diff --git a/java-strings-2/src/main/java/com/baeldung/localization/JavaSEFormat.java b/java-strings-2/src/main/java/com/baeldung/localization/JavaSEFormat.java new file mode 100644 index 0000000000..c95dfffa13 --- /dev/null +++ b/java-strings-2/src/main/java/com/baeldung/localization/JavaSEFormat.java @@ -0,0 +1,24 @@ +package com.baeldung.localization; + +import java.text.MessageFormat; +import java.util.Date; +import java.util.List; +import java.util.Locale; +import java.util.ResourceBundle; + +public class JavaSEFormat { + + public static String getLabel(Locale locale, Object[] data) { + ResourceBundle bundle = ResourceBundle.getBundle("formats", locale); + final String pattern = bundle.getString("label"); + final MessageFormat formatter = new MessageFormat(pattern, locale); + return formatter.format(data); + } + + public static void run(List locales) { + System.out.println("Java formatter"); + final Date date = new Date(System.currentTimeMillis()); + locales.forEach(locale -> System.out.println(getLabel(locale, new Object[] { date, "Alice", 0 }))); + locales.forEach(locale -> System.out.println(getLabel(locale, new Object[] { date, "Alice", 2 }))); + } +} diff --git a/java-strings-2/src/main/java/com/baeldung/localization/Localization.java b/java-strings-2/src/main/java/com/baeldung/localization/Localization.java new file mode 100644 index 0000000000..17a6598ce0 --- /dev/null +++ b/java-strings-2/src/main/java/com/baeldung/localization/Localization.java @@ -0,0 +1,18 @@ +package com.baeldung.localization; + +import java.util.List; +import java.util.Locale; +import java.util.ResourceBundle; + +public class Localization { + + public static String getLabel(Locale locale) { + final ResourceBundle bundle = ResourceBundle.getBundle("messages", locale); + return bundle.getString("label"); + } + + public static void run(List locales) { + locales.forEach(locale -> System.out.println(getLabel(locale))); + } + +} diff --git a/java-strings-2/src/main/resources/formats_en.properties b/java-strings-2/src/main/resources/formats_en.properties new file mode 100644 index 0000000000..4bea9a74bb --- /dev/null +++ b/java-strings-2/src/main/resources/formats_en.properties @@ -0,0 +1,2 @@ +label=On {0, date, short} {1} has sent you {2, choice, 0#no messages|1#a message|2#two messages|2<{2,number,integer} messages}. +label-icu={0} has sent you {2, plural, =0 {no messages} =1 {a message} other {{2, number, integer} messages}}. diff --git a/java-strings-2/src/main/resources/formats_fr.properties b/java-strings-2/src/main/resources/formats_fr.properties new file mode 100644 index 0000000000..7f509d494e --- /dev/null +++ b/java-strings-2/src/main/resources/formats_fr.properties @@ -0,0 +1,2 @@ +label={0, date, short}, {1}{2, choice, 0# ne|0<} vous a envoy\u00e9 {2, choice, 0#aucun message|1#un message|2#deux messages|2<{2,number,integer} messages}. +label-icu={0} {2, plural, =0 {ne } other {}}vous a envoy\u00e9 {2, plural, =0 {aucun message} =1 {un message} other {{2, number, integer} messages}}. diff --git a/java-strings-2/src/main/resources/formats_it.properties b/java-strings-2/src/main/resources/formats_it.properties new file mode 100644 index 0000000000..fe061ae1b6 --- /dev/null +++ b/java-strings-2/src/main/resources/formats_it.properties @@ -0,0 +1,2 @@ +label={0, date, short} {1} ti ha inviato {2, choice, 0#nessun messagio|1#un messaggio|2#due messaggi|2<{2, number, integer} messaggi}. +label-icu={0} {2, plural, =0 {non } other {}}ti ha inviato {2, plural, =0 {nessun messaggio} =1 {un messaggio} other {{2, number, integer} messaggi}}. diff --git a/java-strings-2/src/main/resources/formats_pl.properties b/java-strings-2/src/main/resources/formats_pl.properties new file mode 100644 index 0000000000..9333ec3396 --- /dev/null +++ b/java-strings-2/src/main/resources/formats_pl.properties @@ -0,0 +1,2 @@ +label=W {0, date, short} {1}{2, choice, 0# nie|0<} wys\u0142a\u0142a ci {2, choice, 0#\u017Cadnych wiadomo\u015Bci|1#wiadomo\u015B\u0107|2#dwie wiadomo\u015Bci|2<{2, number, integer} wiadomo\u015Bci}. +label-icu={0} {2, plural, =0 {nie } other {}}{1, select, male {wys\u0142a\u0142} female {wys\u0142a\u0142a} other {wys\u0142a\u0142o}} ci {2, plural, =0 {\u017Cadnej wiadomo\u015Bci} =1 {wiadomo\u015B\u0107} other {{2, number, integer} wiadomo\u015Bci}}. diff --git a/java-strings-2/src/main/resources/messages_en.properties b/java-strings-2/src/main/resources/messages_en.properties new file mode 100644 index 0000000000..bcbca9483c --- /dev/null +++ b/java-strings-2/src/main/resources/messages_en.properties @@ -0,0 +1 @@ +label=Alice has sent you a message. diff --git a/java-strings-2/src/main/resources/messages_fr.properties b/java-strings-2/src/main/resources/messages_fr.properties new file mode 100644 index 0000000000..15ad031a30 --- /dev/null +++ b/java-strings-2/src/main/resources/messages_fr.properties @@ -0,0 +1 @@ +label=Alice vous a envoy\u00e9 un message. diff --git a/java-strings-2/src/main/resources/messages_it.properties b/java-strings-2/src/main/resources/messages_it.properties new file mode 100644 index 0000000000..93b99a9483 --- /dev/null +++ b/java-strings-2/src/main/resources/messages_it.properties @@ -0,0 +1 @@ +label=Alice ti ha inviato un messaggio. diff --git a/java-strings-2/src/main/resources/messages_pl.properties b/java-strings-2/src/main/resources/messages_pl.properties new file mode 100644 index 0000000000..a64066deea --- /dev/null +++ b/java-strings-2/src/main/resources/messages_pl.properties @@ -0,0 +1 @@ +label=Alice wys\u0142a\u0142a ci wiadomo\u015B\u0107. diff --git a/java-strings-2/src/test/java/com/baeldung/localization/ICUFormatUnitTest.java b/java-strings-2/src/test/java/com/baeldung/localization/ICUFormatUnitTest.java new file mode 100644 index 0000000000..2c8f9b47f3 --- /dev/null +++ b/java-strings-2/src/test/java/com/baeldung/localization/ICUFormatUnitTest.java @@ -0,0 +1,74 @@ +package com.baeldung.localization; + +import static org.junit.Assert.assertEquals; + +import java.util.Locale; + +import org.junit.Test; + +import com.baeldung.localization.ICUFormat; + +public class ICUFormatUnitTest { + + @Test + public void givenInUK_whenAliceSendsNothing_thenCorrectMessage() { + assertEquals("Alice has sent you no messages.", ICUFormat.getLabel(Locale.UK, new Object[] { "Alice", "female", 0 })); + } + + @Test + public void givenInUK_whenAliceSendsOneMessage_thenCorrectMessage() { + assertEquals("Alice has sent you a message.", ICUFormat.getLabel(Locale.UK, new Object[] { "Alice", "female", 1 })); + } + + @Test + public void givenInUK_whenBobSendsSixMessages_thenCorrectMessage() { + assertEquals("Bob has sent you 6 messages.", ICUFormat.getLabel(Locale.UK, new Object[] { "Bob", "male", 6 })); + } + + @Test + public void givenInItaly_whenAliceSendsNothing_thenCorrectMessage() { + assertEquals("Alice non ti ha inviato nessun messaggio.", ICUFormat.getLabel(Locale.ITALY, new Object[] { "Alice", "female", 0 })); + } + + @Test + public void givenInItaly_whenAliceSendsOneMessage_thenCorrectMessage() { + assertEquals("Alice ti ha inviato un messaggio.", ICUFormat.getLabel(Locale.ITALY, new Object[] { "Alice", "female", 1 })); + } + + @Test + public void givenInItaly_whenBobSendsSixMessages_thenCorrectMessage() { + assertEquals("Bob ti ha inviato 6 messaggi.", ICUFormat.getLabel(Locale.ITALY, new Object[] { "Bob", "male", 6 })); + } + + @Test + public void givenInFrance_whenAliceSendsNothing_thenCorrectMessage() { + assertEquals("Alice ne vous a envoyé aucun message.", ICUFormat.getLabel(Locale.FRANCE, new Object[] { "Alice", "female", 0 })); + } + + @Test + public void givenInFrance_whenAliceSendsOneMessage_thenCorrectMessage() { + assertEquals("Alice vous a envoyé un message.", ICUFormat.getLabel(Locale.FRANCE, new Object[] { "Alice", "female", 1 })); + } + + @Test + public void givenInFrance_whenBobSendsSixMessages_thenCorrectMessage() { + assertEquals("Bob vous a envoyé 6 messages.", ICUFormat.getLabel(Locale.FRANCE, new Object[] { "Bob", "male", 6 })); + } + + + @Test + public void givenInPoland_whenAliceSendsNothing_thenCorrectMessage() { + assertEquals("Alice nie wysłała ci żadnej wiadomości.", ICUFormat.getLabel(Locale.forLanguageTag("pl-PL"), new Object[] { "Alice", "female", 0 })); + } + + @Test + public void givenInPoland_whenAliceSendsOneMessage_thenCorrectMessage() { + assertEquals("Alice wysłała ci wiadomość.", ICUFormat.getLabel(Locale.forLanguageTag("pl-PL"), new Object[] { "Alice", "female", 1 })); + } + + @Test + public void givenInPoland_whenBobSendsSixMessages_thenCorrectMessage() { + assertEquals("Bob wysłał ci 6 wiadomości.", ICUFormat.getLabel(Locale.forLanguageTag("pl-PL"), new Object[] { "Bob", "male", 6 })); + } + +} diff --git a/java-strings/pom.xml b/java-strings/pom.xml index 4555b8ad4a..7f66b95355 100755 --- a/java-strings/pom.xml +++ b/java-strings/pom.xml @@ -50,7 +50,7 @@ org.openjdk.jmh jmh-generator-annprocess - ${jmh-core.version} + ${jmh-generator.version} com.ibm.icu @@ -79,7 +79,7 @@ org.hamcrest hamcrest-library - ${hamcrest-library.version} + ${org.hamcrest.version} test @@ -132,12 +132,10 @@ 1.10 3.6.1 - 1.19 61.1 27.0.1-jre 4.0.0 5.3.1 - 1.3 1.3.1 1.4 0.4.0 diff --git a/javax-servlets/pom.xml b/javax-servlets/pom.xml index bf85feb7ce..e3d8a430d9 100644 --- a/javax-servlets/pom.xml +++ b/javax-servlets/pom.xml @@ -48,7 +48,7 @@ javax.servlet.jsp javax.servlet.jsp-api - ${jsp.version} + ${javax.servlet.jsp-api.version} javax.servlet @@ -90,7 +90,5 @@ 1.3.3 2.6 4.0.1 - 1.2 - 2.3.1 diff --git a/jee-7/pom.xml b/jee-7/pom.xml index 62ccb9d313..d389b57cd5 100644 --- a/jee-7/pom.xml +++ b/jee-7/pom.xml @@ -527,10 +527,8 @@ 2.2.14 4.5 2.0.1.Final - 3.1.0 2.1.0.Final 2.8 - 1.2 2.2 20160715 1.0.0.Final @@ -538,7 +536,6 @@ 1.0.0.Final 1.4.2.Final 2.1.1.Final - 1.4.178 2.22.1 diff --git a/jee-7/src/main/java/com/baeldung/singleton/Car.java b/jee-7/src/main/java/com/baeldung/singleton/Car.java new file mode 100644 index 0000000000..0cf7281294 --- /dev/null +++ b/jee-7/src/main/java/com/baeldung/singleton/Car.java @@ -0,0 +1,28 @@ +package com.baeldung.singleton; + +public class Car { + + private String type; + private String model; + private boolean serviced = false; + + public Car(String type, String model) { + super(); + this.type = type; + this.model = model; + } + + public boolean isServiced () { + return serviced; + } + + public void setServiced(Boolean serviced) { + this.serviced = serviced; + } + + @Override + public String toString() { + return "Car [type=" + type + ", model=" + model + "]"; + } + +} diff --git a/jee-7/src/main/java/com/baeldung/singleton/CarServiceBean.java b/jee-7/src/main/java/com/baeldung/singleton/CarServiceBean.java new file mode 100644 index 0000000000..b824882d5d --- /dev/null +++ b/jee-7/src/main/java/com/baeldung/singleton/CarServiceBean.java @@ -0,0 +1,23 @@ +package com.baeldung.singleton; + +import java.util.UUID; + +import javax.enterprise.context.Dependent; + +import org.springframework.web.context.annotation.RequestScope; + +@RequestScope +public class CarServiceBean { + + private UUID id = UUID.randomUUID(); + + public UUID getId() { + return this.id; + } + + @Override + public String toString() { + return "CarService [id=" + id + "]"; + } + +} diff --git a/jee-7/src/main/java/com/baeldung/singleton/CarServiceEjbSingleton.java b/jee-7/src/main/java/com/baeldung/singleton/CarServiceEjbSingleton.java new file mode 100644 index 0000000000..1bbffdd61e --- /dev/null +++ b/jee-7/src/main/java/com/baeldung/singleton/CarServiceEjbSingleton.java @@ -0,0 +1,46 @@ +package com.baeldung.singleton; + +import java.util.UUID; + +import javax.ejb.Singleton; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +@Singleton +public class CarServiceEjbSingleton { + + private static Logger LOG = LoggerFactory.getLogger(CarServiceEjbSingleton.class); + + private UUID id = UUID.randomUUID(); + + private static int serviceQueue; + + public UUID getId() { + return this.id; + } + + @Override + public String toString() { + return "CarServiceEjbSingleton [id=" + id + "]"; + } + + public int service(Car car) { + serviceQueue++; + LOG.info("Car {} is being serviced @ CarServiceEjbSingleton - serviceQueue: {}", car, serviceQueue); + simulateService(car); + serviceQueue--; + LOG.info("Car service for {} is completed - serviceQueue: {}", car, serviceQueue); + return serviceQueue; + } + + private void simulateService(Car car) { + try { + Thread.sleep(100); + car.setServiced(true); + } catch (InterruptedException e) { + LOG.error("CarServiceEjbSingleton::InterruptedException: {}", e); + } + } + +} diff --git a/jee-7/src/main/java/com/baeldung/singleton/CarServiceSingleton.java b/jee-7/src/main/java/com/baeldung/singleton/CarServiceSingleton.java new file mode 100644 index 0000000000..223d139346 --- /dev/null +++ b/jee-7/src/main/java/com/baeldung/singleton/CarServiceSingleton.java @@ -0,0 +1,47 @@ +package com.baeldung.singleton; + +import java.util.UUID; + +import javax.inject.Singleton; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +@Singleton +public class CarServiceSingleton { + + private static Logger LOG = LoggerFactory.getLogger(CarServiceSingleton.class); + + private UUID id = UUID.randomUUID(); + + private static int serviceQueue; + + public UUID getId() { + return this.id; + } + + @Override + public String toString() { + return "CarServiceSingleton [id=" + id + "]"; + } + + public int service(Car car) { + serviceQueue++; + LOG.info("Car {} is being serviced @ CarServiceSingleton - serviceQueue: {}", car, serviceQueue); + simulateService(car); + serviceQueue--; + LOG.info("Car service for {} is completed - serviceQueue: {}", car, serviceQueue); + return serviceQueue; + + } + + private void simulateService(Car car) { + try { + Thread.sleep(100); + car.setServiced(true); + } catch (InterruptedException e) { + LOG.error("CarServiceSingleton::InterruptedException: {}", e); + } + } + +} diff --git a/jee-7/src/test/java/com/baeldung/singleton/CarServiceIntegrationTest.java b/jee-7/src/test/java/com/baeldung/singleton/CarServiceIntegrationTest.java new file mode 100644 index 0000000000..b828296dca --- /dev/null +++ b/jee-7/src/test/java/com/baeldung/singleton/CarServiceIntegrationTest.java @@ -0,0 +1,142 @@ +package com.baeldung.singleton; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; + +import javax.ejb.EJB; +import javax.inject.Inject; + +import org.jboss.arquillian.container.test.api.Deployment; +import org.jboss.arquillian.junit.Arquillian; +import org.jboss.shrinkwrap.api.ShrinkWrap; +import org.jboss.shrinkwrap.api.asset.EmptyAsset; +import org.jboss.shrinkwrap.api.spec.JavaArchive; +import org.junit.Before; +import org.junit.FixMethodOrder; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.MethodSorters; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +@RunWith(Arquillian.class) +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +public class CarServiceIntegrationTest { + + public static final Logger LOG = LoggerFactory.getLogger(CarServiceIntegrationTest.class); + + @Deployment + public static JavaArchive createDeployment() { + return ShrinkWrap.create(JavaArchive.class) + .addClasses(CarServiceBean.class, CarServiceSingleton.class, CarServiceEjbSingleton.class, Car.class) + .addAsResource("META-INF/persistence.xml") + .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml"); + } + + @Inject + private CarServiceBean carServiceBean; + + @Inject + private CarServiceSingleton carServiceSingleton; + + @EJB + private CarServiceEjbSingleton carServiceEjbSingleton; + + private static Map idMap = new HashMap<>(); + + @Before + public void setUp() { + // populate idMap only on first run + if (idMap.isEmpty()) { + LOG.info("setUp::carServiceBean: {}", carServiceBean.getId()); + idMap.put("carServiceBeanId", carServiceBean.getId()); + + LOG.info("setUp::carServiceSingleton: {}", carServiceSingleton.getId()); + idMap.put("carServiceSingletonId", carServiceSingleton.getId()); + + LOG.info("setUp::carServiceEjbSingleton: {}", carServiceEjbSingleton.getId()); + idMap.put("carServiceEjbSingletonId", carServiceEjbSingleton.getId()); + } + } + + @Test + public void givenRun1_whenGetId_thenSingletonIdEqual() { + int testRun = 1; + + assertNotNull(carServiceBean); + assertNotNull(carServiceSingleton); + assertNotNull(carServiceEjbSingleton); + + UUID carServiceBeanId = carServiceBean.getId(); + assertEquals(idMap.get("carServiceBeanId"), carServiceBeanId); + LOG.info("Test run {}::carServiceBeanId: {}", testRun, carServiceBeanId); + + UUID carServiceSingletonId = carServiceSingleton.getId(); + assertEquals(idMap.get("carServiceSingletonId"), carServiceSingletonId); + LOG.info("Test run {}::carServiceSingletonId: {}", testRun, carServiceSingletonId); + + UUID carServiceEjbSingletonId = carServiceEjbSingleton.getId(); + assertEquals(idMap.get("carServiceEjbSingletonId"), carServiceEjbSingletonId); + LOG.info("Test run {}::carServiceEjbSingletonId: {}", testRun, carServiceEjbSingletonId); + } + + @Test + public void givenRun2_whenGetId_thenSingletonIdEqual() { + int testRun = 2; + + assertNotNull(carServiceBean); + assertNotNull(carServiceSingleton); + assertNotNull(carServiceEjbSingleton); + + UUID carServiceBeanId = carServiceBean.getId(); + assertNotEquals(idMap.get("carServiceBeanId"), carServiceBeanId); + LOG.info("Test run {}::carServiceBeanId: {}", testRun, carServiceBeanId); + + UUID carServiceSingletonId = carServiceSingleton.getId(); + assertEquals(idMap.get("carServiceSingletonId"), carServiceSingletonId); + LOG.info("Test run {}::carServiceSingletonId: {}", testRun, carServiceSingletonId); + + UUID carServiceEjbSingletonId = carServiceEjbSingleton.getId(); + assertEquals(idMap.get("carServiceEjbSingletonId"), carServiceEjbSingletonId); + LOG.info("Test run {}::carServiceEjbSingletonId: {}", testRun, carServiceEjbSingletonId); + } + + @Test + public void givenRun3_whenSingleton_thenNoLocking() { + for (int i = 0; i < 10; i++) { + new Thread(new Runnable() { + @Override + public void run() { + String model = Double.toString(Math.round(Math.random() * 100)); + Car car = new Car("Speedster", model); + int serviceQueue = carServiceSingleton.service(car); + assertTrue(serviceQueue < 10); + } + }).start(); + } + return; + } + + @Test + public void givenRun4_whenEjb_thenLocking() { + for (int i = 0; i < 10; i++) { + new Thread(new Runnable() { + @Override + public void run() { + String model = Double.toString(Math.round(Math.random() * 100)); + Car car = new Car("Speedster", model); + int serviceQueue = carServiceEjbSingleton.service(car); + assertEquals(0, serviceQueue); + } + }).start(); + } + return; + } + +} \ No newline at end of file diff --git a/jsf/pom.xml b/jsf/pom.xml index fc6d4a0ee2..19f1265250 100644 --- a/jsf/pom.xml +++ b/jsf/pom.xml @@ -67,7 +67,7 @@ javax.servlet javax.servlet-api provided - ${javax.servlet.version} + ${javax.servlet-api.version} @@ -99,11 +99,6 @@ 2.2.14 3.0.0 - - 3.1.0 - - 1.2 - 2.6 diff --git a/jta/pom.xml b/jta/pom.xml index 6a31733996..b7e39c66e1 100644 --- a/jta/pom.xml +++ b/jta/pom.xml @@ -83,7 +83,6 @@ UTF-8 UTF-8 - 1.8 2.4.1 2.0.4.RELEASE diff --git a/kotlin-libraries-2/README.md b/kotlin-libraries-2/README.md index ff12555376..fdb7c2830d 100644 --- a/kotlin-libraries-2/README.md +++ b/kotlin-libraries-2/README.md @@ -1 +1,3 @@ ## Relevant articles: + +- [Jackson Support for Kotlin](https://www.baeldung.com/jackson-kotlin) diff --git a/kotlin-libraries/build.gradle b/kotlin-libraries/build.gradle index b244df34b0..afb92de49e 100644 --- a/kotlin-libraries/build.gradle +++ b/kotlin-libraries/build.gradle @@ -7,6 +7,7 @@ version '1.0-SNAPSHOT' buildscript { ext.kotlin_version = '1.2.41' ext.ktor_version = '0.9.2' + ext.khttp_version = '0.1.0' repositories { mavenCentral() @@ -47,11 +48,16 @@ dependencies { compile "io.ktor:ktor-server-netty:$ktor_version" compile "ch.qos.logback:logback-classic:1.2.1" compile "io.ktor:ktor-gson:$ktor_version" + compile "khttp:khttp:$khttp_version" testCompile group: 'junit', name: 'junit', version: '4.12' + testCompile group: 'org.jetbrains.spek', name: 'spek-api', version: '1.1.5' + testCompile group: 'org.jetbrains.spek', name: 'spek-subject-extension', version: '1.1.5' + testCompile group: 'org.jetbrains.spek', name: 'spek-junit-platform-engine', version: '1.1.5' implementation 'com.beust:klaxon:3.0.1' + implementation 'io.reactivex.rxjava2:rxkotlin:2.3.0' } task runServer(type: JavaExec) { main = 'APIServer' classpath = sourceSets.main.runtimeClasspath -} \ No newline at end of file +} diff --git a/kotlin-libraries/pom.xml b/kotlin-libraries/pom.xml index 3d2c7337b0..b75c77f358 100644 --- a/kotlin-libraries/pom.xml +++ b/kotlin-libraries/pom.xml @@ -166,6 +166,12 @@ 2.6 compile + + + io.reactivex.rxjava2 + rxkotlin + 2.3.0 + diff --git a/kotlin-libraries/src/test/kotlin/com/baeldung/kotlin/rxkotlin/RxKotlinTest.kt b/kotlin-libraries/src/test/kotlin/com/baeldung/kotlin/rxkotlin/RxKotlinTest.kt new file mode 100644 index 0000000000..979ed3f809 --- /dev/null +++ b/kotlin-libraries/src/test/kotlin/com/baeldung/kotlin/rxkotlin/RxKotlinTest.kt @@ -0,0 +1,157 @@ +package com.baeldung.kotlin.rxkotlin + +import io.reactivex.Maybe +import io.reactivex.Observable +import io.reactivex.functions.BiFunction +import io.reactivex.rxkotlin.* +import io.reactivex.subjects.PublishSubject +import org.junit.Test +import kotlin.test.assertEquals +import kotlin.test.assertFalse + +class RxKotlinTest { + + @Test + fun whenBooleanArrayToObserver_thenBooleanObserver() { + val observable = listOf(true, false, false).toObservable() + observable.test().assertValues(true, false, false) + } + + @Test + fun whenBooleanArrayToFlowable_thenBooleanFlowable() { + val flowable = listOf(true, false, false).toFlowable() + flowable.buffer(2).test().assertValues(listOf(true, false), listOf(false)) + } + + @Test + fun whenIntArrayToObserver_thenIntObserver() { + val observable = listOf(1, 1, 2, 3).toObservable() + observable.test().assertValues(1, 1, 2, 3) + } + + @Test + fun whenIntArrayToFlowable_thenIntFlowable() { + val flowable = listOf(1, 1, 2, 3).toFlowable() + flowable.buffer(2).test().assertValues(listOf(1, 1), listOf(2, 3)) + } + + @Test + fun whenObservablePairToMap_thenSingleNoDuplicates() { + val list = listOf(Pair("a", 1), Pair("b", 2), Pair("c", 3), Pair("a", 4)) + val observable = list.toObservable() + val map = observable.toMap() + assertEquals(mapOf(Pair("a", 4), Pair("b", 2), Pair("c", 3)), map.blockingGet()) + } + + @Test + fun whenObservablePairToMap_thenSingleWithDuplicates() { + val list = listOf(Pair("a", 1), Pair("b", 2), Pair("c", 3), Pair("a", 4)) + val observable = list.toObservable() + val map = observable.toMultimap() + assertEquals( + mapOf(Pair("a", listOf(1, 4)), Pair("b", listOf(2)), Pair("c", listOf(3))), + map.blockingGet()) + } + + @Test + fun whenMergeAll_thenStream() { + val subject = PublishSubject.create>() + val observable = subject.mergeAll() + val testObserver = observable.test() + subject.onNext(Observable.just("first", "second")) + testObserver.assertValues("first", "second") + subject.onNext(Observable.just("third", "fourth")) + subject.onNext(Observable.just("fifth")) + testObserver.assertValues("first", "second", "third", "fourth", "fifth") + } + + @Test + fun whenConcatAll_thenStream() { + val subject = PublishSubject.create>() + val observable = subject.concatAll() + val testObserver = observable.test() + subject.onNext(Observable.just("first", "second")) + testObserver.assertValues("first", "second") + subject.onNext(Observable.just("third", "fourth")) + subject.onNext(Observable.just("fifth")) + testObserver.assertValues("first", "second", "third", "fourth", "fifth") + } + + @Test + fun whenSwitchLatest_thenStream() { + val subject = PublishSubject.create>() + val observable = subject.switchLatest() + val testObserver = observable.test() + subject.onNext(Observable.just("first", "second")) + testObserver.assertValues("first", "second") + subject.onNext(Observable.just("third", "fourth")) + subject.onNext(Observable.just("fifth")) + testObserver.assertValues("first", "second", "third", "fourth", "fifth") + } + + @Test + fun whenMergeAllMaybes_thenObservable() { + val subject = PublishSubject.create>() + val observable = subject.mergeAllMaybes() + val testObserver = observable.test() + subject.onNext(Maybe.just(1)) + subject.onNext(Maybe.just(2)) + subject.onNext(Maybe.empty()) + testObserver.assertValues(1, 2) + subject.onNext(Maybe.error(Exception(""))) + subject.onNext(Maybe.just(3)) + testObserver.assertValues(1, 2).assertError(Exception::class.java) + } + + @Test + fun whenMerge_thenStream() { + val observables = mutableListOf(Observable.just("first", "second")) + val observable = observables.merge() + observables.add(Observable.just("third", "fourth")) + observables.add(Observable.error(Exception("e"))) + observables.add(Observable.just("fifth")) + + observable.test().assertValues("first", "second", "third", "fourth").assertError(Exception::class.java) + } + + @Test + fun whenMergeDelayError_thenStream() { + val observables = mutableListOf>(Observable.error(Exception("e1"))) + val observable = observables.mergeDelayError() + observables.add(Observable.just("1", "2")) + observables.add(Observable.error(Exception("e2"))) + observables.add(Observable.just("3")) + + observable.test().assertValues("1", "2", "3").assertError(Exception::class.java) + } + + @Test + fun whenCast_thenUniformType() { + val observable = Observable.just(1, 1, 2, 3) + observable.cast().test().assertValues(1, 1, 2, 3) + } + + @Test + fun whenOfType_thenFilter() { + val observable = Observable.just(1, "and", 2, "and") + observable.ofType().test().assertValues(1, 2) + } + + @Test + fun whenFunction_thenCompletable() { + var value = 0 + val completable = { value = 3 }.toCompletable() + assertFalse(completable.test().isCancelled) + assertEquals(3, value) + } + + @Test + fun whenHelper_thenMoreIdiomaticKotlin() { + val zipWith = Observable.just(1).zipWith(Observable.just(2)) { a, b -> a + b } + zipWith.subscribeBy(onNext = { println(it) }) + val zip = Observables.zip(Observable.just(1), Observable.just(2)) { a, b -> a + b } + zip.subscribeBy(onNext = { println(it) }) + val zipOrig = Observable.zip(Observable.just(1), Observable.just(2), BiFunction { a, b -> a + b }) + zipOrig.subscribeBy(onNext = { println(it) }) + } +} diff --git a/libraries-2/README.md b/libraries-2/README.md index 4883e13b64..4bcfeaefa1 100644 --- a/libraries-2/README.md +++ b/libraries-2/README.md @@ -1,3 +1,6 @@ + ### Relevant Articles: - [A Guide to jBPM with Java](https://www.baeldung.com/jbpm-java) +- [Guide to Classgraph Library](https://www.baeldung.com/classgraph) + diff --git a/libraries-2/pom.xml b/libraries-2/pom.xml index 965cb195bf..6303c0cab5 100644 --- a/libraries-2/pom.xml +++ b/libraries-2/pom.xml @@ -45,11 +45,23 @@ jbpm-test ${jbpm.version} + + info.picocli + picocli + ${picocli.version} + + + org.springframework.boot + spring-boot-starter + ${spring-boot-starter.version} + 3.6.2 - 4.8.22 + 4.8.28 6.0.0.Final + 3.9.6 + 2.1.4.RELEASE diff --git a/picocli/src/main/java/com/baeldung/picocli/git/Application.java b/libraries-2/src/main/java/com/baeldung/picocli/git/Application.java similarity index 100% rename from picocli/src/main/java/com/baeldung/picocli/git/Application.java rename to libraries-2/src/main/java/com/baeldung/picocli/git/Application.java diff --git a/picocli/src/main/java/com/baeldung/picocli/git/commands/declarative/GitCommand.java b/libraries-2/src/main/java/com/baeldung/picocli/git/commands/declarative/GitCommand.java similarity index 100% rename from picocli/src/main/java/com/baeldung/picocli/git/commands/declarative/GitCommand.java rename to libraries-2/src/main/java/com/baeldung/picocli/git/commands/declarative/GitCommand.java diff --git a/picocli/src/main/java/com/baeldung/picocli/git/commands/methods/GitCommand.java b/libraries-2/src/main/java/com/baeldung/picocli/git/commands/methods/GitCommand.java similarity index 100% rename from picocli/src/main/java/com/baeldung/picocli/git/commands/methods/GitCommand.java rename to libraries-2/src/main/java/com/baeldung/picocli/git/commands/methods/GitCommand.java diff --git a/picocli/src/main/java/com/baeldung/picocli/git/commands/programmative/GitCommand.java b/libraries-2/src/main/java/com/baeldung/picocli/git/commands/programmative/GitCommand.java similarity index 100% rename from picocli/src/main/java/com/baeldung/picocli/git/commands/programmative/GitCommand.java rename to libraries-2/src/main/java/com/baeldung/picocli/git/commands/programmative/GitCommand.java diff --git a/picocli/src/main/java/com/baeldung/picocli/git/commands/subcommands/GitAddCommand.java b/libraries-2/src/main/java/com/baeldung/picocli/git/commands/subcommands/GitAddCommand.java similarity index 100% rename from picocli/src/main/java/com/baeldung/picocli/git/commands/subcommands/GitAddCommand.java rename to libraries-2/src/main/java/com/baeldung/picocli/git/commands/subcommands/GitAddCommand.java diff --git a/picocli/src/main/java/com/baeldung/picocli/git/commands/subcommands/GitCommitCommand.java b/libraries-2/src/main/java/com/baeldung/picocli/git/commands/subcommands/GitCommitCommand.java similarity index 100% rename from picocli/src/main/java/com/baeldung/picocli/git/commands/subcommands/GitCommitCommand.java rename to libraries-2/src/main/java/com/baeldung/picocli/git/commands/subcommands/GitCommitCommand.java diff --git a/picocli/src/main/java/com/baeldung/picocli/git/commands/subcommands/GitConfigCommand.java b/libraries-2/src/main/java/com/baeldung/picocli/git/commands/subcommands/GitConfigCommand.java similarity index 100% rename from picocli/src/main/java/com/baeldung/picocli/git/commands/subcommands/GitConfigCommand.java rename to libraries-2/src/main/java/com/baeldung/picocli/git/commands/subcommands/GitConfigCommand.java diff --git a/picocli/src/main/java/com/baeldung/picocli/git/model/ConfigElement.java b/libraries-2/src/main/java/com/baeldung/picocli/git/model/ConfigElement.java similarity index 100% rename from picocli/src/main/java/com/baeldung/picocli/git/model/ConfigElement.java rename to libraries-2/src/main/java/com/baeldung/picocli/git/model/ConfigElement.java diff --git a/picocli/src/main/java/com/baeldung/picocli/helloworld/HelloWorldCommand.java b/libraries-2/src/main/java/com/baeldung/picocli/helloworld/HelloWorldCommand.java similarity index 100% rename from picocli/src/main/java/com/baeldung/picocli/helloworld/HelloWorldCommand.java rename to libraries-2/src/main/java/com/baeldung/picocli/helloworld/HelloWorldCommand.java diff --git a/libraries-apache-commons/pom.xml b/libraries-apache-commons/pom.xml index c7ff918af9..cb5990df22 100644 --- a/libraries-apache-commons/pom.xml +++ b/libraries-apache-commons/pom.xml @@ -95,14 +95,11 @@ 3.6.2 2.5 1.6 - 1.4.196 4.1 - 4.12 2.0.0.0 1.10.L001 3.5.2 3.6 - 1.3 3.6.1 diff --git a/libraries-data/pom.xml b/libraries-data/pom.xml index 85be66c067..3276ebcdbb 100644 --- a/libraries-data/pom.xml +++ b/libraries-data/pom.xml @@ -432,9 +432,7 @@ 1.2.2 4.0.1 - 1.4.196 16.5.1 - 3.7.0 5.0 1.0.0 2.4.0 diff --git a/linkrest/pom.xml b/linkrest/pom.xml index 073a173aff..b3d3bd374e 100644 --- a/linkrest/pom.xml +++ b/linkrest/pom.xml @@ -73,7 +73,6 @@ 2.9 4.0.B1 - 1.4.196 2.25.1 diff --git a/logging-modules/log-mdc/pom.xml b/logging-modules/log-mdc/pom.xml index 3031274d0b..ae658e034e 100644 --- a/logging-modules/log-mdc/pom.xml +++ b/logging-modules/log-mdc/pom.xml @@ -29,13 +29,13 @@ javax.servlet javax.servlet-api - ${javax.servlet.version} + ${javax.servlet-api.version} provided com.fasterxml.jackson.core jackson-databind - ${jackson.library} + ${jackson.version} @@ -98,12 +98,9 @@ - 1.2.17 2.7 3.3.6 3.3.0.Final - 3.1.0 - 2.9.7 2.4 diff --git a/logging-modules/log4j2/pom.xml b/logging-modules/log4j2/pom.xml index 924abfd346..14420356de 100644 --- a/logging-modules/log4j2/pom.xml +++ b/logging-modules/log4j2/pom.xml @@ -115,8 +115,6 @@ - 2.9.7 - 1.4.193 2.1.1 2.11.0 yyyyMMddHHmmss diff --git a/logging-modules/logback/pom.xml b/logging-modules/logback/pom.xml index 41a28ffd17..22a89124b5 100644 --- a/logging-modules/logback/pom.xml +++ b/logging-modules/logback/pom.xml @@ -58,7 +58,6 @@ 1.2.3 0.1.5 - 2.9.7 3.3.5 diff --git a/lucene/pom.xml b/lucene/pom.xml index f427cfd8a7..3d1ce61782 100644 --- a/lucene/pom.xml +++ b/lucene/pom.xml @@ -32,8 +32,6 @@ - - 1.16.18 1.0.0.Final diff --git a/parent-spring-5/pom.xml b/parent-spring-5/pom.xml index 3178682d34..84df8cf30a 100644 --- a/parent-spring-5/pom.xml +++ b/parent-spring-5/pom.xml @@ -31,7 +31,6 @@ 5.1.4.RELEASE 5.0.2 - 2.9.6 5.1.4.RELEASE diff --git a/patterns/pom.xml b/patterns/pom.xml index bf302a7a74..875af67d55 100644 --- a/patterns/pom.xml +++ b/patterns/pom.xml @@ -51,7 +51,6 @@ - 3.1.0 3.0.0 9.4.0.v20161208 diff --git a/performance-tests/pom.xml b/performance-tests/pom.xml index 7d77c2a0e3..d7738780bf 100644 --- a/performance-tests/pom.xml +++ b/performance-tests/pom.xml @@ -46,12 +46,12 @@ org.openjdk.jmh jmh-core - ${jmh.version} + ${jmh-core.version} org.openjdk.jmh jmh-generator-annprocess - ${jmh.version} + ${jmh-generator.version} @@ -85,7 +85,6 @@ 1.2.0.Final 1.1.0 1.6.0.1 - 1.20 1.2.0.Final diff --git a/persistence-modules/core-java-persistence/pom.xml b/persistence-modules/core-java-persistence/pom.xml index 2ad2083fec..2760489ce1 100644 --- a/persistence-modules/core-java-persistence/pom.xml +++ b/persistence-modules/core-java-persistence/pom.xml @@ -30,7 +30,7 @@ com.h2database h2 - ${h2database.version} + ${h2.version} org.apache.commons @@ -73,7 +73,6 @@ 42.2.5.jre7 8.0.15 3.10.0 - 1.4.197 2.4.0 3.2.0 0.9.5.2 diff --git a/persistence-modules/deltaspike/pom.xml b/persistence-modules/deltaspike/pom.xml index 9a4669102a..4dcef07695 100644 --- a/persistence-modules/deltaspike/pom.xml +++ b/persistence-modules/deltaspike/pom.xml @@ -317,7 +317,6 @@ 2.6 1.1.3 1.2.5.Final-redhat-1 - 1.4.197 3.5 diff --git a/persistence-modules/flyway/pom.xml b/persistence-modules/flyway/pom.xml index eb827f5675..99549ee3fc 100644 --- a/persistence-modules/flyway/pom.xml +++ b/persistence-modules/flyway/pom.xml @@ -65,7 +65,6 @@ 5.0.2 5.0.2 - 1.4.195 diff --git a/persistence-modules/hibernate-mapping/pom.xml b/persistence-modules/hibernate-mapping/pom.xml index fdc82a5275..6bab3c5b1f 100644 --- a/persistence-modules/hibernate-mapping/pom.xml +++ b/persistence-modules/hibernate-mapping/pom.xml @@ -29,7 +29,7 @@ com.h2database h2 - ${h2database.version} + ${h2.version} @@ -61,7 +61,6 @@ 5.3.7.Final - 1.4.196 3.8.0 5.3.3.Final 2.2.5 diff --git a/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/basicannotation/Course.java b/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/basicannotation/Course.java new file mode 100644 index 0000000000..e816fb0176 --- /dev/null +++ b/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/basicannotation/Course.java @@ -0,0 +1,34 @@ +package com.baeldung.hibernate.basicannotation; + +import javax.persistence.Basic; +import javax.persistence.Entity; +import javax.persistence.FetchType; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; + +@Entity +public class Course { + + @Id + private int id; + + @Basic(optional = false, fetch = FetchType.LAZY) + private String name; + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} + diff --git a/persistence-modules/hibernate-mapping/src/test/java/com/baeldung/hibernate/basicannotation/BasicAnnotationIntegrationTest.java b/persistence-modules/hibernate-mapping/src/test/java/com/baeldung/hibernate/basicannotation/BasicAnnotationIntegrationTest.java new file mode 100644 index 0000000000..70f08b4ee3 --- /dev/null +++ b/persistence-modules/hibernate-mapping/src/test/java/com/baeldung/hibernate/basicannotation/BasicAnnotationIntegrationTest.java @@ -0,0 +1,59 @@ +package com.baeldung.hibernate.basicannotation; + +import com.baeldung.hibernate.HibernateUtil; +import com.baeldung.hibernate.basicannotation.Course; +import com.baeldung.hibernate.Strategy; +import org.hibernate.PropertyValueException; +import org.hibernate.Session; +import org.hibernate.Transaction; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.hibernate.SessionFactory; +import org.junit.BeforeClass; + +import java.io.IOException; + +public class BasicAnnotationIntegrationTest { + + private static SessionFactory sessionFactory; + private Session session; + private Transaction transaction; + + @BeforeClass + public static void beforeTests() { + sessionFactory = HibernateUtil.getSessionFactory(Strategy.MAP_KEY_COLUMN_BASED); + } + + @Before + public void setUp() throws IOException { + session = sessionFactory.openSession(); + transaction = session.beginTransaction(); + } + + @After + public void tearDown() { + transaction.rollback(); + session.close(); + } + + @Test + public void givenACourse_whenCourseNamePresent_shouldPersist() { + Course course = new Course(); + course.setName("Computers"); + + session.save(course); + session.flush(); + session.clear(); + + } + + @Test(expected = PropertyValueException.class) + public void givenACourse_whenCourseNameAbsent_shouldFail() { + Course course = new Course(); + + session.save(course); + session.flush(); + session.clear(); + } +} diff --git a/persistence-modules/hibernate5/pom.xml b/persistence-modules/hibernate5/pom.xml index c7f08e50d5..8799317e9c 100644 --- a/persistence-modules/hibernate5/pom.xml +++ b/persistence-modules/hibernate5/pom.xml @@ -30,7 +30,7 @@ com.h2database h2 - ${h2database.version} + ${h2.version} org.hibernate @@ -104,9 +104,7 @@ 5.3.7.Final 6.0.6 2.2.3 - 1.4.196 3.8.0 - 2.9.7 1.21 diff --git a/persistence-modules/hibernate5/src/main/java/com/baeldung/hibernate/pojo/Course.java b/persistence-modules/hibernate5/src/main/java/com/baeldung/hibernate/pojo/Course.java index 97760acd3b..2214b9a56f 100644 --- a/persistence-modules/hibernate5/src/main/java/com/baeldung/hibernate/pojo/Course.java +++ b/persistence-modules/hibernate5/src/main/java/com/baeldung/hibernate/pojo/Course.java @@ -20,8 +20,8 @@ public class Course { public void setCourseId(UUID courseId) { this.courseId = courseId; } - - - + + + } diff --git a/persistence-modules/influxdb/pom.xml b/persistence-modules/influxdb/pom.xml index 8e1aeebe6d..a8ecaadd62 100644 --- a/persistence-modules/influxdb/pom.xml +++ b/persistence-modules/influxdb/pom.xml @@ -33,7 +33,6 @@ 2.8 - 1.16.18 diff --git a/persistence-modules/java-jpa/pom.xml b/persistence-modules/java-jpa/pom.xml index fa47d6bd9c..f23040fbdc 100644 --- a/persistence-modules/java-jpa/pom.xml +++ b/persistence-modules/java-jpa/pom.xml @@ -49,7 +49,6 @@ 5.4.0.Final - 1.4.197 2.7.4-RC1 42.2.5 diff --git a/persistence-modules/java-jpa/src/main/java/com/baeldung/jpa/basicannotation/Course.java b/persistence-modules/java-jpa/src/main/java/com/baeldung/jpa/basicannotation/Course.java new file mode 100644 index 0000000000..cc5a83420c --- /dev/null +++ b/persistence-modules/java-jpa/src/main/java/com/baeldung/jpa/basicannotation/Course.java @@ -0,0 +1,33 @@ +package com.baeldung.jpa.basicannotation; + +import javax.persistence.Basic; +import javax.persistence.Entity; +import javax.persistence.FetchType; +import javax.persistence.Id; + +@Entity +public class Course { + + @Id + private int id; + + @Basic(optional = false, fetch = FetchType.LAZY) + private String name; + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} + diff --git a/persistence-modules/java-jpa/src/main/java/com/baeldung/jpa/defaultvalues/User.java b/persistence-modules/java-jpa/src/main/java/com/baeldung/jpa/defaultvalues/User.java new file mode 100644 index 0000000000..436c708d40 --- /dev/null +++ b/persistence-modules/java-jpa/src/main/java/com/baeldung/jpa/defaultvalues/User.java @@ -0,0 +1,54 @@ +package com.baeldung.jpa.defaultvalues; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; + +@Entity +public class User { + + @Id + private Long id; + + @Column(columnDefinition = "varchar(255) default 'John Snow'") + private String name = "John Snow"; + + @Column(columnDefinition = "integer default 25") + private Integer age = 25; + + @Column(columnDefinition = "boolean default false") + private Boolean locked = false; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Integer getAge() { + return age; + } + + public void setAge(Integer age) { + this.age = age; + } + + public Boolean getLocked() { + return locked; + } + + public void setLocked(Boolean locked) { + this.locked = locked; + } +} diff --git a/persistence-modules/java-jpa/src/main/java/com/baeldung/jpa/defaultvalues/UserRepository.java b/persistence-modules/java-jpa/src/main/java/com/baeldung/jpa/defaultvalues/UserRepository.java new file mode 100644 index 0000000000..52f9807cfb --- /dev/null +++ b/persistence-modules/java-jpa/src/main/java/com/baeldung/jpa/defaultvalues/UserRepository.java @@ -0,0 +1,36 @@ +package com.baeldung.jpa.defaultvalues; + +import javax.persistence.EntityManager; +import javax.persistence.EntityManagerFactory; +import javax.persistence.Persistence; + +public class UserRepository { + + private EntityManagerFactory emf = null; + + public UserRepository() { + emf = Persistence.createEntityManagerFactory("entity-default-values"); + } + + public User find(Long id) { + EntityManager entityManager = emf.createEntityManager(); + User user = entityManager.find(User.class, id); + entityManager.close(); + return user; + } + + public void save(User user, Long id) { + user.setId(id); + + EntityManager entityManager = emf.createEntityManager(); + entityManager.getTransaction().begin(); + entityManager.persist(user); + entityManager.getTransaction().commit(); + entityManager.close(); + } + + public void clean() { + emf.close(); + } + +} diff --git a/persistence-modules/java-jpa/src/main/resources/META-INF/persistence.xml b/persistence-modules/java-jpa/src/main/resources/META-INF/persistence.xml index 5422afa4a3..21a757f490 100644 --- a/persistence-modules/java-jpa/src/main/resources/META-INF/persistence.xml +++ b/persistence-modules/java-jpa/src/main/resources/META-INF/persistence.xml @@ -1,133 +1,149 @@ - - - - - org.hibernate.jpa.HibernatePersistenceProvider - com.baeldung.sqlresultsetmapping.ScheduledDay - com.baeldung.sqlresultsetmapping.Employee - true - - - - - - - - - - - - - - org.hibernate.jpa.HibernatePersistenceProvider - com.baeldung.jpa.stringcast.Message - true - - - - - - - - - - - - - - org.hibernate.jpa.HibernatePersistenceProvider - com.baeldung.jpa.model.Car - true - - - - - - - - - - - - com.baeldung.jpa.entitygraph.model.Post - com.baeldung.jpa.entitygraph.model.User - com.baeldung.jpa.entitygraph.model.Comment - true - - - - - - - - - - - - - org.eclipse.persistence.jpa.PersistenceProvider - com.baeldung.jpa.datetime.JPA22DateTimeEntity - true - - - - - - - - - - - - - - - - org.hibernate.jpa.HibernatePersistenceProvider - com.baeldung.jpa.criteria.entity.Item - true - - - - - - - - - - - - - - - org.hibernate.jpa.HibernatePersistenceProvider - com.baeldung.jpa.querytypes.UserEntity - true - - - - - - - - - - - - - - \ No newline at end of file + + + + + org.hibernate.jpa.HibernatePersistenceProvider + com.baeldung.sqlresultsetmapping.ScheduledDay + com.baeldung.sqlresultsetmapping.Employee + true + + + + + + + + + + + + + + org.hibernate.jpa.HibernatePersistenceProvider + com.baeldung.jpa.stringcast.Message + true + + + + + + + + + + + + + + org.hibernate.jpa.HibernatePersistenceProvider + com.baeldung.jpa.model.Car + true + + + + + + + + + + + + com.baeldung.jpa.entitygraph.model.Post + com.baeldung.jpa.entitygraph.model.User + com.baeldung.jpa.entitygraph.model.Comment + true + + + + + + + + + + + + + org.eclipse.persistence.jpa.PersistenceProvider + com.baeldung.jpa.datetime.JPA22DateTimeEntity + true + + + + + + + + + + + + + + + + org.hibernate.jpa.HibernatePersistenceProvider + com.baeldung.jpa.criteria.entity.Item + true + + + + + + + + + + + + + + + org.hibernate.jpa.HibernatePersistenceProvider + com.baeldung.jpa.querytypes.UserEntity + true + + + + + + + + + + + + + + + org.hibernate.jpa.HibernatePersistenceProvider + com.baeldung.jpa.defaultvalues.User + true + + + + + + + + + + + + + diff --git a/persistence-modules/java-jpa/src/test/java/com/baeldung/jpa/basicannotation/BasicAnnotationIntegrationTest.java b/persistence-modules/java-jpa/src/test/java/com/baeldung/jpa/basicannotation/BasicAnnotationIntegrationTest.java new file mode 100644 index 0000000000..8580aa6602 --- /dev/null +++ b/persistence-modules/java-jpa/src/test/java/com/baeldung/jpa/basicannotation/BasicAnnotationIntegrationTest.java @@ -0,0 +1,56 @@ +package com.baeldung.jpa.basicannotation; + +import org.hibernate.PropertyValueException; +import javax.persistence.EntityManager; +import javax.persistence.EntityManagerFactory; +import javax.persistence.Persistence; +import org.junit.After; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.AfterClass; +import org.junit.Test; + +import java.io.IOException; + +public class BasicAnnotationIntegrationTest { + + private static EntityManager entityManager; + private static EntityManagerFactory entityManagerFactory; + + @BeforeClass + public void setup() { + entityManagerFactory = Persistence.createEntityManagerFactory("java-jpa-scheduled-day"); + entityManager = entityManagerFactory.createEntityManager(); + } + + @Test + public void givenACourse_whenCourseNamePresent_shouldPersist() { + Course course = new Course(); + course.setName("Computers"); + + entityManager.persist(course); + entityManager.flush(); + entityManager.clear(); + + } + + @Test(expected = PropertyValueException.class) + public void givenACourse_whenCourseNameAbsent_shouldFail() { + Course course = new Course(); + + entityManager.persist(course); + entityManager.flush(); + entityManager.clear(); + } + + @AfterClass + public void destroy() { + + if (entityManager != null) { + entityManager.close(); + } + if (entityManagerFactory != null) { + entityManagerFactory.close(); + } + } +} diff --git a/persistence-modules/java-jpa/src/test/java/com/baeldung/jpa/defautlvalues/UserDefaultValuesUnitTest.java b/persistence-modules/java-jpa/src/test/java/com/baeldung/jpa/defautlvalues/UserDefaultValuesUnitTest.java new file mode 100644 index 0000000000..dc41ff51f2 --- /dev/null +++ b/persistence-modules/java-jpa/src/test/java/com/baeldung/jpa/defautlvalues/UserDefaultValuesUnitTest.java @@ -0,0 +1,63 @@ +package com.baeldung.jpa.defaultvalues; + +import com.baeldung.jpa.defaultvalues.User; +import com.baeldung.jpa.defaultvalues.UserRepository; + +import org.junit.Test; +import org.junit.Ignore; +import org.junit.AfterClass; +import org.junit.BeforeClass; + +import static org.junit.Assert.*; + +public class UserDefaultValuesUnitTest { + + private static UserRepository userRepository = null; + + @BeforeClass + public static void once() { + userRepository = new UserRepository(); + } + + @Test + @Ignore // SQL default values are also defined + public void saveUser_shouldSaveWithDefaultFieldValues() { + User user = new User(); + userRepository.save(user, 1L); + + user = userRepository.find(1L); + assertEquals(user.getName(), "John Snow"); + assertEquals(25, (int) user.getAge()); + assertFalse(user.getLocked()); + } + + @Test + @Ignore // SQL default values are also defined + public void saveUser_shouldSaveWithNullName() { + User user = new User(); + user.setName(null); + userRepository.save(user, 2L); + + user = userRepository.find(2L); + assertNull(user.getName()); + assertEquals(25, (int) user.getAge()); + assertFalse(user.getLocked()); + } + + @Test + public void saveUser_shouldSaveWithDefaultSqlValues() { + User user = new User(); + userRepository.save(user, 3L); + + user = userRepository.find(3L); + assertEquals(user.getName(), "John Snow"); + assertEquals(25, (int) user.getAge()); + assertFalse(user.getLocked()); + } + + @AfterClass + public static void destroy() { + userRepository.clean(); + } + +} diff --git a/persistence-modules/pom.xml b/persistence-modules/pom.xml index 67a5c36fed..ba3baf6636 100644 --- a/persistence-modules/pom.xml +++ b/persistence-modules/pom.xml @@ -55,5 +55,6 @@ spring-hibernate-5 spring-hibernate4 spring-jpa + spring-persistence-simple diff --git a/persistence-modules/spring-boot-persistence/pom.xml b/persistence-modules/spring-boot-persistence/pom.xml index ca7c7306e7..e283759c75 100644 --- a/persistence-modules/spring-boot-persistence/pom.xml +++ b/persistence-modules/spring-boot-persistence/pom.xml @@ -79,10 +79,8 @@ UTF-8 - 1.8 8.0.12 9.0.10 - 1.4.197 2.23.0 2.0.1.Final diff --git a/persistence-modules/spring-data-cassandra-reactive/pom.xml b/persistence-modules/spring-data-cassandra-reactive/pom.xml index bc8f49862d..5a34d90c9f 100644 --- a/persistence-modules/spring-data-cassandra-reactive/pom.xml +++ b/persistence-modules/spring-data-cassandra-reactive/pom.xml @@ -52,7 +52,6 @@ UTF-8 UTF-8 - 1.8 2.1.2.RELEASE diff --git a/persistence-modules/spring-data-eclipselink/pom.xml b/persistence-modules/spring-data-eclipselink/pom.xml index 618fa83ee5..61c28dc26f 100644 --- a/persistence-modules/spring-data-eclipselink/pom.xml +++ b/persistence-modules/spring-data-eclipselink/pom.xml @@ -67,7 +67,6 @@ 1.5.9.RELEASE 2.7.0 - 1.4.196 diff --git a/persistence-modules/spring-data-jpa-2/src/main/java/com/baeldung/derivedquery/entity/User.java b/persistence-modules/spring-data-jpa-2/src/main/java/com/baeldung/derivedquery/entity/User.java new file mode 100644 index 0000000000..e6d38f775b --- /dev/null +++ b/persistence-modules/spring-data-jpa-2/src/main/java/com/baeldung/derivedquery/entity/User.java @@ -0,0 +1,70 @@ +package com.baeldung.derivedquery.entity; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.Table; +import java.time.ZonedDateTime; + +@Table(name = "users") +@Entity +public class User { + + @Id + @GeneratedValue + private Integer id; + private String name; + private Integer age; + private ZonedDateTime birthDate; + private Boolean active; + + public User() { + } + + public User(String name, Integer age, ZonedDateTime birthDate, Boolean active) { + this.name = name; + this.age = age; + this.birthDate = birthDate; + this.active = active; + } + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Integer getAge() { + return age; + } + + public void setAge(Integer age) { + this.age = age; + } + + public ZonedDateTime getBirthDate() { + return birthDate; + } + + public void setBirthDate(ZonedDateTime birthDate) { + this.birthDate = birthDate; + } + + public Boolean getActive() { + return active; + } + + public void setActive(Boolean active) { + this.active = active; + } +} diff --git a/persistence-modules/spring-data-jpa-2/src/main/java/com/baeldung/derivedquery/repository/UserRepository.java b/persistence-modules/spring-data-jpa-2/src/main/java/com/baeldung/derivedquery/repository/UserRepository.java new file mode 100644 index 0000000000..a23855d96d --- /dev/null +++ b/persistence-modules/spring-data-jpa-2/src/main/java/com/baeldung/derivedquery/repository/UserRepository.java @@ -0,0 +1,60 @@ +package com.baeldung.derivedquery.repository; + +import com.baeldung.derivedquery.entity.User; +import org.springframework.data.jpa.repository.JpaRepository; + +import java.time.ZonedDateTime; +import java.util.Collection; +import java.util.List; + +public interface UserRepository extends JpaRepository { + + List findByName(String name); + + List findByNameIs(String name); + + List findByNameEquals(String name); + + List findByNameIsNull(); + + List findByNameNot(String name); + + List findByNameIsNot(String name); + + List findByNameStartingWith(String name); + + List findByNameEndingWith(String name); + + List findByNameContaining(String name); + + List findByNameLike(String name); + + List findByAgeLessThan(Integer age); + + List findByAgeLessThanEqual(Integer age); + + List findByAgeGreaterThan(Integer age); + + List findByAgeGreaterThanEqual(Integer age); + + List findByAgeBetween(Integer startAge, Integer endAge); + + List findByBirthDateAfter(ZonedDateTime birthDate); + + List findByBirthDateBefore(ZonedDateTime birthDate); + + List findByActiveTrue(); + + List findByActiveFalse(); + + List findByAgeIn(Collection ages); + + List findByNameOrBirthDate(String name, ZonedDateTime birthDate); + + List findByNameOrBirthDateAndActive(String name, ZonedDateTime birthDate, Boolean active); + + List findByNameOrderByName(String name); + + List findByNameOrderByNameDesc(String name); + +} diff --git a/persistence-modules/spring-data-jpa-2/src/test/java/com/baeldung/derivedquery/repository/UserRepositoryTest.java b/persistence-modules/spring-data-jpa-2/src/test/java/com/baeldung/derivedquery/repository/UserRepositoryTest.java new file mode 100644 index 0000000000..188ed5d4d0 --- /dev/null +++ b/persistence-modules/spring-data-jpa-2/src/test/java/com/baeldung/derivedquery/repository/UserRepositoryTest.java @@ -0,0 +1,172 @@ +package com.baeldung.derivedquery.repository; + +import com.baeldung.Application; +import com.baeldung.derivedquery.entity.User; +import com.baeldung.derivedquery.repository.UserRepository; +import java.time.ZonedDateTime; +import java.util.Arrays; +import java.util.List; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; + +import static org.junit.Assert.assertEquals; + +@RunWith(SpringRunner.class) +@SpringBootTest(classes = Application.class) +public class UserRepositoryTest { + + private static final String USER_NAME_ADAM = "Adam"; + private static final String USER_NAME_EVE = "Eve"; + private static final ZonedDateTime BIRTHDATE = ZonedDateTime.now(); + + @Autowired + private UserRepository userRepository; + + @Before + public void setUp() { + + User user1 = new User(USER_NAME_ADAM, 25, BIRTHDATE, true); + User user2 = new User(USER_NAME_ADAM, 20, BIRTHDATE, false); + User user3 = new User(USER_NAME_EVE, 20, BIRTHDATE, true); + User user4 = new User(null, 30, BIRTHDATE, false); + + userRepository.saveAll(Arrays.asList(user1, user2, user3, user4)); + } + + @After + public void tearDown() { + + userRepository.deleteAll(); + } + + @Test + public void whenFindByName_thenReturnsCorrectResult() { + + assertEquals(2, userRepository.findByName(USER_NAME_ADAM).size()); + } + + @Test + public void whenFindByNameIsNull_thenReturnsCorrectResult() { + + assertEquals(1, userRepository.findByNameIsNull().size()); + } + + @Test + public void whenFindByNameNot_thenReturnsCorrectResult() { + + assertEquals(USER_NAME_EVE, userRepository.findByNameNot(USER_NAME_ADAM).get(0).getName()); + } + + @Test + public void whenFindByNameStartingWith_thenReturnsCorrectResult() { + + assertEquals(2, userRepository.findByNameStartingWith("A").size()); + } + + @Test + public void whenFindByNameEndingWith_thenReturnsCorrectResult() { + + assertEquals(1, userRepository.findByNameEndingWith("e").size()); + } + + @Test + public void whenByNameContaining_thenReturnsCorrectResult() { + + assertEquals(1, userRepository.findByNameContaining("v").size()); + } + + + @Test + public void whenByNameLike_thenReturnsCorrectResult() { + + assertEquals(2, userRepository.findByNameEndingWith("%d%m").size()); + } + + @Test + public void whenByAgeLessThan_thenReturnsCorrectResult() { + + assertEquals(2, userRepository.findByAgeLessThan(25).size()); + } + + + @Test + public void whenByAgeLessThanEqual_thenReturnsCorrectResult() { + + assertEquals(3, userRepository.findByAgeLessThanEqual(25).size()); + } + + @Test + public void whenByAgeGreaterThan_thenReturnsCorrectResult() { + + assertEquals(1, userRepository.findByAgeGreaterThan(25).size()); + } + + @Test + public void whenByAgeGreaterThanEqual_thenReturnsCorrectResult() { + + assertEquals(2, userRepository.findByAgeGreaterThanEqual(25).size()); + } + + @Test + public void whenByAgeBetween_thenReturnsCorrectResult() { + + assertEquals(4, userRepository.findByAgeBetween(20, 30).size()); + } + + @Test + public void whenByBirthDateAfter_thenReturnsCorrectResult() { + + final ZonedDateTime yesterday = BIRTHDATE.minusDays(1); + assertEquals(4, userRepository.findByBirthDateAfter(yesterday).size()); + } + + @Test + public void whenByBirthDateBefore_thenReturnsCorrectResult() { + + final ZonedDateTime yesterday = BIRTHDATE.minusDays(1); + assertEquals(0, userRepository.findByBirthDateBefore(yesterday).size()); + } + + @Test + public void whenByActiveTrue_thenReturnsCorrectResult() { + + assertEquals(2, userRepository.findByActiveTrue().size()); + } + + @Test + public void whenByActiveFalse_thenReturnsCorrectResult() { + + assertEquals(2, userRepository.findByActiveFalse().size()); + } + + + @Test + public void whenByAgeIn_thenReturnsCorrectResult() { + + final List ages = Arrays.asList(20, 25); + assertEquals(3, userRepository.findByAgeIn(ages).size()); + } + + @Test + public void whenByNameOrBirthDate() { + + assertEquals(4, userRepository.findByNameOrBirthDate(USER_NAME_ADAM, BIRTHDATE).size()); + } + + @Test + public void whenByNameOrBirthDateAndActive() { + + assertEquals(3, userRepository.findByNameOrBirthDateAndActive(USER_NAME_ADAM, BIRTHDATE, false).size()); + } + + @Test + public void whenByNameOrderByName() { + + assertEquals(2, userRepository.findByNameOrderByName(USER_NAME_ADAM).size()); + } +} \ No newline at end of file diff --git a/persistence-modules/spring-hibernate-3/pom.xml b/persistence-modules/spring-hibernate-3/pom.xml index 6c1bdace30..ec35f35bb3 100644 --- a/persistence-modules/spring-hibernate-3/pom.xml +++ b/persistence-modules/spring-hibernate-3/pom.xml @@ -91,7 +91,6 @@ 3.6.10.Final 5.1.40 8.5.8 - 1.4.193 19.0 3.5 diff --git a/persistence-modules/spring-hibernate-5/pom.xml b/persistence-modules/spring-hibernate-5/pom.xml index 832cf8dca7..16e55cb0c0 100644 --- a/persistence-modules/spring-hibernate-5/pom.xml +++ b/persistence-modules/spring-hibernate-5/pom.xml @@ -143,7 +143,6 @@ 9.0.0.M26 1.1 2.3.4 - 1.4.195 21.0 diff --git a/persistence-modules/spring-hibernate4/pom.xml b/persistence-modules/spring-hibernate4/pom.xml index fad84870df..4289c9c3d5 100644 --- a/persistence-modules/spring-hibernate4/pom.xml +++ b/persistence-modules/spring-hibernate4/pom.xml @@ -160,7 +160,6 @@ 8.5.8 1.1 2.3.4 - 1.4.193 5.3.3.Final diff --git a/persistence-modules/spring-jpa/README.md b/persistence-modules/spring-jpa/README.md index 2f2a27e4ac..24cbb3ee8b 100644 --- a/persistence-modules/spring-jpa/README.md +++ b/persistence-modules/spring-jpa/README.md @@ -4,7 +4,6 @@ ### Relevant Articles: -- [A Guide to JPA with Spring](https://www.baeldung.com/the-persistence-layer-with-spring-and-jpa) - [Transactions with Spring and JPA](https://www.baeldung.com/transaction-configuration-with-jpa-and-spring) - [The DAO with JPA and Spring](http://www.baeldung.com/spring-dao-jpa) - [JPA Pagination](http://www.baeldung.com/jpa-pagination) diff --git a/persistence-modules/spring-jpa/pom.xml b/persistence-modules/spring-jpa/pom.xml index 3daba6cd55..0fdffad8db 100644 --- a/persistence-modules/spring-jpa/pom.xml +++ b/persistence-modules/spring-jpa/pom.xml @@ -93,7 +93,7 @@ javax.servlet jstl - ${javax.servlet.jstl.version} + ${jstl.version} javax.servlet @@ -163,10 +163,8 @@ 5.2.17.Final 6.0.6 2.1.5.RELEASE - 1.4.195 - 1.2 2.5 diff --git a/persistence-modules/spring-persistence-simple/.gitignore b/persistence-modules/spring-persistence-simple/.gitignore new file mode 100644 index 0000000000..83c05e60c8 --- /dev/null +++ b/persistence-modules/spring-persistence-simple/.gitignore @@ -0,0 +1,13 @@ +*.class + +#folders# +/target +/neoDb* +/data +/src/main/webapp/WEB-INF/classes +*/META-INF/* + +# Packaged files # +*.jar +*.war +*.ear \ No newline at end of file diff --git a/persistence-modules/spring-persistence-simple/README.md b/persistence-modules/spring-persistence-simple/README.md new file mode 100644 index 0000000000..2fcd05e84a --- /dev/null +++ b/persistence-modules/spring-persistence-simple/README.md @@ -0,0 +1,18 @@ +========= + +## Spring Persistence Example Project + + +### Relevant Articles: +- [A Guide to JPA with Spring](https://www.baeldung.com/the-persistence-layer-with-spring-and-jpa) + + +### Eclipse Config +After importing the project into Eclipse, you may see the following error: +"No persistence xml file found in project" + +This can be ignored: +- Project -> Properties -> Java Persistance -> JPA -> Error/Warnings -> Select Ignore on "No persistence xml file found in project" +Or: +- Eclipse -> Preferences - Validation - disable the "Build" execution of the JPA Validator + diff --git a/persistence-modules/spring-persistence-simple/pom.xml b/persistence-modules/spring-persistence-simple/pom.xml new file mode 100644 index 0000000000..e624af4ea6 --- /dev/null +++ b/persistence-modules/spring-persistence-simple/pom.xml @@ -0,0 +1,114 @@ + + 4.0.0 + spring-persistence-simple + 0.1-SNAPSHOT + spring-persistence-simple + + + com.baeldung + parent-modules + 1.0.0-SNAPSHOT + ../../ + + + + + + org.springframework + spring-orm + ${org.springframework.version} + + + commons-logging + commons-logging + + + + + org.springframework + spring-context + ${org.springframework.version} + + + + + + org.hibernate + hibernate-entitymanager + ${hibernate.version} + + + mysql + mysql-connector-java + ${mysql-connector-java.version} + runtime + + + org.springframework.data + spring-data-jpa + ${spring-data-jpa.version} + + + com.h2database + h2 + ${h2.version} + + + + + + com.google.guava + guava + ${guava.version} + + + org.assertj + assertj-core + ${assertj.version} + + + + + + org.apache.commons + commons-lang3 + ${commons-lang3.version} + test + + + + org.springframework + spring-test + ${org.springframework.version} + test + + + + + + spring-persistence-simple + + + src/main/resources + true + + + + + + + 5.1.6.RELEASE + + + 5.4.2.Final + 6.0.6 + 2.1.6.RELEASE + + + 21.0 + 3.5 + 3.8.0 + + + \ No newline at end of file diff --git a/persistence-modules/spring-persistence-simple/src/main/java/org/baeldung/config/PersistenceJPAConfig.java b/persistence-modules/spring-persistence-simple/src/main/java/org/baeldung/config/PersistenceJPAConfig.java new file mode 100644 index 0000000000..ec0d4bca3c --- /dev/null +++ b/persistence-modules/spring-persistence-simple/src/main/java/org/baeldung/config/PersistenceJPAConfig.java @@ -0,0 +1,87 @@ +package org.baeldung.config; + +import java.util.Properties; + +import javax.persistence.EntityManagerFactory; +import javax.sql.DataSource; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.PropertySource; +import org.springframework.core.env.Environment; +import org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor; +import org.springframework.data.jpa.repository.config.EnableJpaRepositories; +import org.springframework.jdbc.datasource.DriverManagerDataSource; +import org.springframework.orm.jpa.JpaTransactionManager; +import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; +import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter; +import org.springframework.transaction.PlatformTransactionManager; +import org.springframework.transaction.annotation.EnableTransactionManagement; + +import com.google.common.base.Preconditions; + +@Configuration +@EnableTransactionManagement +@PropertySource({ "classpath:persistence-h2.properties" }) +@ComponentScan({ "org.baeldung.persistence" }) +@EnableJpaRepositories(basePackages = "org.baeldung.persistence.dao") +public class PersistenceJPAConfig { + + @Autowired + private Environment env; + + public PersistenceJPAConfig() { + super(); + } + + // beans + + @Bean + public LocalContainerEntityManagerFactoryBean entityManagerFactory() { + final LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean(); + em.setDataSource(dataSource()); + em.setPackagesToScan(new String[] { "org.baeldung.persistence.model" }); + + final HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter(); + em.setJpaVendorAdapter(vendorAdapter); + em.setJpaProperties(additionalProperties()); + + return em; + } + + @Bean + public DataSource dataSource() { + final DriverManagerDataSource dataSource = new DriverManagerDataSource(); + dataSource.setDriverClassName(Preconditions.checkNotNull(env.getProperty("jdbc.driverClassName"))); + dataSource.setUrl(Preconditions.checkNotNull(env.getProperty("jdbc.url"))); + dataSource.setUsername(Preconditions.checkNotNull(env.getProperty("jdbc.user"))); + dataSource.setPassword(Preconditions.checkNotNull(env.getProperty("jdbc.pass"))); + + return dataSource; + } + + @Bean + public PlatformTransactionManager transactionManager(final EntityManagerFactory emf) { + final JpaTransactionManager transactionManager = new JpaTransactionManager(); + transactionManager.setEntityManagerFactory(emf); + return transactionManager; + } + + @Bean + public PersistenceExceptionTranslationPostProcessor exceptionTranslation() { + return new PersistenceExceptionTranslationPostProcessor(); + } + + final Properties additionalProperties() { + final Properties hibernateProperties = new Properties(); + hibernateProperties.setProperty("hibernate.hbm2ddl.auto", env.getProperty("hibernate.hbm2ddl.auto")); + hibernateProperties.setProperty("hibernate.dialect", env.getProperty("hibernate.dialect")); + hibernateProperties.setProperty("hibernate.cache.use_second_level_cache", "false"); + + + return hibernateProperties; + } + +} \ No newline at end of file diff --git a/persistence-modules/spring-persistence-simple/src/main/java/org/baeldung/persistence/dao/AbstractJpaDAO.java b/persistence-modules/spring-persistence-simple/src/main/java/org/baeldung/persistence/dao/AbstractJpaDAO.java new file mode 100644 index 0000000000..13007d9fcc --- /dev/null +++ b/persistence-modules/spring-persistence-simple/src/main/java/org/baeldung/persistence/dao/AbstractJpaDAO.java @@ -0,0 +1,46 @@ +package org.baeldung.persistence.dao; + +import java.io.Serializable; +import java.util.List; + +import javax.persistence.EntityManager; +import javax.persistence.PersistenceContext; + +public abstract class AbstractJpaDAO { + + private Class clazz; + + @PersistenceContext + private EntityManager entityManager; + + public final void setClazz(final Class clazzToSet) { + this.clazz = clazzToSet; + } + + public T findOne(final long id) { + return entityManager.find(clazz, id); + } + + @SuppressWarnings("unchecked") + public List findAll() { + return entityManager.createQuery("from " + clazz.getName()).getResultList(); + } + + public void create(final T entity) { + entityManager.persist(entity); + } + + public T update(final T entity) { + return entityManager.merge(entity); + } + + public void delete(final T entity) { + entityManager.remove(entity); + } + + public void deleteById(final long entityId) { + final T entity = findOne(entityId); + delete(entity); + } + +} \ No newline at end of file diff --git a/persistence-modules/spring-persistence-simple/src/main/java/org/baeldung/persistence/dao/FooDao.java b/persistence-modules/spring-persistence-simple/src/main/java/org/baeldung/persistence/dao/FooDao.java new file mode 100644 index 0000000000..77978c5cf2 --- /dev/null +++ b/persistence-modules/spring-persistence-simple/src/main/java/org/baeldung/persistence/dao/FooDao.java @@ -0,0 +1,17 @@ +package org.baeldung.persistence.dao; + +import org.baeldung.persistence.model.Foo; +import org.springframework.stereotype.Repository; + +@Repository +public class FooDao extends AbstractJpaDAO implements IFooDao { + + public FooDao() { + super(); + + setClazz(Foo.class); + } + + // API + +} diff --git a/persistence-modules/spring-persistence-simple/src/main/java/org/baeldung/persistence/dao/IFooDao.java b/persistence-modules/spring-persistence-simple/src/main/java/org/baeldung/persistence/dao/IFooDao.java new file mode 100644 index 0000000000..f5799522e2 --- /dev/null +++ b/persistence-modules/spring-persistence-simple/src/main/java/org/baeldung/persistence/dao/IFooDao.java @@ -0,0 +1,21 @@ +package org.baeldung.persistence.dao; + +import java.util.List; + +import org.baeldung.persistence.model.Foo; + +public interface IFooDao { + + Foo findOne(long id); + + List findAll(); + + void create(Foo entity); + + Foo update(Foo entity); + + void delete(Foo entity); + + void deleteById(long entityId); + +} diff --git a/persistence-modules/spring-persistence-simple/src/main/java/org/baeldung/persistence/model/Bar.java b/persistence-modules/spring-persistence-simple/src/main/java/org/baeldung/persistence/model/Bar.java new file mode 100644 index 0000000000..b602e57562 --- /dev/null +++ b/persistence-modules/spring-persistence-simple/src/main/java/org/baeldung/persistence/model/Bar.java @@ -0,0 +1,102 @@ +package org.baeldung.persistence.model; + +import java.io.Serializable; +import java.util.List; + +import javax.persistence.CascadeType; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.FetchType; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.OneToMany; +import javax.persistence.OrderBy; + +@Entity +public class Bar implements Serializable { + private static final long serialVersionUID = 1L; + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private long id; + + @Column(nullable = false) + private String name; + + @OneToMany(mappedBy = "bar", fetch = FetchType.EAGER, cascade = CascadeType.ALL) + @OrderBy("name ASC") + List fooList; + + public Bar() { + super(); + } + + public Bar(final String name) { + super(); + + this.name = name; + } + + // API + + public long getId() { + return id; + } + + public void setId(final long id) { + + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(final String name) { + this.name = name; + } + + public List getFooList() { + return fooList; + } + + public void setFooList(final List fooList) { + this.fooList = fooList; + } + + // + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((name == null) ? 0 : name.hashCode()); + return result; + } + + @Override + public boolean equals(final Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + final Bar other = (Bar) obj; + if (name == null) { + if (other.name != null) + return false; + } else if (!name.equals(other.name)) + return false; + return true; + } + + @Override + public String toString() { + final StringBuilder builder = new StringBuilder(); + builder.append("Bar [name=").append(name).append("]"); + return builder.toString(); + } + +} diff --git a/persistence-modules/spring-persistence-simple/src/main/java/org/baeldung/persistence/model/Foo.java b/persistence-modules/spring-persistence-simple/src/main/java/org/baeldung/persistence/model/Foo.java new file mode 100644 index 0000000000..5294860311 --- /dev/null +++ b/persistence-modules/spring-persistence-simple/src/main/java/org/baeldung/persistence/model/Foo.java @@ -0,0 +1,92 @@ +package org.baeldung.persistence.model; + +import org.hibernate.annotations.CacheConcurrencyStrategy; + +import javax.persistence.*; +import java.io.Serializable; + +@Entity +@Cacheable +@org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.READ_WRITE) +public class Foo implements Serializable { + + private static final long serialVersionUID = 1L; + + public Foo() { + super(); + } + + public Foo(final String name) { + super(); + + this.name = name; + } + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name = "ID") + private Long id; + @Column(name = "NAME") + private String name; + + @ManyToOne(targetEntity = Bar.class, fetch = FetchType.EAGER) + @JoinColumn(name = "BAR_ID") + private Bar bar; + + public Bar getBar() { + return bar; + } + + public void setBar(final Bar bar) { + this.bar = bar; + } + + public Long getId() { + return id; + } + + public void setId(final Long id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(final String name) { + this.name = name; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((name == null) ? 0 : name.hashCode()); + return result; + } + + @Override + public boolean equals(final Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + final Foo other = (Foo) obj; + if (name == null) { + if (other.name != null) + return false; + } else if (!name.equals(other.name)) + return false; + return true; + } + + @Override + public String toString() { + final StringBuilder builder = new StringBuilder(); + builder.append("Foo [name=").append(name).append("]"); + return builder.toString(); + } + +} diff --git a/persistence-modules/spring-persistence-simple/src/main/java/org/baeldung/persistence/service/FooService.java b/persistence-modules/spring-persistence-simple/src/main/java/org/baeldung/persistence/service/FooService.java new file mode 100644 index 0000000000..6d1bb0adbe --- /dev/null +++ b/persistence-modules/spring-persistence-simple/src/main/java/org/baeldung/persistence/service/FooService.java @@ -0,0 +1,36 @@ +package org.baeldung.persistence.service; + +import java.util.List; + +import org.baeldung.persistence.dao.IFooDao; +import org.baeldung.persistence.model.Foo; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +@Service +@Transactional +public class FooService { + + @Autowired + private IFooDao dao; + + public FooService() { + super(); + } + + // API + + public void create(final Foo entity) { + dao.create(entity); + } + + public Foo findOne(final long id) { + return dao.findOne(id); + } + + public List findAll() { + return dao.findAll(); + } + +} diff --git a/persistence-modules/spring-persistence-simple/src/main/resources/logback.xml b/persistence-modules/spring-persistence-simple/src/main/resources/logback.xml new file mode 100644 index 0000000000..ec0dc2469a --- /dev/null +++ b/persistence-modules/spring-persistence-simple/src/main/resources/logback.xml @@ -0,0 +1,19 @@ + + + + + web - %date [%thread] %-5level %logger{36} - %message%n + + + + + + + + + + + + + + \ No newline at end of file diff --git a/persistence-modules/spring-persistence-simple/src/main/resources/persistence-h2.properties b/persistence-modules/spring-persistence-simple/src/main/resources/persistence-h2.properties new file mode 100644 index 0000000000..716a96fde3 --- /dev/null +++ b/persistence-modules/spring-persistence-simple/src/main/resources/persistence-h2.properties @@ -0,0 +1,13 @@ +# jdbc.X +jdbc.driverClassName=org.h2.Driver +jdbc.url=jdbc:h2:mem:db;DB_CLOSE_DELAY=-1 +jdbc.user=sa +jdbc.pass= + +# hibernate.X +hibernate.dialect=org.hibernate.dialect.H2Dialect +hibernate.show_sql=true +hibernate.hbm2ddl.auto=create-drop +hibernate.cache.use_second_level_cache=true +hibernate.cache.use_query_cache=true +hibernate.cache.region.factory_class=org.hibernate.cache.ehcache.EhCacheRegionFactory \ No newline at end of file diff --git a/persistence-modules/spring-persistence-simple/src/main/resources/persistence.xml b/persistence-modules/spring-persistence-simple/src/main/resources/persistence.xml new file mode 100644 index 0000000000..6304fa0a65 --- /dev/null +++ b/persistence-modules/spring-persistence-simple/src/main/resources/persistence.xml @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + ${hibernate.hbm2ddl.auto} + ${hibernate.dialect} + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/persistence-modules/spring-persistence-simple/src/test/java/org/baeldung/persistence/service/FooPaginationPersistenceIntegrationTest.java b/persistence-modules/spring-persistence-simple/src/test/java/org/baeldung/persistence/service/FooPaginationPersistenceIntegrationTest.java new file mode 100644 index 0000000000..76c34affb9 --- /dev/null +++ b/persistence-modules/spring-persistence-simple/src/test/java/org/baeldung/persistence/service/FooPaginationPersistenceIntegrationTest.java @@ -0,0 +1,157 @@ +package org.baeldung.persistence.service; + +import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic; +import static org.hamcrest.Matchers.hasSize; +import static org.hamcrest.Matchers.lessThan; +import static org.junit.Assert.assertThat; + +import java.util.List; + +import javax.persistence.EntityManager; +import javax.persistence.PersistenceContext; +import javax.persistence.Query; +import javax.persistence.TypedQuery; +import javax.persistence.criteria.CriteriaBuilder; +import javax.persistence.criteria.CriteriaQuery; +import javax.persistence.criteria.Root; + +import org.baeldung.config.PersistenceJPAConfig; +import org.baeldung.persistence.model.Foo; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.annotation.DirtiesContext; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.support.AnnotationConfigContextLoader; + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = { PersistenceJPAConfig.class }, loader = AnnotationConfigContextLoader.class) +@DirtiesContext +public class FooPaginationPersistenceIntegrationTest { + + @PersistenceContext + private EntityManager entityManager; + + @Autowired + private FooService fooService; + + @Before + public final void before() { + final int minimalNumberOfEntities = 25; + if (fooService.findAll().size() <= minimalNumberOfEntities) { + for (int i = 0; i < minimalNumberOfEntities; i++) { + fooService.create(new Foo(randomAlphabetic(6))); + } + } + } + + // tests + + @Test + public final void whenContextIsBootstrapped_thenNoExceptions() { + // + } + + @SuppressWarnings("unchecked") + @Test + public final void givenEntitiesExist_whenRetrievingFirstPage_thenCorrect() { + final int pageSize = 10; + + final Query query = entityManager.createQuery("From Foo"); + configurePagination(query, 1, pageSize); + + // When + final List fooList = query.getResultList(); + + // Then + assertThat(fooList, hasSize(pageSize)); + } + + @SuppressWarnings("unchecked") + @Test + public final void givenEntitiesExist_whenRetrievingLastPage_thenCorrect() { + final int pageSize = 10; + final Query queryTotal = entityManager.createQuery("Select count(f.id) from Foo f"); + final long countResult = (long) queryTotal.getSingleResult(); + + final Query query = entityManager.createQuery("Select f from Foo as f order by f.id"); + final int lastPage = (int) ((countResult / pageSize) + 1); + configurePagination(query, lastPage, pageSize); + final List fooList = query.getResultList(); + + // Then + assertThat(fooList, hasSize(lessThan(pageSize + 1))); + } + + @SuppressWarnings("unchecked") + @Test + public final void givenEntitiesExist_whenRetrievingPage_thenCorrect() { + final int pageSize = 10; + + final Query queryIds = entityManager.createQuery("Select f.id from Foo f order by f.name"); + final List fooIds = queryIds.getResultList(); + + final Query query = entityManager.createQuery("Select f from Foo as f where f.id in :ids"); + query.setParameter("ids", fooIds.subList(0, pageSize)); + + final List fooList = query.getResultList(); + + // Then + assertThat(fooList, hasSize(pageSize)); + } + + @Test + public final void givenEntitiesExist_whenRetrievingPageViaCriteria_thenCorrect() { + final int pageSize = 10; + final CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder(); + final CriteriaQuery criteriaQuery = criteriaBuilder.createQuery(Foo.class); + final Root from = criteriaQuery.from(Foo.class); + final CriteriaQuery select = criteriaQuery.select(from); + final TypedQuery typedQuery = entityManager.createQuery(select); + typedQuery.setFirstResult(0); + typedQuery.setMaxResults(pageSize); + final List fooList = typedQuery.getResultList(); + + // Then + assertThat(fooList, hasSize(pageSize)); + } + + @Test + public final void givenEntitiesExist_whenRetrievingPageViaCriteria_thenNoExceptions() { + int pageNumber = 1; + final int pageSize = 10; + final CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder(); + + final CriteriaQuery countQuery = criteriaBuilder.createQuery(Long.class); + countQuery.select(criteriaBuilder.count(countQuery.from(Foo.class))); + final Long count = entityManager.createQuery(countQuery).getSingleResult(); + + final CriteriaQuery criteriaQuery = criteriaBuilder.createQuery(Foo.class); + final Root from = criteriaQuery.from(Foo.class); + final CriteriaQuery select = criteriaQuery.select(from); + + TypedQuery typedQuery; + while (pageNumber < count.intValue()) { + typedQuery = entityManager.createQuery(select); + typedQuery.setFirstResult(pageNumber - 1); + typedQuery.setMaxResults(pageSize); + System.out.println("Current page: " + typedQuery.getResultList()); + pageNumber += pageSize; + } + + } + + // UTIL + + final int determineLastPage(final int pageSize, final long countResult) { + return (int) (countResult / pageSize) + 1; + } + + final void configurePagination(final Query query, final int pageNumber, final int pageSize) { + query.setFirstResult((pageNumber - 1) * pageSize); + query.setMaxResults(pageSize); + } + +} diff --git a/persistence-modules/spring-persistence-simple/src/test/java/org/baeldung/persistence/service/FooServicePersistenceIntegrationTest.java b/persistence-modules/spring-persistence-simple/src/test/java/org/baeldung/persistence/service/FooServicePersistenceIntegrationTest.java new file mode 100644 index 0000000000..e1b53c8ded --- /dev/null +++ b/persistence-modules/spring-persistence-simple/src/test/java/org/baeldung/persistence/service/FooServicePersistenceIntegrationTest.java @@ -0,0 +1,69 @@ +package org.baeldung.persistence.service; + +import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic; + +import org.baeldung.config.PersistenceJPAConfig; +import org.baeldung.persistence.model.Foo; +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.dao.DataAccessException; +import org.springframework.dao.DataIntegrityViolationException; +import org.springframework.dao.InvalidDataAccessApiUsageException; +import org.springframework.test.annotation.DirtiesContext; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.support.AnnotationConfigContextLoader; + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = { PersistenceJPAConfig.class }, loader = AnnotationConfigContextLoader.class) +@DirtiesContext +public class FooServicePersistenceIntegrationTest { + + @Autowired + private FooService service; + + // tests + + @Test + public final void whenContextIsBootstrapped_thenNoExceptions() { + // + } + + @Test + public final void whenEntityIsCreated_thenNoExceptions() { + service.create(new Foo(randomAlphabetic(6))); + } + + @Test(expected = DataIntegrityViolationException.class) + public final void whenInvalidEntityIsCreated_thenDataException() { + service.create(new Foo(randomAlphabetic(2048))); + } + + @Test(expected = DataIntegrityViolationException.class) + public final void whenEntityWithLongNameIsCreated_thenDataException() { + service.create(new Foo(randomAlphabetic(2048))); + } + + @Test(expected = InvalidDataAccessApiUsageException.class) + public final void whenSameEntityIsCreatedTwice_thenDataException() { + final Foo entity = new Foo(randomAlphabetic(8)); + service.create(entity); + service.create(entity); + } + + @Test(expected = DataAccessException.class) + public final void temp_whenInvalidEntityIsCreated_thenDataException() { + service.create(new Foo(randomAlphabetic(2048))); + } + + @Test + public final void whenEntityIsCreated_thenFound() { + final Foo fooEntity = new Foo("abc"); + service.create(fooEntity); + final Foo found = service.findOne(fooEntity.getId()); + Assert.assertNotNull(found); + } + +} diff --git a/persistence-modules/spring-persistence-simple/src/test/java/org/baeldung/persistence/service/FooServiceSortingIntegrationTest.java b/persistence-modules/spring-persistence-simple/src/test/java/org/baeldung/persistence/service/FooServiceSortingIntegrationTest.java new file mode 100644 index 0000000000..40249b4b30 --- /dev/null +++ b/persistence-modules/spring-persistence-simple/src/test/java/org/baeldung/persistence/service/FooServiceSortingIntegrationTest.java @@ -0,0 +1,118 @@ +package org.baeldung.persistence.service; + +import java.util.List; + +import javax.persistence.EntityManager; +import javax.persistence.PersistenceContext; +import javax.persistence.Query; +import javax.persistence.TypedQuery; +import javax.persistence.criteria.CriteriaBuilder; +import javax.persistence.criteria.CriteriaQuery; +import javax.persistence.criteria.Root; + +import org.baeldung.config.PersistenceJPAConfig; +import org.baeldung.persistence.model.Bar; +import org.baeldung.persistence.model.Foo; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.test.annotation.DirtiesContext; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.support.AnnotationConfigContextLoader; + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = { PersistenceJPAConfig.class }, loader = AnnotationConfigContextLoader.class) +@DirtiesContext +@SuppressWarnings("unchecked") +public class FooServiceSortingIntegrationTest { + + @PersistenceContext + private EntityManager entityManager; + + // tests + + @Test + public final void whenSortingByOneAttributeDefaultOrder_thenPrintSortedResult() { + final String jql = "Select f from Foo as f order by f.id"; + final Query sortQuery = entityManager.createQuery(jql); + final List fooList = sortQuery.getResultList(); + for (final Foo foo : fooList) { + System.out.println("Name:" + foo.getName() + "-------Id:" + foo.getId()); + } + } + + @Test + public final void whenSortingByOneAttributeSetOrder_thenSortedPrintResult() { + final String jql = "Select f from Foo as f order by f.id desc"; + final Query sortQuery = entityManager.createQuery(jql); + final List fooList = sortQuery.getResultList(); + for (final Foo foo : fooList) { + System.out.println("Name:" + foo.getName() + "-------Id:" + foo.getId()); + } + } + + @Test + public final void whenSortingByTwoAttributes_thenPrintSortedResult() { + final String jql = "Select f from Foo as f order by f.name asc, f.id desc"; + final Query sortQuery = entityManager.createQuery(jql); + final List fooList = sortQuery.getResultList(); + for (final Foo foo : fooList) { + System.out.println("Name:" + foo.getName() + "-------Id:" + foo.getId()); + } + } + + @Test + public final void whenSortingFooByBar_thenBarsSorted() { + final String jql = "Select f from Foo as f order by f.name, f.bar.id"; + final Query barJoinQuery = entityManager.createQuery(jql); + final List fooList = barJoinQuery.getResultList(); + for (final Foo foo : fooList) { + System.out.println("Name:" + foo.getName()); + if (foo.getBar() != null) { + System.out.print("-------BarId:" + foo.getBar().getId()); + } + } + } + + @Test + public final void whenSortinfBar_thenPrintBarsSortedWithFoos() { + final String jql = "Select b from Bar as b order by b.id"; + final Query barQuery = entityManager.createQuery(jql); + final List barList = barQuery.getResultList(); + for (final Bar bar : barList) { + System.out.println("Bar Id:" + bar.getId()); + for (final Foo foo : bar.getFooList()) { + System.out.println("FooName:" + foo.getName()); + } + } + } + + @Test + public final void whenSortingFooWithCriteria_thenPrintSortedFoos() { + final CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder(); + final CriteriaQuery criteriaQuery = criteriaBuilder.createQuery(Foo.class); + final Root from = criteriaQuery.from(Foo.class); + final CriteriaQuery select = criteriaQuery.select(from); + criteriaQuery.orderBy(criteriaBuilder.asc(from.get("name"))); + final TypedQuery typedQuery = entityManager.createQuery(select); + final List fooList = typedQuery.getResultList(); + for (final Foo foo : fooList) { + System.out.println("Name:" + foo.getName() + "--------Id:" + foo.getId()); + } + } + + @Test + public final void whenSortingFooWithCriteriaAndMultipleAttributes_thenPrintSortedFoos() { + final CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder(); + final CriteriaQuery criteriaQuery = criteriaBuilder.createQuery(Foo.class); + final Root from = criteriaQuery.from(Foo.class); + final CriteriaQuery select = criteriaQuery.select(from); + criteriaQuery.orderBy(criteriaBuilder.asc(from.get("name")), criteriaBuilder.desc(from.get("id"))); + final TypedQuery typedQuery = entityManager.createQuery(select); + final List fooList = typedQuery.getResultList(); + for (final Foo foo : fooList) { + System.out.println("Name:" + foo.getName() + "-------Id:" + foo.getId()); + } + } + +} diff --git a/persistence-modules/spring-persistence-simple/src/test/java/org/baeldung/persistence/service/FooServiceSortingWitNullsManualIntegrationTest.java b/persistence-modules/spring-persistence-simple/src/test/java/org/baeldung/persistence/service/FooServiceSortingWitNullsManualIntegrationTest.java new file mode 100644 index 0000000000..c530003ac1 --- /dev/null +++ b/persistence-modules/spring-persistence-simple/src/test/java/org/baeldung/persistence/service/FooServiceSortingWitNullsManualIntegrationTest.java @@ -0,0 +1,64 @@ +package org.baeldung.persistence.service; + +import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic; +import static org.junit.Assert.assertNull; + +import java.util.List; + +import javax.persistence.EntityManager; +import javax.persistence.PersistenceContext; +import javax.persistence.Query; + +import org.baeldung.config.PersistenceJPAConfig; +import org.baeldung.persistence.model.Foo; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.annotation.DirtiesContext; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.support.AnnotationConfigContextLoader; + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = { PersistenceJPAConfig.class }, loader = AnnotationConfigContextLoader.class) +@DirtiesContext +public class FooServiceSortingWitNullsManualIntegrationTest { + + @PersistenceContext + private EntityManager entityManager; + + @Autowired + private FooService service; + + // tests + + @SuppressWarnings("unchecked") + @Test + public final void whenSortingByStringNullLast_thenLastNull() { + service.create(new Foo()); + service.create(new Foo(randomAlphabetic(6))); + + final String jql = "Select f from Foo as f order by f.name desc NULLS LAST"; + final Query sortQuery = entityManager.createQuery(jql); + final List fooList = sortQuery.getResultList(); + assertNull(fooList.get(fooList.toArray().length - 1).getName()); + for (final Foo foo : fooList) { + System.out.println("Name:" + foo.getName()); + } + } + + @SuppressWarnings("unchecked") + @Test + public final void whenSortingByStringNullFirst_thenFirstNull() { + service.create(new Foo()); + + final String jql = "Select f from Foo as f order by f.name desc NULLS FIRST"; + final Query sortQuery = entityManager.createQuery(jql); + final List fooList = sortQuery.getResultList(); + assertNull(fooList.get(0).getName()); + for (final Foo foo : fooList) { + System.out.println("Name:" + foo.getName()); + } + } + +} diff --git a/persistence-modules/spring-persistence-simple/src/test/resources/.gitignore b/persistence-modules/spring-persistence-simple/src/test/resources/.gitignore new file mode 100644 index 0000000000..83c05e60c8 --- /dev/null +++ b/persistence-modules/spring-persistence-simple/src/test/resources/.gitignore @@ -0,0 +1,13 @@ +*.class + +#folders# +/target +/neoDb* +/data +/src/main/webapp/WEB-INF/classes +*/META-INF/* + +# Packaged files # +*.jar +*.war +*.ear \ No newline at end of file diff --git a/pom.xml b/pom.xml index b896514b3a..2ea5e4505c 100644 --- a/pom.xml +++ b/pom.xml @@ -12,7 +12,7 @@ lombok-custom - picocli + quarkus @@ -380,32 +380,33 @@ core-groovy core-groovy-2 core-groovy-collections - - - - core-java-8 - core-java-8-2 - core-java-lambdas - - - core-java-arrays - core-java-collections - core-java-collections-list - core-java-collections-set - core-java-concurrency-basic - core-java-concurrency-collections - core-java-io - core-java-security - core-java-lang-syntax - core-java-lang - core-java-lang-oop - core-java-lang-oop-2 + + + + core-java-modules/core-java-8 + core-java-modules/core-java-8-2 + core-java-modules/core-java-lambdas + + + core-java-modules/core-java-arrays + core-java-modules/core-java-collections + core-java-modules/core-java-collections-list + core-java-modules/core-java-collections-set + core-java-modules/core-java-concurrency-basic + core-java-modules/core-java-concurrency-collections + core-java-modules/core-java-io + core-java-modules/core-java-security + core-java-modules/core-java-lang-syntax + core-java-modules/core-java-lang + core-java-modules/core-java-lang-oop + core-java-modules/core-java-lang-oop-2 core-java-modules - core-java-networking - core-java-perf - core-java-sun - core-java - core-java-jvm + core-java-modules/core-java-networking + core-java-modules/core-java-perf + core-java-modules/core-java-reflection + core-java-modules/core-java-sun + core-java-modules/core-java + core-java-modules/core-java-jvm core-scala couchbase custom-pmd @@ -534,6 +535,7 @@ protobuffer persistence-modules + quarkus rabbitmq @@ -606,6 +608,7 @@ spring-5-reactive-security spring-5-security spring-5-security-oauth + spring-5-security-cognito spring-activiti spring-akka @@ -817,6 +820,7 @@ spring-5-reactive-security spring-5-security spring-5-security-oauth + spring-5-security-cognito spring-activiti spring-akka spring-all @@ -967,7 +971,7 @@ parent-java parent-kotlin - core-java-concurrency-advanced + core-java-modules/core-java-concurrency-advanced core-kotlin core-kotlin-2 core-kotlin-io @@ -1060,28 +1064,28 @@ core-groovy core-groovy-2 core-groovy-collections - - - core-java-8 - core-java-8-2 - - - core-java-arrays - core-java-collections - core-java-collections-list - core-java-collections-set - core-java-concurrency-basic - core-java-concurrency-collections - core-java-io - core-java-security - core-java-lang-syntax - core-java-lang - core-java-lang-oop - core-java-lang-oop-2 + + + core-java-modules/core-java-8 + core-java-modules/core-java-8-2 + + + core-java-modules/core-java-arrays + core-java-modules/core-java-collections + core-java-modules/core-java-collections-list + core-java-modules/core-java-collections-set + core-java-modules/core-java-concurrency-basic + core-java-modules/core-java-concurrency-collections + core-java-modules/core-java-io + core-java-modules/core-java-security + core-java-modules/core-java-lang-syntax + core-java-modules/core-java-lang + core-java-modules/core-java-lang-oop + core-java-modules/core-java-lang-oop-2 core-java-modules - core-java-networking - core-java-perf - core-java-sun + core-java-modules/core-java-networking + core-java-modules/core-java-perf + core-java-modules/core-java-sun core-scala couchbase custom-pmd @@ -1269,7 +1273,7 @@ spring-5-reactive-security spring-5-security spring-5-security-oauth - + spring-5-security-cognito spring-activiti spring-akka spring-all @@ -1474,8 +1478,8 @@ parent-java parent-kotlin - core-java - core-java-concurrency-advanced + core-java-modules/core-java + core-java-modules/core-java-concurrency-advanced core-kotlin core-kotlin-2 @@ -1510,7 +1514,7 @@ UTF-8 UTF-8 - refs/remotes/origin/master + refs/remotes/origin/master true false false @@ -1558,5 +1562,6 @@ 3.8 1.16.12 + 1.4.197 diff --git a/quarkus/.dockerignore b/quarkus/.dockerignore new file mode 100644 index 0000000000..b86c7ac340 --- /dev/null +++ b/quarkus/.dockerignore @@ -0,0 +1,4 @@ +* +!target/*-runner +!target/*-runner.jar +!target/lib/* \ No newline at end of file diff --git a/quarkus/.mvn/wrapper/MavenWrapperDownloader.java b/quarkus/.mvn/wrapper/MavenWrapperDownloader.java new file mode 100755 index 0000000000..b20a55a7a9 --- /dev/null +++ b/quarkus/.mvn/wrapper/MavenWrapperDownloader.java @@ -0,0 +1,117 @@ +/* + * Copyright 2007-present the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import java.net.*; +import java.io.*; +import java.nio.channels.*; +import java.util.Properties; + +public class MavenWrapperDownloader { + + private static final String WRAPPER_VERSION = "0.5.3"; + /** + * Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided. + */ + private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/" + + WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + " .jar"; + + /** + * Path to the maven-wrapper.properties file, which might contain a downloadUrl property to + * use instead of the default one. + */ + private static final String MAVEN_WRAPPER_PROPERTIES_PATH = + ".mvn/wrapper/maven-wrapper.properties"; + + /** + * Path where the maven-wrapper.jar will be saved to. + */ + private static final String MAVEN_WRAPPER_JAR_PATH = + ".mvn/wrapper/maven-wrapper.jar"; + + /** + * Name of the property which should be used to override the default download url for the wrapper. + */ + private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl"; + + public static void main(String args[]) { + System.out.println("- Downloader started"); + File baseDirectory = new File(args[0]); + System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath()); + + // If the maven-wrapper.properties exists, read it and check if it contains a custom + // wrapperUrl parameter. + File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH); + String url = DEFAULT_DOWNLOAD_URL; + if(mavenWrapperPropertyFile.exists()) { + FileInputStream mavenWrapperPropertyFileInputStream = null; + try { + mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile); + Properties mavenWrapperProperties = new Properties(); + mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream); + url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url); + } catch (IOException e) { + System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'"); + } finally { + try { + if(mavenWrapperPropertyFileInputStream != null) { + mavenWrapperPropertyFileInputStream.close(); + } + } catch (IOException e) { + // Ignore ... + } + } + } + System.out.println("- Downloading from: " + url); + + File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH); + if(!outputFile.getParentFile().exists()) { + if(!outputFile.getParentFile().mkdirs()) { + System.out.println( + "- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'"); + } + } + System.out.println("- Downloading to: " + outputFile.getAbsolutePath()); + try { + downloadFileFromURL(url, outputFile); + System.out.println("Done"); + System.exit(0); + } catch (Throwable e) { + System.out.println("- Error downloading"); + e.printStackTrace(); + System.exit(1); + } + } + + private static void downloadFileFromURL(String urlString, File destination) throws Exception { + if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) { + String username = System.getenv("MVNW_USERNAME"); + char[] password = System.getenv("MVNW_PASSWORD").toCharArray(); + Authenticator.setDefault(new Authenticator() { + @Override + protected PasswordAuthentication getPasswordAuthentication() { + return new PasswordAuthentication(username, password); + } + }); + } + URL website = new URL(urlString); + ReadableByteChannel rbc; + rbc = Channels.newChannel(website.openStream()); + FileOutputStream fos = new FileOutputStream(destination); + fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); + fos.close(); + rbc.close(); + } + +} diff --git a/quarkus/.mvn/wrapper/maven-wrapper.jar b/quarkus/.mvn/wrapper/maven-wrapper.jar new file mode 100755 index 0000000000..e89f07c229 Binary files /dev/null and b/quarkus/.mvn/wrapper/maven-wrapper.jar differ diff --git a/quarkus/.mvn/wrapper/maven-wrapper.properties b/quarkus/.mvn/wrapper/maven-wrapper.properties new file mode 100755 index 0000000000..1703626ce7 --- /dev/null +++ b/quarkus/.mvn/wrapper/maven-wrapper.properties @@ -0,0 +1,2 @@ +distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip +wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.3/maven-wrapper-0.5.3.jar diff --git a/quarkus/mvnw b/quarkus/mvnw new file mode 100755 index 0000000000..34d9dae8d0 --- /dev/null +++ b/quarkus/mvnw @@ -0,0 +1,305 @@ +#!/bin/sh +# ---------------------------------------------------------------------------- +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# ---------------------------------------------------------------------------- + +# ---------------------------------------------------------------------------- +# Maven2 Start Up Batch script +# +# Required ENV vars: +# ------------------ +# JAVA_HOME - location of a JDK home dir +# +# Optional ENV vars +# ----------------- +# M2_HOME - location of maven2's installed home dir +# MAVEN_OPTS - parameters passed to the Java VM when running Maven +# e.g. to debug Maven itself, use +# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +# MAVEN_SKIP_RC - flag to disable loading of mavenrc files +# ---------------------------------------------------------------------------- + +if [ -z "$MAVEN_SKIP_RC" ] ; then + + if [ -f /etc/mavenrc ] ; then + . /etc/mavenrc + fi + + if [ -f "$HOME/.mavenrc" ] ; then + . "$HOME/.mavenrc" + fi + +fi + +# OS specific support. $var _must_ be set to either true or false. +cygwin=false; +darwin=false; +mingw=false +case "`uname`" in + CYGWIN*) cygwin=true ;; + MINGW*) mingw=true;; + Darwin*) darwin=true + # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home + # See https://developer.apple.com/library/mac/qa/qa1170/_index.html + if [ -z "$JAVA_HOME" ]; then + if [ -x "/usr/libexec/java_home" ]; then + export JAVA_HOME="`/usr/libexec/java_home`" + else + export JAVA_HOME="/Library/Java/Home" + fi + fi + ;; +esac + +if [ -z "$JAVA_HOME" ] ; then + if [ -r /etc/gentoo-release ] ; then + JAVA_HOME=`java-config --jre-home` + fi +fi + +if [ -z "$M2_HOME" ] ; then + ## resolve links - $0 may be a link to maven's home + PRG="$0" + + # need this for relative symlinks + while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG="`dirname "$PRG"`/$link" + fi + done + + saveddir=`pwd` + + M2_HOME=`dirname "$PRG"`/.. + + # make it fully qualified + M2_HOME=`cd "$M2_HOME" && pwd` + + cd "$saveddir" + # echo Using m2 at $M2_HOME +fi + +# For Cygwin, ensure paths are in UNIX format before anything is touched +if $cygwin ; then + [ -n "$M2_HOME" ] && + M2_HOME=`cygpath --unix "$M2_HOME"` + [ -n "$JAVA_HOME" ] && + JAVA_HOME=`cygpath --unix "$JAVA_HOME"` + [ -n "$CLASSPATH" ] && + CLASSPATH=`cygpath --path --unix "$CLASSPATH"` +fi + +# For Mingw, ensure paths are in UNIX format before anything is touched +if $mingw ; then + [ -n "$M2_HOME" ] && + M2_HOME="`(cd "$M2_HOME"; pwd)`" + [ -n "$JAVA_HOME" ] && + JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" +fi + +if [ -z "$JAVA_HOME" ]; then + javaExecutable="`which javac`" + if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then + # readlink(1) is not available as standard on Solaris 10. + readLink=`which readlink` + if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then + if $darwin ; then + javaHome="`dirname \"$javaExecutable\"`" + javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" + else + javaExecutable="`readlink -f \"$javaExecutable\"`" + fi + javaHome="`dirname \"$javaExecutable\"`" + javaHome=`expr "$javaHome" : '\(.*\)/bin'` + JAVA_HOME="$javaHome" + export JAVA_HOME + fi + fi +fi + +if [ -z "$JAVACMD" ] ; then + if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + else + JAVACMD="`which java`" + fi +fi + +if [ ! -x "$JAVACMD" ] ; then + echo "Error: JAVA_HOME is not defined correctly." >&2 + echo " We cannot execute $JAVACMD" >&2 + exit 1 +fi + +if [ -z "$JAVA_HOME" ] ; then + echo "Warning: JAVA_HOME environment variable is not set." +fi + +CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher + +# traverses directory structure from process work directory to filesystem root +# first directory with .mvn subdirectory is considered project base directory +find_maven_basedir() { + + if [ -z "$1" ] + then + echo "Path not specified to find_maven_basedir" + return 1 + fi + + basedir="$1" + wdir="$1" + while [ "$wdir" != '/' ] ; do + if [ -d "$wdir"/.mvn ] ; then + basedir=$wdir + break + fi + # workaround for JBEAP-8937 (on Solaris 10/Sparc) + if [ -d "${wdir}" ]; then + wdir=`cd "$wdir/.."; pwd` + fi + # end of workaround + done + echo "${basedir}" +} + +# concatenates all lines of a file +concat_lines() { + if [ -f "$1" ]; then + echo "$(tr -s '\n' ' ' < "$1")" + fi +} + +BASE_DIR=`find_maven_basedir "$(pwd)"` +if [ -z "$BASE_DIR" ]; then + exit 1; +fi + +########################################################################################## +# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central +# This allows using the maven wrapper in projects that prohibit checking in binary data. +########################################################################################## +if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found .mvn/wrapper/maven-wrapper.jar" + fi +else + if [ "$MVNW_VERBOSE" = true ]; then + echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..." + fi + if [ -n "$MVNW_REPOURL" ]; then + jarUrl="$MVNW_REPOURL/io/takari/maven-wrapper/0.5.3/maven-wrapper-0.5.3.jar" + else + jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.3/maven-wrapper-0.5.3.jar" + fi + while IFS="=" read key value; do + case "$key" in (wrapperUrl) jarUrl="$value"; break ;; + esac + done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties" + if [ "$MVNW_VERBOSE" = true ]; then + echo "Downloading from: $jarUrl" + fi + wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" + if $cygwin; then + wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"` + fi + + if command -v wget > /dev/null; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found wget ... using wget" + fi + if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then + wget "$jarUrl" -O "$wrapperJarPath" + else + wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath" + fi + elif command -v curl > /dev/null; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found curl ... using curl" + fi + if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then + curl -o "$wrapperJarPath" "$jarUrl" -f + else + curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f + fi + + else + if [ "$MVNW_VERBOSE" = true ]; then + echo "Falling back to using Java to download" + fi + javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java" + # For Cygwin, switch paths to Windows format before running javac + if $cygwin; then + javaClass=`cygpath --path --windows "$javaClass"` + fi + if [ -e "$javaClass" ]; then + if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then + if [ "$MVNW_VERBOSE" = true ]; then + echo " - Compiling MavenWrapperDownloader.java ..." + fi + # Compiling the Java class + ("$JAVA_HOME/bin/javac" "$javaClass") + fi + if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then + # Running the downloader + if [ "$MVNW_VERBOSE" = true ]; then + echo " - Running MavenWrapperDownloader.java ..." + fi + ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR") + fi + fi + fi +fi +########################################################################################## +# End of extension +########################################################################################## + +export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} +if [ "$MVNW_VERBOSE" = true ]; then + echo $MAVEN_PROJECTBASEDIR +fi +MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" + +# For Cygwin, switch paths to Windows format before running java +if $cygwin; then + [ -n "$M2_HOME" ] && + M2_HOME=`cygpath --path --windows "$M2_HOME"` + [ -n "$JAVA_HOME" ] && + JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` + [ -n "$CLASSPATH" ] && + CLASSPATH=`cygpath --path --windows "$CLASSPATH"` + [ -n "$MAVEN_PROJECTBASEDIR" ] && + MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` +fi + +WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +exec "$JAVACMD" \ + $MAVEN_OPTS \ + -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ + "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ + ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" diff --git a/quarkus/mvnw.cmd b/quarkus/mvnw.cmd new file mode 100755 index 0000000000..77b451d837 --- /dev/null +++ b/quarkus/mvnw.cmd @@ -0,0 +1,172 @@ +@REM ---------------------------------------------------------------------------- +@REM Licensed to the Apache Software Foundation (ASF) under one +@REM or more contributor license agreements. See the NOTICE file +@REM distributed with this work for additional information +@REM regarding copyright ownership. The ASF licenses this file +@REM to you under the Apache License, Version 2.0 (the +@REM "License"); you may not use this file except in compliance +@REM with the License. You may obtain a copy of the License at +@REM +@REM http://www.apache.org/licenses/LICENSE-2.0 +@REM +@REM Unless required by applicable law or agreed to in writing, +@REM software distributed under the License is distributed on an +@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +@REM KIND, either express or implied. See the License for the +@REM specific language governing permissions and limitations +@REM under the License. +@REM ---------------------------------------------------------------------------- + +@REM ---------------------------------------------------------------------------- +@REM Maven2 Start Up Batch script +@REM +@REM Required ENV vars: +@REM JAVA_HOME - location of a JDK home dir +@REM +@REM Optional ENV vars +@REM M2_HOME - location of maven2's installed home dir +@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands +@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending +@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven +@REM e.g. to debug Maven itself, use +@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files +@REM ---------------------------------------------------------------------------- + +@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' +@echo off +@REM set title of command window +title %0 +@REM enable echoing my setting MAVEN_BATCH_ECHO to 'on' +@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% + +@REM set %HOME% to equivalent of $HOME +if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") + +@REM Execute a user defined script before this one +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre +@REM check for pre script, once with legacy .bat ending and once with .cmd ending +if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" +if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" +:skipRcPre + +@setlocal + +set ERROR_CODE=0 + +@REM To isolate internal variables from possible post scripts, we use another setlocal +@setlocal + +@REM ==== START VALIDATION ==== +if not "%JAVA_HOME%" == "" goto OkJHome + +echo. +echo Error: JAVA_HOME not found in your environment. >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +:OkJHome +if exist "%JAVA_HOME%\bin\java.exe" goto init + +echo. +echo Error: JAVA_HOME is set to an invalid directory. >&2 +echo JAVA_HOME = "%JAVA_HOME%" >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +@REM ==== END VALIDATION ==== + +:init + +@REM Find the project base dir, i.e. the directory that contains the folder ".mvn". +@REM Fallback to current working directory if not found. + +set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% +IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir + +set EXEC_DIR=%CD% +set WDIR=%EXEC_DIR% +:findBaseDir +IF EXIST "%WDIR%"\.mvn goto baseDirFound +cd .. +IF "%WDIR%"=="%CD%" goto baseDirNotFound +set WDIR=%CD% +goto findBaseDir + +:baseDirFound +set MAVEN_PROJECTBASEDIR=%WDIR% +cd "%EXEC_DIR%" +goto endDetectBaseDir + +:baseDirNotFound +set MAVEN_PROJECTBASEDIR=%EXEC_DIR% +cd "%EXEC_DIR%" + +:endDetectBaseDir + +IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig + +@setlocal EnableExtensions EnableDelayedExpansion +for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a +@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% + +:endReadAdditionalConfig + +SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" +set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" +set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.3/maven-wrapper-0.5.3.jar" + +FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( + IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B +) + +@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central +@REM This allows using the maven wrapper in projects that prohibit checking in binary data. +if exist %WRAPPER_JAR% ( + echo Found %WRAPPER_JAR% +) else ( + if not "%MVNW_REPOURL%" == "" ( + SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.3/maven-wrapper-0.5.3.jar" + ) + echo Couldn't find %WRAPPER_JAR%, downloading it ... + echo Downloading from: %DOWNLOAD_URL% + + powershell -Command "&{"^ + "$webclient = new-object System.Net.WebClient;"^ + "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ + "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ + "}"^ + "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^ + "}" + echo Finished downloading %WRAPPER_JAR% +) +@REM End of extension + +%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* +if ERRORLEVEL 1 goto error +goto end + +:error +set ERROR_CODE=1 + +:end +@endlocal & set ERROR_CODE=%ERROR_CODE% + +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost +@REM check for post script, once with legacy .bat ending and once with .cmd ending +if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" +if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" +:skipRcPost + +@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' +if "%MAVEN_BATCH_PAUSE%" == "on" pause + +if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% + +exit /B %ERROR_CODE% diff --git a/quarkus/pom.xml b/quarkus/pom.xml new file mode 100644 index 0000000000..d8f274df6d --- /dev/null +++ b/quarkus/pom.xml @@ -0,0 +1,113 @@ + + + 4.0.0 + com.baeldung.quarkus + quarkus + 1.0-SNAPSHOT + + 2.22.0 + 0.13.1 + 1.8 + UTF-8 + 1.8 + + + + + io.quarkus + quarkus-bom + ${quarkus.version} + pom + import + + + + + + io.quarkus + quarkus-resteasy + + + io.quarkus + quarkus-junit5 + test + + + io.rest-assured + rest-assured + test + + + + + + io.quarkus + quarkus-maven-plugin + ${quarkus.version} + + + + build + + + + + + maven-surefire-plugin + ${surefire-plugin.version} + + + org.jboss.logmanager.LogManager + + + + + + + + native + + + native + + + + + + io.quarkus + quarkus-maven-plugin + ${quarkus.version} + + + + native-image + + + true + + + + + + maven-failsafe-plugin + ${surefire-plugin.version} + + + + integration-test + verify + + + + ${project.build.directory}/${project.build.finalName}-runner + + + + + + + + + + diff --git a/quarkus/src/main/docker/Dockerfile.jvm b/quarkus/src/main/docker/Dockerfile.jvm new file mode 100644 index 0000000000..c91417af87 --- /dev/null +++ b/quarkus/src/main/docker/Dockerfile.jvm @@ -0,0 +1,21 @@ +#### +# This Dockerfile is used in order to build a container that runs the Quarkus application in JVM mode +# +# Before building the docker image run: +# +# mvn package +# +# Then, build the image with: +# +# docker build -f src/main/docker/Dockerfile.jvm -t quarkus/quarkus-project-jvm . +# +# Then run the container using: +# +# docker run -i --rm -p 8080:8080 quarkus/quarkus-project-jvm +# +### +FROM fabric8/java-jboss-openjdk8-jdk +ENV JAVA_OPTIONS=-Dquarkus.http.host=0.0.0.0 +COPY target/lib/* /deployments/lib/ +COPY target/*-runner.jar /deployments/app.jar +ENTRYPOINT [ "/deployments/run-java.sh" ] \ No newline at end of file diff --git a/quarkus/src/main/docker/Dockerfile.native b/quarkus/src/main/docker/Dockerfile.native new file mode 100644 index 0000000000..f076fe3f60 --- /dev/null +++ b/quarkus/src/main/docker/Dockerfile.native @@ -0,0 +1,22 @@ +#### +# This Dockerfile is used in order to build a container that runs the Quarkus application in native (no JVM) mode +# +# Before building the docker image run: +# +# mvn package -Pnative -Dnative-image.docker-build=true +# +# Then, build the image with: +# +# docker build -f src/main/docker/Dockerfile.native -t quarkus/quarkus-project . +# +# Then run the container using: +# +# docker run -i --rm -p 8080:8080 quarkus/quarkus-project +# +### +FROM registry.fedoraproject.org/fedora-minimal +WORKDIR /work/ +COPY target/*-runner /work/application +RUN chmod 775 /work +EXPOSE 8080 +CMD ["./application", "-Dquarkus.http.host=0.0.0.0"] \ No newline at end of file diff --git a/quarkus/src/main/java/com/baeldung/quarkus/HelloResource.java b/quarkus/src/main/java/com/baeldung/quarkus/HelloResource.java new file mode 100644 index 0000000000..884275f313 --- /dev/null +++ b/quarkus/src/main/java/com/baeldung/quarkus/HelloResource.java @@ -0,0 +1,28 @@ +package com.baeldung.quarkus; + +import javax.inject.Inject; +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; + +@Path("/hello") +public class HelloResource { + + @Inject + HelloService helloService; + + @GET + @Produces(MediaType.APPLICATION_JSON) + @Path("/polite/{name}") + public String greeting(@PathParam("name") String name) { + return helloService.politeHello(name); + } + + @GET + @Produces(MediaType.TEXT_PLAIN) + public String hello() { + return "hello"; + } +} \ No newline at end of file diff --git a/quarkus/src/main/java/com/baeldung/quarkus/HelloService.java b/quarkus/src/main/java/com/baeldung/quarkus/HelloService.java new file mode 100644 index 0000000000..4b19de1b63 --- /dev/null +++ b/quarkus/src/main/java/com/baeldung/quarkus/HelloService.java @@ -0,0 +1,16 @@ +package com.baeldung.quarkus; + +import org.eclipse.microprofile.config.inject.ConfigProperty; + +import javax.enterprise.context.ApplicationScoped; + +@ApplicationScoped +public class HelloService { + + @ConfigProperty(name = "greeting") + private String greeting; + + public String politeHello(String name){ + return greeting + " " + name; + } +} diff --git a/quarkus/src/main/resources/META-INF/resources/index.html b/quarkus/src/main/resources/META-INF/resources/index.html new file mode 100644 index 0000000000..070a1f672b --- /dev/null +++ b/quarkus/src/main/resources/META-INF/resources/index.html @@ -0,0 +1,152 @@ + + + + + quarkus-project - 1.0-SNAPSHOT + + + + +

+ +
+
+

Congratulations, you have created a new Quarkus application.

+ +

Why do you see this?

+ +

This page is served by Quarkus. The source is in + src/main/resources/META-INF/resources/index.html.

+ +

What can I do from here?

+ +

If not already done, run the application in dev mode using: mvn compile quarkus:dev. +

+
    +
  • Add REST resources, Servlets, functions and other services in src/main/java.
  • +
  • Your static assets are located in src/main/resources/META-INF/resources.
  • +
  • Configure your application in src/main/resources/application.properties. +
  • +
+ +

How do I get rid of this page?

+

Just delete the src/main/resources/META-INF/resources/index.html file.

+
+
+
+

Application

+
    +
  • GroupId: com.baeldung.quarkus
  • +
  • ArtifactId: quarkus-project
  • +
  • Version: 1.0-SNAPSHOT
  • +
  • Quarkus Version: 0.13.1
  • +
+
+ +
+
+ + + + \ No newline at end of file diff --git a/quarkus/src/main/resources/application.properties b/quarkus/src/main/resources/application.properties new file mode 100644 index 0000000000..3f05d2198f --- /dev/null +++ b/quarkus/src/main/resources/application.properties @@ -0,0 +1,3 @@ +# Configuration file +# key = value +greeting=Good morning \ No newline at end of file diff --git a/quarkus/src/test/java/com/baeldung/quarkus/HelloResourceTest.java b/quarkus/src/test/java/com/baeldung/quarkus/HelloResourceTest.java new file mode 100644 index 0000000000..3d0fff7562 --- /dev/null +++ b/quarkus/src/test/java/com/baeldung/quarkus/HelloResourceTest.java @@ -0,0 +1,21 @@ +package com.baeldung.quarkus; + +import io.quarkus.test.junit.QuarkusTest; +import org.junit.jupiter.api.Test; + +import static io.restassured.RestAssured.given; +import static org.hamcrest.CoreMatchers.is; + +@QuarkusTest +public class HelloResourceTest { + + @Test + public void testHelloEndpoint() { + given() + .when().get("/hello") + .then() + .statusCode(200) + .body(is("hello")); + } + +} \ No newline at end of file diff --git a/quarkus/src/test/java/com/baeldung/quarkus/NativeHelloResourceIT.java b/quarkus/src/test/java/com/baeldung/quarkus/NativeHelloResourceIT.java new file mode 100644 index 0000000000..4b0606f588 --- /dev/null +++ b/quarkus/src/test/java/com/baeldung/quarkus/NativeHelloResourceIT.java @@ -0,0 +1,9 @@ +package com.baeldung.quarkus; + +import io.quarkus.test.junit.SubstrateTest; + +@SubstrateTest +public class NativeHelloResourceIT extends HelloResourceTest { + + // Execute the same tests but in native mode. +} \ No newline at end of file diff --git a/ratpack/pom.xml b/ratpack/pom.xml index a4389275b6..7c145eff91 100644 --- a/ratpack/pom.xml +++ b/ratpack/pom.xml @@ -61,7 +61,7 @@ com.h2database h2 - ${h2database.version} + ${h2.version} org.apache.httpcomponents @@ -90,7 +90,6 @@ 1.5.4 4.5.3 4.4.6 - 1.4.193 1.5.12 diff --git a/rule-engines/easy-rules/pom.xml b/rule-engines/easy-rules/pom.xml index 5b88ce4e94..369451c56c 100644 --- a/rule-engines/easy-rules/pom.xml +++ b/rule-engines/easy-rules/pom.xml @@ -10,6 +10,7 @@ com.baeldung parent-modules 1.0.0-SNAPSHOT + ../.. @@ -23,4 +24,4 @@ 3.0.0 - \ No newline at end of file + diff --git a/rule-engines/openl-tablets/pom.xml b/rule-engines/openl-tablets/pom.xml index 3bd6055fc9..b19ec8d3f1 100644 --- a/rule-engines/openl-tablets/pom.xml +++ b/rule-engines/openl-tablets/pom.xml @@ -10,6 +10,7 @@ com.baeldung parent-modules 1.0.0-SNAPSHOT + ../.. @@ -29,4 +30,4 @@ 5.19.4 - \ No newline at end of file + diff --git a/rule-engines/rulebook/pom.xml b/rule-engines/rulebook/pom.xml index 90b5e55417..5e0b900bd9 100644 --- a/rule-engines/rulebook/pom.xml +++ b/rule-engines/rulebook/pom.xml @@ -10,6 +10,7 @@ com.baeldung parent-modules 1.0.0-SNAPSHOT + ../.. @@ -24,4 +25,4 @@ 0.6.2 - \ No newline at end of file + diff --git a/rxjava/pom.xml b/rxjava/pom.xml index 596a5196da..85106d1127 100644 --- a/rxjava/pom.xml +++ b/rxjava/pom.xml @@ -62,7 +62,6 @@ 1.0.0 1.1.1 1.7.0 - 1.4.196 \ No newline at end of file diff --git a/software-security/sql-injection-samples/pom.xml b/software-security/sql-injection-samples/pom.xml index 0a28a96a07..b12b479614 100644 --- a/software-security/sql-injection-samples/pom.xml +++ b/software-security/sql-injection-samples/pom.xml @@ -17,6 +17,7 @@ + org.springframework.boot spring-boot-starter-jdbc @@ -53,6 +54,11 @@ hibernate-jpamodelgen + + + org.springframework.boot + spring-boot-devtools + @@ -64,8 +70,4 @@ - - 1.8 - - \ No newline at end of file diff --git a/spring-4/pom.xml b/spring-4/pom.xml index eb64c1839f..59b74782ec 100644 --- a/spring-4/pom.xml +++ b/spring-4/pom.xml @@ -88,8 +88,6 @@ com.baeldung.flips.ApplicationConfig 1.0.1 - 1.16.18 - 1.4.197 diff --git a/spring-5-reactive-oauth/pom.xml b/spring-5-reactive-oauth/pom.xml index ff076985e4..06ce817a02 100644 --- a/spring-5-reactive-oauth/pom.xml +++ b/spring-5-reactive-oauth/pom.xml @@ -69,7 +69,6 @@ UTF-8 UTF-8 - 1.8 2.1.0.RELEASE diff --git a/spring-5-security-cognito/README.md b/spring-5-security-cognito/README.md new file mode 100644 index 0000000000..0825882c05 --- /dev/null +++ b/spring-5-security-cognito/README.md @@ -0,0 +1,3 @@ +## Relevant articles: + +- [Authenticating with Amazon Cognito Using Spring Security](https://www.baeldung.com/spring-security-oauth-cognito) diff --git a/spring-5-security-cognito/pom.xml b/spring-5-security-cognito/pom.xml new file mode 100644 index 0000000000..c7314d6f9f --- /dev/null +++ b/spring-5-security-cognito/pom.xml @@ -0,0 +1,74 @@ + + 4.0.0 + com.baeldung + spring-5-security-cognito + 0.0.1-SNAPSHOT + spring-5-security-cognito + jar + spring 5 security oauth cognito sample project + + + com.baeldung + parent-boot-2 + 0.0.1-SNAPSHOT + ../parent-boot-2 + + + + + + org.springframework.boot + spring-boot-starter-security + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.boot + spring-boot-starter-thymeleaf + + + org.thymeleaf.extras + thymeleaf-extras-springsecurity5 + + + + + org.springframework.security.oauth.boot + spring-security-oauth2-autoconfigure + ${oauth-auto.version} + + + org.springframework.security + spring-security-oauth2-client + + + org.springframework.security + spring-security-oauth2-jose + + + + org.springframework + spring-test + + + org.springframework.boot + spring-boot-starter-test + test + + + org.springframework.security + spring-security-test + test + + + + + 2.1.0.RELEASE + 2.1.0.RELEASE + com.baeldung.cognito.SpringCognitoApplication + + + diff --git a/spring-5-security-oauth/src/main/java/com/baeldung/cognito/CognitoWebConfiguration.java b/spring-5-security-cognito/src/main/java/com/baeldung/cognito/CognitoWebConfiguration.java similarity index 91% rename from spring-5-security-oauth/src/main/java/com/baeldung/cognito/CognitoWebConfiguration.java rename to spring-5-security-cognito/src/main/java/com/baeldung/cognito/CognitoWebConfiguration.java index ae03e0a802..6841fa7a65 100644 --- a/spring-5-security-oauth/src/main/java/com/baeldung/cognito/CognitoWebConfiguration.java +++ b/spring-5-security-cognito/src/main/java/com/baeldung/cognito/CognitoWebConfiguration.java @@ -6,7 +6,7 @@ import org.springframework.web.servlet.config.annotation.ViewControllerRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; @Configuration -@PropertySource("cognito/application_cognito.yml") +@PropertySource("cognito/application-cognito.yml") public class CognitoWebConfiguration implements WebMvcConfigurer { @Override diff --git a/spring-5-security-oauth/src/main/java/com/baeldung/cognito/SpringCognitoApplication.java b/spring-5-security-cognito/src/main/java/com/baeldung/cognito/SpringCognitoApplication.java similarity index 88% rename from spring-5-security-oauth/src/main/java/com/baeldung/cognito/SpringCognitoApplication.java rename to spring-5-security-cognito/src/main/java/com/baeldung/cognito/SpringCognitoApplication.java index 7f7b751cd9..eebe6d8f45 100644 --- a/spring-5-security-oauth/src/main/java/com/baeldung/cognito/SpringCognitoApplication.java +++ b/spring-5-security-cognito/src/main/java/com/baeldung/cognito/SpringCognitoApplication.java @@ -5,7 +5,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.annotation.PropertySource; @SpringBootApplication -@PropertySource("cognito/application_cognito.yml") +@PropertySource("cognito/application-cognito.yml") public class SpringCognitoApplication { public static void main(String[] args) { diff --git a/spring-5-security-oauth/src/main/resources/cognito/application_cognito.yml b/spring-5-security-cognito/src/main/resources/cognito/application-cognito.yml similarity index 100% rename from spring-5-security-oauth/src/main/resources/cognito/application_cognito.yml rename to spring-5-security-cognito/src/main/resources/cognito/application-cognito.yml diff --git a/spring-5-security-oauth/src/main/resources/cognito/home.html b/spring-5-security-cognito/src/main/resources/cognito/home.html similarity index 100% rename from spring-5-security-oauth/src/main/resources/cognito/home.html rename to spring-5-security-cognito/src/main/resources/cognito/home.html diff --git a/spring-5-security-oauth/src/main/resources/cognito/style.css b/spring-5-security-cognito/src/main/resources/cognito/style.css similarity index 100% rename from spring-5-security-oauth/src/main/resources/cognito/style.css rename to spring-5-security-cognito/src/main/resources/cognito/style.css diff --git a/spring-5-security-cognito/src/main/resources/logback.xml b/spring-5-security-cognito/src/main/resources/logback.xml new file mode 100644 index 0000000000..7d900d8ea8 --- /dev/null +++ b/spring-5-security-cognito/src/main/resources/logback.xml @@ -0,0 +1,13 @@ + + + + + %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n + + + + + + + + \ No newline at end of file diff --git a/spring-activiti/pom.xml b/spring-activiti/pom.xml index 3d67a2ab7b..e0196e807d 100644 --- a/spring-activiti/pom.xml +++ b/spring-activiti/pom.xml @@ -59,7 +59,6 @@ UTF-8 UTF-8 6.0.0 - 1.8 diff --git a/spring-boot-angular-ecommerce/pom.xml b/spring-boot-angular-ecommerce/pom.xml index a5296eade8..510e6c6ec3 100644 --- a/spring-boot-angular-ecommerce/pom.xml +++ b/spring-boot-angular-ecommerce/pom.xml @@ -75,7 +75,6 @@ UTF-8 UTF-8 - 1.8 2.0.3.RELEASE 2.0.4.RELEASE diff --git a/spring-boot-crud/pom.xml b/spring-boot-crud/pom.xml index 73635b0a1c..15ff6c5d11 100644 --- a/spring-boot-crud/pom.xml +++ b/spring-boot-crud/pom.xml @@ -60,7 +60,6 @@ UTF-8 - 1.8 \ No newline at end of file diff --git a/spring-boot-exceptions/pom.xml b/spring-boot-exceptions/pom.xml index 105f60e295..01d6973642 100644 --- a/spring-boot-exceptions/pom.xml +++ b/spring-boot-exceptions/pom.xml @@ -17,10 +17,6 @@ pass-exception-to-client-json-spring-boot Baeldung article code on how to pass exceptions to client in JSON format using Spring Boot - - 1.8 - - org.springframework.boot diff --git a/spring-boot-vue/pom.xml b/spring-boot-vue/pom.xml index 4e47a98d6f..5d19f01d1e 100644 --- a/spring-boot-vue/pom.xml +++ b/spring-boot-vue/pom.xml @@ -47,7 +47,6 @@ UTF-8 UTF-8 - 1.8 diff --git a/spring-cloud-data-flow/etl/customer-mongodb-sink/pom.xml b/spring-cloud-data-flow/etl/customer-mongodb-sink/pom.xml index 456caf480c..409db34829 100644 --- a/spring-cloud-data-flow/etl/customer-mongodb-sink/pom.xml +++ b/spring-cloud-data-flow/etl/customer-mongodb-sink/pom.xml @@ -63,7 +63,6 @@ UTF-8 UTF-8 - 1.8 Greenwich.RELEASE diff --git a/spring-cloud-data-flow/etl/customer-transform/pom.xml b/spring-cloud-data-flow/etl/customer-transform/pom.xml index b7376f7bd4..66f1d5e0d7 100644 --- a/spring-cloud-data-flow/etl/customer-transform/pom.xml +++ b/spring-cloud-data-flow/etl/customer-transform/pom.xml @@ -55,7 +55,6 @@ UTF-8 UTF-8 - 1.8 Greenwich.RELEASE diff --git a/spring-cloud/spring-cloud-contract/spring-cloud-contract-consumer/pom.xml b/spring-cloud/spring-cloud-contract/spring-cloud-contract-consumer/pom.xml index 8ecda40d0a..afd045189c 100644 --- a/spring-cloud/spring-cloud-contract/spring-cloud-contract-consumer/pom.xml +++ b/spring-cloud/spring-cloud-contract/spring-cloud-contract-consumer/pom.xml @@ -50,7 +50,6 @@ UTF-8 UTF-8 - 1.8 1.2.2.RELEASE 1.5.9.RELEASE diff --git a/spring-cloud/spring-cloud-contract/spring-cloud-contract-producer/pom.xml b/spring-cloud/spring-cloud-contract/spring-cloud-contract-producer/pom.xml index 47759a818a..07429687c7 100644 --- a/spring-cloud/spring-cloud-contract/spring-cloud-contract-producer/pom.xml +++ b/spring-cloud/spring-cloud-contract/spring-cloud-contract-producer/pom.xml @@ -64,7 +64,6 @@ UTF-8 UTF-8 - 1.8 Edgware.SR1 1.5.9.RELEASE diff --git a/spring-cloud/spring-cloud-functions/pom.xml b/spring-cloud/spring-cloud-functions/pom.xml index 4d03e07e89..7a44e4ae0f 100644 --- a/spring-cloud/spring-cloud-functions/pom.xml +++ b/spring-cloud/spring-cloud-functions/pom.xml @@ -85,7 +85,6 @@ UTF-8 UTF-8 - 1.8 1.0.1.RELEASE 2.0.2 2.0.4.RELEASE diff --git a/spring-cloud/spring-cloud-kubernetes/client-service/pom.xml b/spring-cloud/spring-cloud-kubernetes/client-service/pom.xml index a4de796ee3..41e09fa13b 100644 --- a/spring-cloud/spring-cloud-kubernetes/client-service/pom.xml +++ b/spring-cloud/spring-cloud-kubernetes/client-service/pom.xml @@ -88,7 +88,6 @@
- 1.8 Finchley.SR2 1.0.0.RELEASE diff --git a/spring-cloud/spring-cloud-kubernetes/liveness-example/pom.xml b/spring-cloud/spring-cloud-kubernetes/liveness-example/pom.xml index 012a81bd8d..293b215918 100644 --- a/spring-cloud/spring-cloud-kubernetes/liveness-example/pom.xml +++ b/spring-cloud/spring-cloud-kubernetes/liveness-example/pom.xml @@ -44,7 +44,6 @@ UTF-8 UTF-8 - 1.8 1.5.17.RELEASE diff --git a/spring-cloud/spring-cloud-kubernetes/readiness-example/pom.xml b/spring-cloud/spring-cloud-kubernetes/readiness-example/pom.xml index 2b2e57a19c..07589e65b6 100644 --- a/spring-cloud/spring-cloud-kubernetes/readiness-example/pom.xml +++ b/spring-cloud/spring-cloud-kubernetes/readiness-example/pom.xml @@ -44,7 +44,6 @@ UTF-8 UTF-8 - 1.8 1.5.17.RELEASE diff --git a/spring-cloud/spring-cloud-kubernetes/travel-agency-service/pom.xml b/spring-cloud/spring-cloud-kubernetes/travel-agency-service/pom.xml index 19eea2612c..0d7639b179 100755 --- a/spring-cloud/spring-cloud-kubernetes/travel-agency-service/pom.xml +++ b/spring-cloud/spring-cloud-kubernetes/travel-agency-service/pom.xml @@ -68,7 +68,6 @@ - 1.8 Finchley.SR2 diff --git a/spring-cloud/spring-cloud-vault/pom.xml b/spring-cloud/spring-cloud-vault/pom.xml index 3466f657be..9a1be3f5c0 100644 --- a/spring-cloud/spring-cloud-vault/pom.xml +++ b/spring-cloud/spring-cloud-vault/pom.xml @@ -68,7 +68,6 @@ UTF-8 UTF-8 - 1.8 Greenwich.RELEASE diff --git a/spring-cloud/spring-cloud-zuul/pom.xml b/spring-cloud/spring-cloud-zuul/pom.xml index 08990357d6..5d44ae9590 100644 --- a/spring-cloud/spring-cloud-zuul/pom.xml +++ b/spring-cloud/spring-cloud-zuul/pom.xml @@ -70,7 +70,6 @@ UTF-8 UTF-8 - 1.8 Finchley.SR1 2.0.6.RELEASE diff --git a/spring-data-rest/pom.xml b/spring-data-rest/pom.xml index 525c88c9d8..8400993a38 100644 --- a/spring-data-rest/pom.xml +++ b/spring-data-rest/pom.xml @@ -41,6 +41,11 @@ spring-boot-starter-test test + + com.h2database + h2 + runtime + com.querydsl querydsl-apt @@ -87,4 +92,4 @@ com.baeldung.SpringDataRestApplication - + \ No newline at end of file diff --git a/spring-exceptions/pom.xml b/spring-exceptions/pom.xml index 16f6286606..ff28ac89bb 100644 --- a/spring-exceptions/pom.xml +++ b/spring-exceptions/pom.xml @@ -179,7 +179,6 @@ 4.3.4.RELEASE 4.2.0.RELEASE 3.21.0-GA - 1.2 5.2.5.Final @@ -189,7 +188,6 @@ 5.3.3.Final - 3.1.0 2.2 diff --git a/spring-freemarker/pom.xml b/spring-freemarker/pom.xml index 40558476ef..be34f84495 100644 --- a/spring-freemarker/pom.xml +++ b/spring-freemarker/pom.xml @@ -35,7 +35,7 @@ javax.servlet javax.servlet-api - ${servletapi.version} + ${javax.servlet-api.version} provided @@ -57,7 +57,6 @@ 5.0.8.RELEASE 2.3.28 - 3.1.0 false 1.5.10.RELEASE diff --git a/spring-kafka/pom.xml b/spring-kafka/pom.xml index b76d4f10c0..2fb4c776fe 100644 --- a/spring-kafka/pom.xml +++ b/spring-kafka/pom.xml @@ -34,7 +34,6 @@ 2.2.2.RELEASE - 2.9.7 \ No newline at end of file diff --git a/spring-mvc-forms-jsp/pom.xml b/spring-mvc-forms-jsp/pom.xml index e0539c3216..20912e71e5 100644 --- a/spring-mvc-forms-jsp/pom.xml +++ b/spring-mvc-forms-jsp/pom.xml @@ -100,9 +100,6 @@ 2.6 - 1.2 - 2.3.1 - 3.1.0 6.0.10.Final 1.3.3 5.2.5.Final diff --git a/spring-mvc-simple/pom.xml b/spring-mvc-simple/pom.xml index cdd4a9e13a..a767cf3c37 100644 --- a/spring-mvc-simple/pom.xml +++ b/spring-mvc-simple/pom.xml @@ -163,9 +163,7 @@ 1.8 1.8 3.2.0 - 3.7.0 2.21.0 - 1.2 2.3.2-b02 4.0.0 6.0.10.Final @@ -177,7 +175,6 @@ 1.2.5 1.0.2 1.9.0 - 2.9.7 1.4.9 5.1.0 20180130 diff --git a/spring-mvc-velocity/pom.xml b/spring-mvc-velocity/pom.xml index 60ac8b9c2f..df19b67e8e 100644 --- a/spring-mvc-velocity/pom.xml +++ b/spring-mvc-velocity/pom.xml @@ -110,8 +110,6 @@ 4.4.5 4.5.2 - - 3.1.0 1.7 2.0 2.9.0 diff --git a/spring-mvc-webflow/pom.xml b/spring-mvc-webflow/pom.xml index e1a279a787..c8de990da0 100644 --- a/spring-mvc-webflow/pom.xml +++ b/spring-mvc-webflow/pom.xml @@ -90,9 +90,6 @@ 2.5.0.RELEASE - 3.1.0 - 1.2 - 4.4.5 4.5.2 diff --git a/spring-resttemplate/README.md b/spring-resttemplate/README.md index 353e9f955e..c2c4965231 100644 --- a/spring-resttemplate/README.md +++ b/spring-resttemplate/README.md @@ -9,3 +9,4 @@ The "REST With Spring" Classes: http://bit.ly/restwithspring - [Spring RestTemplate Error Handling](http://www.baeldung.com/spring-rest-template-error-handling) - [Configure a RestTemplate with RestTemplateBuilder](http://www.baeldung.com/spring-rest-template-builder) - [Mocking a RestTemplate in Spring](https://www.baeldung.com/spring-mock-rest-template) +- [RestTemplate Post Request with JSON](https://www.baeldung.com/spring-resttemplate-post-json) diff --git a/spring-security-cache-control/pom.xml b/spring-security-cache-control/pom.xml index c630774849..e68f92d2ee 100644 --- a/spring-security-cache-control/pom.xml +++ b/spring-security-cache-control/pom.xml @@ -65,8 +65,4 @@
- - 3.1.0 - - \ No newline at end of file diff --git a/spring-security-mvc-boot/pom.xml b/spring-security-mvc-boot/pom.xml index 00d8f032c2..4c25dc01e8 100644 --- a/spring-security-mvc-boot/pom.xml +++ b/spring-security-mvc-boot/pom.xml @@ -234,10 +234,8 @@ 1.1.2 - 1.2 1.6.1 2.6.11 - 1.8 diff --git a/spring-security-mvc-custom/pom.xml b/spring-security-mvc-custom/pom.xml index 7c60a8e18a..4e932f3245 100644 --- a/spring-security-mvc-custom/pom.xml +++ b/spring-security-mvc-custom/pom.xml @@ -94,7 +94,7 @@ javax.servlet javax.servlet-api - ${javax.servlet.version} + ${javax.servlet-api.version} provided @@ -192,14 +192,9 @@ - - 3.1.0 - 1.2 - 19.0 3.5 - 2.9.7 2.6 diff --git a/spring-security-mvc-digest-auth/pom.xml b/spring-security-mvc-digest-auth/pom.xml index 33b3b5ff31..cf1de1730d 100644 --- a/spring-security-mvc-digest-auth/pom.xml +++ b/spring-security-mvc-digest-auth/pom.xml @@ -94,7 +94,7 @@ javax.servlet javax.servlet-api - ${javax.servlet.version} + ${javax.servlet-api.version} provided @@ -194,10 +194,6 @@ 4.2.6.RELEASE - - 1.2 - 3.1.0 - 19.0 3.5 diff --git a/spring-security-mvc-login/pom.xml b/spring-security-mvc-login/pom.xml index 048297bbd4..02ed0e36f2 100644 --- a/spring-security-mvc-login/pom.xml +++ b/spring-security-mvc-login/pom.xml @@ -94,7 +94,7 @@ javax.servlet javax.servlet-api - ${javax.servlet.version} + ${javax.servlet-api.version} provided @@ -174,16 +174,9 @@ - - - - 3.1.0 - 1.2 - 2.6 1.6.1 - \ No newline at end of file diff --git a/spring-security-mvc-persisted-remember-me/pom.xml b/spring-security-mvc-persisted-remember-me/pom.xml index d10565255d..5e987dcb77 100644 --- a/spring-security-mvc-persisted-remember-me/pom.xml +++ b/spring-security-mvc-persisted-remember-me/pom.xml @@ -198,7 +198,6 @@ 4.2.6.RELEASE - 1.4.193 9.4.1212 diff --git a/spring-security-mvc-session/pom.xml b/spring-security-mvc-session/pom.xml index 03c75b99e2..c0e1527a24 100644 --- a/spring-security-mvc-session/pom.xml +++ b/spring-security-mvc-session/pom.xml @@ -94,7 +94,7 @@ javax.servlet javax.servlet-api - ${javax.servlet.version} + ${javax.servlet-api.version} provided @@ -171,8 +171,6 @@ 3.0.2 - 1.2 - 3.1.0 2.6 diff --git a/spring-security-mvc-socket/pom.xml b/spring-security-mvc-socket/pom.xml index b83f10d9fe..f1d28355fd 100644 --- a/spring-security-mvc-socket/pom.xml +++ b/spring-security-mvc-socket/pom.xml @@ -188,7 +188,6 @@ 1.11.3.RELEASE 1.4.196 1.2.3 - 2.9.7 \ No newline at end of file diff --git a/spring-security-react/pom.xml b/spring-security-react/pom.xml index eaf10791bc..c7b7c85be8 100644 --- a/spring-security-react/pom.xml +++ b/spring-security-react/pom.xml @@ -72,7 +72,7 @@ javax.servlet javax.servlet-api - ${javax.servlet.version} + ${javax.servlet-api.version} provided @@ -167,10 +167,6 @@ 4.3.6.RELEASE 4.2.1.RELEASE - - 3.1.0 - 1.2 - 19.0 3.5 diff --git a/spring-security-rest-basic-auth/pom.xml b/spring-security-rest-basic-auth/pom.xml index 3c7f8eaa2b..8a90247386 100644 --- a/spring-security-rest-basic-auth/pom.xml +++ b/spring-security-rest-basic-auth/pom.xml @@ -142,7 +142,7 @@ javax.servlet javax.servlet-api - ${javax.servlet.version} + ${javax.servlet-api.version} provided @@ -275,10 +275,6 @@ 4.4.11 4.5.8 - - 1.2 - 3.1.0 - 19.0 diff --git a/spring-security-rest/pom.xml b/spring-security-rest/pom.xml index b6039ce9d3..af38c1ffef 100644 --- a/spring-security-rest/pom.xml +++ b/spring-security-rest/pom.xml @@ -267,10 +267,7 @@ - 3.1.0 1.1.0.Final - 1.2 - 2.9.7 26.0-jre diff --git a/spring-session/spring-session-jdbc/pom.xml b/spring-session/spring-session-jdbc/pom.xml index b46b549ce2..432715bc0e 100644 --- a/spring-session/spring-session-jdbc/pom.xml +++ b/spring-session/spring-session-jdbc/pom.xml @@ -48,8 +48,4 @@ - - 1.4.197 - - \ No newline at end of file diff --git a/spring-static-resources/pom.xml b/spring-static-resources/pom.xml index fc2b3336bc..f01e807919 100644 --- a/spring-static-resources/pom.xml +++ b/spring-static-resources/pom.xml @@ -199,14 +199,10 @@ 1.8.9 2.3.2-b02 - - 2.9.6 - 6.0.10.Final 4.1.0 2.10 - 1.2 4.0.1 1 diff --git a/spring-swagger-codegen/spring-swagger-codegen-api-client/pom.xml b/spring-swagger-codegen/spring-swagger-codegen-api-client/pom.xml index 320745b6e5..cfbc90155c 100644 --- a/spring-swagger-codegen/spring-swagger-codegen-api-client/pom.xml +++ b/spring-swagger-codegen/spring-swagger-codegen-api-client/pom.xml @@ -158,27 +158,27 @@ com.fasterxml.jackson.core jackson-core - ${jackson-version} + ${jackson.version} com.fasterxml.jackson.core jackson-annotations - ${jackson-version} + ${jackson.version} com.fasterxml.jackson.core jackson-databind - ${jackson-version} + ${jackson.version} com.fasterxml.jackson.jaxrs jackson-jaxrs-json-provider - ${jackson-version} + ${jackson.version} com.fasterxml.jackson.datatype jackson-datatype-joda - ${jackson-version} + ${jackson.version} joda-time @@ -190,7 +190,6 @@ 1.5.15 4.3.9.RELEASE - 2.9.7 2.9.9 2.2 1.5 diff --git a/spring-userservice/pom.xml b/spring-userservice/pom.xml index e562171103..e6e8553c80 100644 --- a/spring-userservice/pom.xml +++ b/spring-userservice/pom.xml @@ -176,7 +176,7 @@ javax.servlet.jsp.jstl jstl-api - ${jstl-api.version} + ${jstl.version} org.springframework.boot @@ -191,7 +191,7 @@ javax.servlet javax.servlet-api - ${javax.servlet.version} + ${javax.servlet-api.version}
@@ -225,15 +225,12 @@ 5.2.10.Final 5.1.40 1.10.5.RELEASE - 1.4.193 10.13.1.1 5.3.3.Final 2.2.5 1.1.2 - 1.2 - 3.1.0 19.0 diff --git a/spring-webflux-amqp/pom.xml b/spring-webflux-amqp/pom.xml index a8346458a0..88f5eff403 100755 --- a/spring-webflux-amqp/pom.xml +++ b/spring-webflux-amqp/pom.xml @@ -1,62 +1,76 @@ - 4.0.0 - org.baeldung.spring - spring-webflux-amqp - 1.0.0-SNAPSHOT - spring-webflux-amqp - jar - Spring WebFlux AMQP Sample + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + 4.0.0 + org.baeldung.spring + spring-webflux-amqp + 1.0.0-SNAPSHOT + spring-webflux-amqp + jar + Spring WebFlux AMQP Sample - - parent-boot-2 - com.baeldung - 0.0.1-SNAPSHOT - ../parent-boot-2 - + + parent-boot-2 + com.baeldung + 0.0.1-SNAPSHOT + ../parent-boot-2 + - - - org.springframework.boot - spring-boot-starter-amqp - - - org.springframework.boot - spring-boot-starter-webflux - + + + + + org.springframework.boot + spring-boot-dependencies + + 2.1.3.RELEASE + pom + import + + + - - org.springframework.boot - spring-boot-configuration-processor - true - + + + org.springframework.boot + spring-boot-starter-amqp + + + org.springframework.boot + spring-boot-starter-webflux + - - org.springframework.boot - spring-boot-starter-test - test - + + org.springframework.boot + spring-boot-configuration-processor + true + - - io.projectreactor - reactor-test - test - + + org.springframework.boot + spring-boot-starter-test + test + - - org.springframework.boot - spring-boot-starter-integration - - + + io.projectreactor + reactor-test + test + - - - - org.springframework.boot - spring-boot-maven-plugin - - - + + org.springframework.boot + spring-boot-starter-integration + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + diff --git a/spring-webflux-amqp/src/main/java/org/baeldung/spring/amqp/SpringWebfluxAmqpApplication.java b/spring-webflux-amqp/src/main/java/org/baeldung/spring/amqp/SpringWebfluxAmqpApplication.java index 30614e7ee6..8a31299333 100755 --- a/spring-webflux-amqp/src/main/java/org/baeldung/spring/amqp/SpringWebfluxAmqpApplication.java +++ b/spring-webflux-amqp/src/main/java/org/baeldung/spring/amqp/SpringWebfluxAmqpApplication.java @@ -3,6 +3,12 @@ package org.baeldung.spring.amqp; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; +import org.springframework.web.filter.reactive.HiddenHttpMethodFilter; +import org.springframework.web.server.ServerWebExchange; +import org.springframework.web.server.WebFilterChain; + +import reactor.core.publisher.Mono; @SpringBootApplication @EnableConfigurationProperties(DestinationsConfig.class) @@ -12,4 +18,19 @@ public class SpringWebfluxAmqpApplication { SpringApplication.run(SpringWebfluxAmqpApplication.class, args); } + + /** + * This is a workaround for https://github.com/spring-projects/spring-framework/issues/21094 + * @return + */ + @Bean + public HiddenHttpMethodFilter hiddenHttpMethodFilter() { + return new HiddenHttpMethodFilter() { + @Override + public Mono filter(ServerWebExchange exchange, WebFilterChain chain) { + return chain.filter(exchange); + } + }; + } + } diff --git a/spring-webflux-amqp/src/main/resources/application.yml b/spring-webflux-amqp/src/main/resources/application.yml index 702aaba357..3f527ce4c5 100755 --- a/spring-webflux-amqp/src/main/resources/application.yml +++ b/spring-webflux-amqp/src/main/resources/application.yml @@ -1,6 +1,6 @@ spring: rabbitmq: - host: localhost + host: 192.168.99.100 port: 5672 username: guest password: guest diff --git a/stripe/pom.xml b/stripe/pom.xml index b0cb194bfe..86c6389f7f 100644 --- a/stripe/pom.xml +++ b/stripe/pom.xml @@ -40,7 +40,6 @@
- 1.16.16 4.2.0 diff --git a/struts-2/pom.xml b/struts-2/pom.xml index 7f0fba727d..7de688ff2c 100644 --- a/struts-2/pom.xml +++ b/struts-2/pom.xml @@ -33,7 +33,7 @@ javax.servlet javax.servlet-api - ${servlet.version} + ${javax.servlet-api.version} org.springframework @@ -69,7 +69,6 @@ 2.5.5 2.5.8 - 3.0.1 4.3.6.RELEASE 3.0.0 diff --git a/tensorflow-java/pom.xml b/tensorflow-java/pom.xml index f52cd4a68f..f9abde737c 100644 --- a/tensorflow-java/pom.xml +++ b/tensorflow-java/pom.xml @@ -45,7 +45,6 @@ - 1.8 1.12.0 5.4.0 diff --git a/testing-modules/groovy-spock/.gitignore b/testing-modules/groovy-spock/.gitignore new file mode 100644 index 0000000000..37118ef42c --- /dev/null +++ b/testing-modules/groovy-spock/.gitignore @@ -0,0 +1 @@ +/report-*.json \ No newline at end of file diff --git a/testing-modules/junit-5-configuration/README.md b/testing-modules/junit-5-configuration/README.md index c274391766..a00e2a3f4a 100644 --- a/testing-modules/junit-5-configuration/README.md +++ b/testing-modules/junit-5-configuration/README.md @@ -1,2 +1,3 @@ ### Relevant Articles: -- + +- [Get the Path of the /src/test/resources Directory in JUnit](https://www.baeldung.com/junit-src-test-resources-directory-path) diff --git a/testing-modules/junit-5-configuration/pom.xml b/testing-modules/junit-5-configuration/pom.xml index aa488ebb8b..0f19bc19b7 100644 --- a/testing-modules/junit-5-configuration/pom.xml +++ b/testing-modules/junit-5-configuration/pom.xml @@ -16,11 +16,55 @@ + + org.junit.platform + junit-platform-engine + ${junit.platform.version} + org.junit.jupiter junit-jupiter-params ${junit.jupiter.version} + + org.junit.platform + junit-platform-runner + ${junit.platform.version} + test + + + org.junit.vintage + junit-vintage-engine + ${junit.vintage.version} + test + + + org.junit.jupiter + junit-jupiter-migrationsupport + ${junit.vintage.version} + test + + + com.h2database + h2 + ${h2.version} + + + org.springframework + spring-test + ${spring.version} + test + + + org.springframework + spring-context + ${spring.version} + + + org.springframework + spring-orm + ${spring.version} + @@ -29,13 +73,87 @@ src/test/resources true + + src/main/resources + true + + + + + filtering + + false + + + + + maven-surefire-plugin + ${maven-surefire-plugin.version} + + + org.junit.platform + junit-platform-surefire-provider + ${junit.platform.version} + + + + + **/*IntegrationTest.java + + + + + + + + category + + false + + + + + maven-surefire-plugin + ${maven-surefire-plugin.version} + + com.baeldung.categories.UnitTest + com.baeldung.categories.IntegrationTest + + + + + + + tags + + false + + + + + maven-surefire-plugin + ${maven-surefire-plugin.version} + + UnitTest + IntegrationTest + + + + + + + + - 5.3.1 + 5.4.2 1.2.0 5.2.0 + 1.4.196 + 5.0.6.RELEASE + 2.21.0 diff --git a/testing-modules/junit-5-configuration/src/main/java/com/baeldung/junit/tags/example/Employee.java b/testing-modules/junit-5-configuration/src/main/java/com/baeldung/junit/tags/example/Employee.java new file mode 100644 index 0000000000..66f41ee885 --- /dev/null +++ b/testing-modules/junit-5-configuration/src/main/java/com/baeldung/junit/tags/example/Employee.java @@ -0,0 +1,44 @@ +package com.baeldung.junit.tags.example; + +public class Employee { + private int id; + + private String firstName; + + private String lastName; + + private String address; + + public int getId() { + return id; + } + + public void setId(final int id) { + this.id = id; + } + + public String getFirstName() { + return firstName; + } + + public void setFirstName(final String firstName) { + this.firstName = firstName; + } + + public String getLastName() { + return lastName; + } + + public void setLastName(final String lastName) { + this.lastName = lastName; + } + + public String getAddress() { + return address; + } + + public void setAddress(final String address) { + this.address = address; + } + +} diff --git a/testing-modules/junit-5-configuration/src/main/java/com/baeldung/junit/tags/example/EmployeeDAO.java b/testing-modules/junit-5-configuration/src/main/java/com/baeldung/junit/tags/example/EmployeeDAO.java new file mode 100644 index 0000000000..2e9016018e --- /dev/null +++ b/testing-modules/junit-5-configuration/src/main/java/com/baeldung/junit/tags/example/EmployeeDAO.java @@ -0,0 +1,58 @@ +package com.baeldung.junit.tags.example; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.jdbc.core.JdbcTemplate; +import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate; +import org.springframework.jdbc.core.simple.SimpleJdbcInsert; +import org.springframework.stereotype.Repository; + +import javax.sql.DataSource; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +@Repository +public class EmployeeDAO { + + private JdbcTemplate jdbcTemplate; + + private NamedParameterJdbcTemplate namedParameterJdbcTemplate; + + private SimpleJdbcInsert simpleJdbcInsert; + + @Autowired + public void setDataSource(final DataSource dataSource) { + jdbcTemplate = new JdbcTemplate(dataSource); + + namedParameterJdbcTemplate = new NamedParameterJdbcTemplate(dataSource); + simpleJdbcInsert = new SimpleJdbcInsert(dataSource).withTableName("EMPLOYEE"); + + } + + public int getCountOfEmployees() { + return jdbcTemplate.queryForObject("SELECT COUNT(*) FROM EMPLOYEE", Integer.class); + } + + public List getAllEmployees() { + return jdbcTemplate.query("SELECT * FROM EMPLOYEE", new EmployeeRowMapper()); + } + + public int addEmplyee(final int id) { + return jdbcTemplate.update("INSERT INTO EMPLOYEE VALUES (?, ?, ?, ?)", id, "Bill", "Gates", "USA"); + } + + public int addEmplyeeUsingSimpelJdbcInsert(final Employee emp) { + final Map parameters = new HashMap(); + parameters.put("ID", emp.getId()); + parameters.put("FIRST_NAME", emp.getFirstName()); + parameters.put("LAST_NAME", emp.getLastName()); + parameters.put("ADDRESS", emp.getAddress()); + + return simpleJdbcInsert.execute(parameters); + } + + // for testing + public void setJdbcTemplate(JdbcTemplate jdbcTemplate) { + this.jdbcTemplate = jdbcTemplate; + } +} diff --git a/testing-modules/junit-5-configuration/src/main/java/com/baeldung/junit/tags/example/EmployeeRowMapper.java b/testing-modules/junit-5-configuration/src/main/java/com/baeldung/junit/tags/example/EmployeeRowMapper.java new file mode 100644 index 0000000000..f480aac9a2 --- /dev/null +++ b/testing-modules/junit-5-configuration/src/main/java/com/baeldung/junit/tags/example/EmployeeRowMapper.java @@ -0,0 +1,21 @@ +package com.baeldung.junit.tags.example; + +import org.springframework.jdbc.core.RowMapper; + +import java.sql.ResultSet; +import java.sql.SQLException; + +public class EmployeeRowMapper implements RowMapper { + + @Override + public Employee mapRow(final ResultSet rs, final int rowNum) throws SQLException { + final Employee employee = new Employee(); + + employee.setId(rs.getInt("ID")); + employee.setFirstName(rs.getString("FIRST_NAME")); + employee.setLastName(rs.getString("LAST_NAME")); + employee.setAddress(rs.getString("ADDRESS")); + + return employee; + } +} diff --git a/testing-modules/junit-5-configuration/src/main/java/com/baeldung/junit/tags/example/SpringJdbcConfig.java b/testing-modules/junit-5-configuration/src/main/java/com/baeldung/junit/tags/example/SpringJdbcConfig.java new file mode 100644 index 0000000000..dc82409df9 --- /dev/null +++ b/testing-modules/junit-5-configuration/src/main/java/com/baeldung/junit/tags/example/SpringJdbcConfig.java @@ -0,0 +1,19 @@ +package com.baeldung.junit.tags.example; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder; +import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType; + +import javax.sql.DataSource; + +@Configuration +@ComponentScan("com.baeldung.junit.tags.example") +public class SpringJdbcConfig { + + @Bean + public DataSource dataSource() { + return new EmbeddedDatabaseBuilder().setType(EmbeddedDatabaseType.H2).addScript("classpath:jdbc/schema.sql").addScript("classpath:jdbc/test-data.sql").build(); + } +} \ No newline at end of file diff --git a/testing-modules/junit-5-configuration/src/main/resources/jdbc/schema.sql b/testing-modules/junit-5-configuration/src/main/resources/jdbc/schema.sql new file mode 100644 index 0000000000..c86d35cdae --- /dev/null +++ b/testing-modules/junit-5-configuration/src/main/resources/jdbc/schema.sql @@ -0,0 +1,7 @@ +CREATE TABLE EMPLOYEE +( + ID int NOT NULL PRIMARY KEY, + FIRST_NAME varchar(255), + LAST_NAME varchar(255), + ADDRESS varchar(255), +); \ No newline at end of file diff --git a/testing-modules/junit-5-configuration/src/main/resources/jdbc/springJdbc-config.xml b/testing-modules/junit-5-configuration/src/main/resources/jdbc/springJdbc-config.xml new file mode 100644 index 0000000000..5fd2699b41 --- /dev/null +++ b/testing-modules/junit-5-configuration/src/main/resources/jdbc/springJdbc-config.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/testing-modules/junit-5-configuration/src/main/resources/jdbc/test-data.sql b/testing-modules/junit-5-configuration/src/main/resources/jdbc/test-data.sql new file mode 100644 index 0000000000..b9ef8fec25 --- /dev/null +++ b/testing-modules/junit-5-configuration/src/main/resources/jdbc/test-data.sql @@ -0,0 +1,7 @@ +INSERT INTO EMPLOYEE VALUES (1, 'James', 'Gosling', 'Canada'); + +INSERT INTO EMPLOYEE VALUES (2, 'Donald', 'Knuth', 'USA'); + +INSERT INTO EMPLOYEE VALUES (3, 'Linus', 'Torvalds', 'Finland'); + +INSERT INTO EMPLOYEE VALUES (4, 'Dennis', 'Ritchie', 'USA'); \ No newline at end of file diff --git a/testing-modules/junit-5-configuration/src/test/java/com/baeldung/categories/EmployeeDAOCategoryIntegrationTest.java b/testing-modules/junit-5-configuration/src/test/java/com/baeldung/categories/EmployeeDAOCategoryIntegrationTest.java new file mode 100644 index 0000000000..6aa1652321 --- /dev/null +++ b/testing-modules/junit-5-configuration/src/test/java/com/baeldung/categories/EmployeeDAOCategoryIntegrationTest.java @@ -0,0 +1,66 @@ +package com.baeldung.categories; + +import com.baeldung.junit.tags.example.Employee; +import com.baeldung.junit.tags.example.EmployeeDAO; +import com.baeldung.junit.tags.example.SpringJdbcConfig; +import org.hamcrest.CoreMatchers; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.junit.experimental.categories.Category; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.MockitoAnnotations; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.jdbc.core.JdbcTemplate; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.support.AnnotationConfigContextLoader; + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = { SpringJdbcConfig.class }, loader = AnnotationConfigContextLoader.class) +public class EmployeeDAOCategoryIntegrationTest { + + @Autowired + private EmployeeDAO employeeDao; + + @Mock + private JdbcTemplate jdbcTemplate; + private EmployeeDAO employeeDAO; + + @Before + public void setup() { + MockitoAnnotations.initMocks(this); + employeeDAO = new EmployeeDAO(); + employeeDAO.setJdbcTemplate(jdbcTemplate); + } + + @Test + @Category(IntegrationTest.class) + public void testAddEmployeeUsingSimpelJdbcInsert() { + final Employee emp = new Employee(); + emp.setId(12); + emp.setFirstName("testFirstName"); + emp.setLastName("testLastName"); + emp.setAddress("testAddress"); + + Assert.assertEquals(employeeDao.addEmplyeeUsingSimpelJdbcInsert(emp), 1); + } + + @Test + @Category(UnitTest.class) + public void givenNumberOfEmployeeWhenCountEmployeeThenCountMatch() { + + // given + Mockito.when(jdbcTemplate.queryForObject(Mockito.any(String.class), Mockito.eq(Integer.class))) + .thenReturn(1); + + // when + int countOfEmployees = employeeDAO.getCountOfEmployees(); + + // then + Assert.assertThat(countOfEmployees, CoreMatchers.is(1)); + } + +} diff --git a/testing-modules/junit-5-configuration/src/test/java/com/baeldung/categories/EmployeeDAOUnitTestSuite.java b/testing-modules/junit-5-configuration/src/test/java/com/baeldung/categories/EmployeeDAOUnitTestSuite.java new file mode 100644 index 0000000000..252e7ffe64 --- /dev/null +++ b/testing-modules/junit-5-configuration/src/test/java/com/baeldung/categories/EmployeeDAOUnitTestSuite.java @@ -0,0 +1,12 @@ +package com.baeldung.categories; + +import org.junit.experimental.categories.Categories; +import org.junit.experimental.categories.Categories.IncludeCategory; +import org.junit.runner.RunWith; +import org.junit.runners.Suite.SuiteClasses; + +@RunWith(Categories.class) +@IncludeCategory(UnitTest.class) +@SuiteClasses(EmployeeDAOCategoryIntegrationTest.class) +public class EmployeeDAOUnitTestSuite { +} diff --git a/testing-modules/junit-5-configuration/src/test/java/com/baeldung/categories/IntegrationTest.java b/testing-modules/junit-5-configuration/src/test/java/com/baeldung/categories/IntegrationTest.java new file mode 100644 index 0000000000..9ced880ffc --- /dev/null +++ b/testing-modules/junit-5-configuration/src/test/java/com/baeldung/categories/IntegrationTest.java @@ -0,0 +1,4 @@ +package com.baeldung.categories; + +public interface IntegrationTest { +} diff --git a/testing-modules/junit-5-configuration/src/test/java/com/baeldung/categories/UnitTest.java b/testing-modules/junit-5-configuration/src/test/java/com/baeldung/categories/UnitTest.java new file mode 100644 index 0000000000..3790fc1d91 --- /dev/null +++ b/testing-modules/junit-5-configuration/src/test/java/com/baeldung/categories/UnitTest.java @@ -0,0 +1,4 @@ +package com.baeldung.categories; + +public interface UnitTest { +} diff --git a/testing-modules/junit-5-configuration/src/test/java/com/baeldung/example/EmployeeDAOIntegrationTest.java b/testing-modules/junit-5-configuration/src/test/java/com/baeldung/example/EmployeeDAOIntegrationTest.java new file mode 100644 index 0000000000..d3b6a52726 --- /dev/null +++ b/testing-modules/junit-5-configuration/src/test/java/com/baeldung/example/EmployeeDAOIntegrationTest.java @@ -0,0 +1,41 @@ +package com.baeldung.example; + +import com.baeldung.junit.tags.example.Employee; +import com.baeldung.junit.tags.example.EmployeeDAO; +import com.baeldung.junit.tags.example.SpringJdbcConfig; +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.support.AnnotationConfigContextLoader; + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = { SpringJdbcConfig.class }, loader = AnnotationConfigContextLoader.class) +public class EmployeeDAOIntegrationTest { + + @Autowired + private EmployeeDAO employeeDao; + + @Test + public void testQueryMethod() { + Assert.assertEquals(employeeDao.getAllEmployees().size(), 4); + } + + @Test + public void testUpdateMethod() { + Assert.assertEquals(employeeDao.addEmplyee(5), 1); + } + + @Test + public void testAddEmployeeUsingSimpelJdbcInsert() { + final Employee emp = new Employee(); + emp.setId(11); + emp.setFirstName("testFirstName"); + emp.setLastName("testLastName"); + emp.setAddress("testAddress"); + + Assert.assertEquals(employeeDao.addEmplyeeUsingSimpelJdbcInsert(emp), 1); + } +} diff --git a/testing-modules/junit-5-configuration/src/test/java/com/baeldung/example/EmployeeUnitTest.java b/testing-modules/junit-5-configuration/src/test/java/com/baeldung/example/EmployeeUnitTest.java new file mode 100644 index 0000000000..f706af94ad --- /dev/null +++ b/testing-modules/junit-5-configuration/src/test/java/com/baeldung/example/EmployeeUnitTest.java @@ -0,0 +1,40 @@ +package com.baeldung.example; + +import com.baeldung.junit.tags.example.EmployeeDAO; +import org.hamcrest.CoreMatchers; +import org.junit.Assert; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.MockitoAnnotations; +import org.springframework.jdbc.core.JdbcTemplate; + +public class EmployeeUnitTest { + + @Mock + private JdbcTemplate jdbcTemplate; + + private EmployeeDAO employeeDAO; + + @BeforeEach + public void setup() { + MockitoAnnotations.initMocks(this); + employeeDAO = new EmployeeDAO(); + employeeDAO.setJdbcTemplate(jdbcTemplate); + } + + @Test + public void givenNumberOfEmployeeWhenCountEmployeeThenCountMatch() { + + // given + Mockito.when(jdbcTemplate.queryForObject(Mockito.any(String.class), Mockito.eq(Integer.class))) + .thenReturn(1); + + // when + int countOfEmployees = employeeDAO.getCountOfEmployees(); + + // then + Assert.assertThat(countOfEmployees, CoreMatchers.is(1)); + } +} diff --git a/testing-modules/junit-5-configuration/src/test/java/com/baeldung/tags/EmployeeDAOIntegrationTest.java b/testing-modules/junit-5-configuration/src/test/java/com/baeldung/tags/EmployeeDAOIntegrationTest.java new file mode 100644 index 0000000000..bcd76cb4c2 --- /dev/null +++ b/testing-modules/junit-5-configuration/src/test/java/com/baeldung/tags/EmployeeDAOIntegrationTest.java @@ -0,0 +1,65 @@ +package com.baeldung.tags; + +import com.baeldung.junit.tags.example.Employee; +import com.baeldung.junit.tags.example.EmployeeDAO; +import com.baeldung.junit.tags.example.SpringJdbcConfig; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.MockitoAnnotations; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.jdbc.core.JdbcTemplate; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit.jupiter.SpringExtension; +import org.springframework.test.context.support.AnnotationConfigContextLoader; + +@ExtendWith(SpringExtension.class) +@ContextConfiguration(classes = { SpringJdbcConfig.class }, loader = AnnotationConfigContextLoader.class) +public class EmployeeDAOIntegrationTest { + + @Autowired + private EmployeeDAO employeeDao; + + @Mock + private JdbcTemplate jdbcTemplate; + private EmployeeDAO employeeDAO; + + @BeforeEach + public void setup() { + MockitoAnnotations.initMocks(this); + employeeDAO = new EmployeeDAO(); + employeeDAO.setJdbcTemplate(jdbcTemplate); + } + + @Test + @Tag("IntegrationTest") + public void testAddEmployeeUsingSimpelJdbcInsert() { + final Employee emp = new Employee(); + emp.setId(12); + emp.setFirstName("testFirstName"); + emp.setLastName("testLastName"); + emp.setAddress("testAddress"); + + Assertions.assertEquals(employeeDao.addEmplyeeUsingSimpelJdbcInsert(emp), 1); + } + + @Test + @Tag("UnitTest") + public void givenNumberOfEmployeeWhenCountEmployeeThenCountMatch() { + + // given + Mockito.when(jdbcTemplate.queryForObject(Mockito.any(String.class), Mockito.eq(Integer.class))) + .thenReturn(1); + + // when + int countOfEmployees = employeeDAO.getCountOfEmployees(); + + // then + Assertions.assertEquals(1, countOfEmployees); + } + +} diff --git a/testing-modules/junit-5-configuration/src/test/java/com/baeldung/tags/EmployeeDAOTestSuite.java b/testing-modules/junit-5-configuration/src/test/java/com/baeldung/tags/EmployeeDAOTestSuite.java new file mode 100644 index 0000000000..783e5a81a2 --- /dev/null +++ b/testing-modules/junit-5-configuration/src/test/java/com/baeldung/tags/EmployeeDAOTestSuite.java @@ -0,0 +1,12 @@ +package com.baeldung.tags; + +import org.junit.platform.runner.JUnitPlatform; +import org.junit.platform.suite.api.IncludeTags; +import org.junit.platform.suite.api.SelectPackages; +import org.junit.runner.RunWith; + +@RunWith(JUnitPlatform.class) +@SelectPackages("com.baeldung.tags") +@IncludeTags("UnitTest") +public class EmployeeDAOTestSuite { +} diff --git a/testing-modules/junit-5/pom.xml b/testing-modules/junit-5/pom.xml index 1d1b0bc574..f27630a76d 100644 --- a/testing-modules/junit-5/pom.xml +++ b/testing-modules/junit-5/pom.xml @@ -128,7 +128,6 @@ 1.4.2 5.4.2 2.8.2 - 1.4.196 2.0.0-RC.1 2.21.0 1.6.0 diff --git a/testing-modules/mockito-2/README.md b/testing-modules/mockito-2/README.md index ee443df81a..5c9e8fc81a 100644 --- a/testing-modules/mockito-2/README.md +++ b/testing-modules/mockito-2/README.md @@ -2,7 +2,4 @@ - [Mockito’s Java 8 Features](http://www.baeldung.com/mockito-2-java-8) - [Lazy Verification with Mockito 2](http://www.baeldung.com/mockito-2-lazy-verification) - -## Mockito 2 and Java 8 Tips - -Examples on how to leverage Java 8 new features with Mockito version 2 +- [Mockito Strict Stubbing and The UnnecessaryStubbingException](https://www.baeldung.com/mockito-unnecessary-stubbing-exception) diff --git a/testing-modules/mockito-2/src/test/java/com/baeldung/mockito/misusing/ExpectedTestFailureRule.java b/testing-modules/mockito-2/src/test/java/com/baeldung/mockito/misusing/ExpectedTestFailureRule.java new file mode 100644 index 0000000000..53ad60a2fa --- /dev/null +++ b/testing-modules/mockito-2/src/test/java/com/baeldung/mockito/misusing/ExpectedTestFailureRule.java @@ -0,0 +1,51 @@ +package com.baeldung.mockito.misusing; + +import org.hamcrest.Matchers; +import org.junit.Assert; +import org.junit.rules.MethodRule; +import org.junit.runners.model.FrameworkMethod; +import org.junit.runners.model.Statement; + +public class ExpectedTestFailureRule implements MethodRule { + + private final MethodRule testedRule; + private FailureAssert failureAssert = null; + + public ExpectedTestFailureRule(MethodRule testedRule) { + this.testedRule = testedRule; + } + + @Override + public Statement apply(final Statement base, final FrameworkMethod method, final Object target) { + return new Statement() { + public void evaluate() throws Throwable { + try { + testedRule.apply(base, method, target) + .evaluate(); + } catch (Throwable t) { + if (failureAssert == null) { + throw t; + } + failureAssert.doAssert(t); + return; + } + } + }; + } + + @SuppressWarnings("unchecked") + public void expectedFailure(final Class expected) { + FailureAssert assertion = t -> Assert.assertThat(t, Matchers.isA((Class) expected)); + this.expectedFailure(assertion); + } + + private void expectedFailure(FailureAssert failureAssert) { + this.failureAssert = failureAssert; + } + + @FunctionalInterface + private interface FailureAssert { + abstract void doAssert(Throwable t); + } + +} diff --git a/testing-modules/mockito-2/src/test/java/com/baeldung/mockito/misusing/MockitoUnecessaryStubUnitTest.java b/testing-modules/mockito-2/src/test/java/com/baeldung/mockito/misusing/MockitoUnecessaryStubUnitTest.java new file mode 100644 index 0000000000..00edb699de --- /dev/null +++ b/testing-modules/mockito-2/src/test/java/com/baeldung/mockito/misusing/MockitoUnecessaryStubUnitTest.java @@ -0,0 +1,52 @@ +package com.baeldung.mockito.misusing; + +import static org.junit.Assert.assertEquals; +import static org.mockito.ArgumentMatchers.anyInt; +import static org.mockito.Mockito.lenient; +import static org.mockito.Mockito.when; + +import java.util.ArrayList; + +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; +import org.mockito.exceptions.misusing.UnnecessaryStubbingException; +import org.mockito.junit.MockitoJUnit; +import org.mockito.quality.Strictness; + +public class MockitoUnecessaryStubUnitTest { + + @Rule + public ExpectedTestFailureRule rule = new ExpectedTestFailureRule(MockitoJUnit.rule() + .strictness(Strictness.STRICT_STUBS)); + + @Mock + private ArrayList mockList; + + @Before + public void setUp() { + MockitoAnnotations.initMocks(this); + } + + @Test + public void givenUnusedStub_whenInvokingGetThenThrowUnnecessaryStubbingException() { + rule.expectedFailure(UnnecessaryStubbingException.class); + + when(mockList.add("one")).thenReturn(true); + when(mockList.get(anyInt())).thenReturn("hello"); + + assertEquals("List should contain hello", "hello", mockList.get(1)); + } + + @Test + public void givenLenientdStub_whenInvokingGetThenDontThrowUnnecessaryStubbingException() { + lenient().when(mockList.add("one")) + .thenReturn(true); + when(mockList.get(anyInt())).thenReturn("hello"); + + assertEquals("List should contain hello", "hello", mockList.get(1)); + } + +} diff --git a/testing-modules/rest-assured/pom.xml b/testing-modules/rest-assured/pom.xml index c528a34e21..4ed10f0641 100644 --- a/testing-modules/rest-assured/pom.xml +++ b/testing-modules/rest-assured/pom.xml @@ -197,8 +197,6 @@ 2.9.7 1.8 19.0 - - 3.1.0 2.5 1.4.7 9.4.0.v20161208 diff --git a/testing-modules/rest-testing/pom.xml b/testing-modules/rest-testing/pom.xml index c3a9477a47..6dad3be117 100644 --- a/testing-modules/rest-testing/pom.xml +++ b/testing-modules/rest-testing/pom.xml @@ -149,9 +149,6 @@ - - 2.9.7 - 19.0 3.5 diff --git a/testing-modules/test-containers/pom.xml b/testing-modules/test-containers/pom.xml index 1f4c483988..7ee002ea8b 100644 --- a/testing-modules/test-containers/pom.xml +++ b/testing-modules/test-containers/pom.xml @@ -103,7 +103,6 @@ 1.0.1 4.12.1 2.8.2 - 1.4.196 2.21.0 5.0.1.RELEASE 1.7.2 diff --git a/vaadin/pom.xml b/vaadin/pom.xml index ec69e240e2..648343fcd8 100644 --- a/vaadin/pom.xml +++ b/vaadin/pom.xml @@ -155,7 +155,6 @@ - 3.0.1 10.0.11 10.0.11 10.0.11 diff --git a/vavr/pom.xml b/vavr/pom.xml index ae495e9830..a2c6e29cde 100644 --- a/vavr/pom.xml +++ b/vavr/pom.xml @@ -41,7 +41,6 @@
- 1.8 0.9.1 3.0.0 diff --git a/video-tutorials/jackson-annotations/pom.xml b/video-tutorials/jackson-annotations/pom.xml index b0e1c7e8d9..2492951d1a 100644 --- a/video-tutorials/jackson-annotations/pom.xml +++ b/video-tutorials/jackson-annotations/pom.xml @@ -136,10 +136,6 @@ - - - 2.9.7 - 2.9.6 2.8.0 diff --git a/vraptor/pom.xml b/vraptor/pom.xml index 214a44cede..3904eb8c63 100644 --- a/vraptor/pom.xml +++ b/vraptor/pom.xml @@ -67,7 +67,7 @@ javax.servlet javax.servlet-api - ${servlet.version} + ${javax.servlet-api.version} provided @@ -129,8 +129,6 @@ 2.1.2.Final 2.2 5.1.1.Final - 1.2 - 3.1.0 1.7.5 4.1.0-RC3 4.0.4