repo stringclasses 1k
values | file_url stringlengths 96 373 | file_path stringlengths 11 294 | content stringlengths 0 32.8k | language stringclasses 1
value | license stringclasses 6
values | commit_sha stringclasses 1k
values | retrieved_at stringdate 2026-01-04 14:45:56 2026-01-04 18:30:23 | truncated bool 2
classes |
|---|---|---|---|---|---|---|---|---|
eugenp/tutorials | https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/jooby/src/test/java/com/baeldung/jooby/AppUnitTest.java | web-modules/jooby/src/test/java/com/baeldung/jooby/AppUnitTest.java | package com.baeldung.jooby;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
import io.jooby.MockRouter;
public class AppUnitTest {
@Test
public void given_defaultUrl_with_mockrouter_expect_fixedString() {
MockRouter router = new MockRouter(new App());
assertEquals("Hello World!", router.get("/")
.value());
}
}
| java | MIT | 4463e58ffb73fe599bac2479abd84598c6e70a1a | 2026-01-04T14:45:57.069771Z | false |
eugenp/tutorials | https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/jooby/src/test/java/com/baeldung/jooby/AppLiveTest.java | web-modules/jooby/src/test/java/com/baeldung/jooby/AppLiveTest.java | package com.baeldung.jooby;
import static org.junit.jupiter.api.Assertions.assertEquals;
import java.io.IOException;
import org.junit.jupiter.api.Test;
import io.jooby.JoobyTest;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
@JoobyTest(value = App.class, port = 8080)
class AppLiveTest {
static OkHttpClient client = new OkHttpClient();
@Test
void given_defaultUrl_expect_fixedString() {
Request request = new Request.Builder().url("http://localhost:8080")
.build();
try (Response response = client.newCall(request)
.execute()) {
assertEquals("Hello World!", response.body()
.string());
} catch (IOException e) {
e.printStackTrace();
}
}
}
| java | MIT | 4463e58ffb73fe599bac2479abd84598c6e70a1a | 2026-01-04T14:45:57.069771Z | false |
eugenp/tutorials | https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/jooby/src/main/java/com/baeldung/jooby/App.java | web-modules/jooby/src/main/java/com/baeldung/jooby/App.java | package com.baeldung.jooby;
import com.baeldung.jooby.bean.Employee;
import io.jooby.Jooby;
import io.jooby.ServerOptions;
import io.jooby.Session;
import io.jooby.SessionStore;
public class App extends Jooby {
{
setServerOptions(new ServerOptions().setPort(8080)
.setSecurePort(8433));
}
{
get("/", ctx -> "Hello World!");
}
{
get("/user/{id}", ctx -> "Hello user : " + ctx.path("id")
.value());
get("/user/:id", ctx -> "Hello user: " + ctx.path("id")
.value());
get("/uid:{id}", ctx -> "Hello User with id : uid = " + ctx.path("id")
.value());
}
{
onStarting(() -> System.out.println("starting app"));
onStop(() -> System.out.println("stopping app"));
onStarted(() -> System.out.println("app started"));
}
{
get("/login", ctx -> "Hello from Baeldung");
}
{
post("/save", ctx -> {
String userId = ctx.query("id")
.value();
return userId;
});
}
{
{
assets("/employee", "public/form.html");
}
post("/submitForm", ctx -> {
Employee employee = ctx.path(Employee.class);
// ...
return "employee data saved successfully";
});
}
{
decorator(next -> ctx -> {
System.out.println("first");
// Moves execution to next handler: second
return next.apply(ctx);
});
decorator(next -> ctx -> {
System.out.println("second");
// Moves execution to next handler: third
return next.apply(ctx);
});
get("/handler", ctx -> "third");
}
{
get("/sessionInMemory", ctx -> {
Session session = ctx.session();
session.put("token", "value");
return session.get("token")
.value();
});
}
{
String secret = "super secret token";
setSessionStore(SessionStore.signed(secret));
get("/signedSession", ctx -> {
Session session = ctx.session();
session.put("token", "value");
return session.get("token")
.value();
});
}
{
get("/sessionInMemoryRedis", ctx -> {
Session session = ctx.session();
session.put("token", "value");
return session.get("token")
.value();
});
}
/* This will work once redis is installed locally
{
install(new RedisModule("redis"));
setSessionStore(new RedisSessionStore(require(RedisClient.class)));
get("/redisSession", ctx -> {
Session session = ctx.session();
session.put("token", "value");
return session.get("token");
});
}*/
public static void main(final String[] args) {
runApp(args, App::new);
}
}
| java | MIT | 4463e58ffb73fe599bac2479abd84598c6e70a1a | 2026-01-04T14:45:57.069771Z | false |
eugenp/tutorials | https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/jooby/src/main/java/com/baeldung/jooby/mvc/GetController.java | web-modules/jooby/src/main/java/com/baeldung/jooby/mvc/GetController.java | package com.baeldung.jooby.mvc;
import java.util.HashMap;
import io.jooby.ModelAndView;
import io.jooby.annotations.GET;
import io.jooby.annotations.Path;
@Path("/hello")
public class GetController {
@GET
public String hello() {
return "Hello Baeldung";
}
@GET
@Path("/home")
public ModelAndView home() {
return new ModelAndView("welcome.html", new HashMap<>());
}
}
| java | MIT | 4463e58ffb73fe599bac2479abd84598c6e70a1a | 2026-01-04T14:45:57.069771Z | false |
eugenp/tutorials | https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/jooby/src/main/java/com/baeldung/jooby/mvc/PostController.java | web-modules/jooby/src/main/java/com/baeldung/jooby/mvc/PostController.java | package com.baeldung.jooby.mvc;
import io.jooby.annotations.POST;
import io.jooby.annotations.Path;
@Path("/submit")
public class PostController {
@POST
public String hello() {
return "Submit Baeldung";
}
}
| java | MIT | 4463e58ffb73fe599bac2479abd84598c6e70a1a | 2026-01-04T14:45:57.069771Z | false |
eugenp/tutorials | https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/jooby/src/main/java/com/baeldung/jooby/bean/Employee.java | web-modules/jooby/src/main/java/com/baeldung/jooby/bean/Employee.java | package com.baeldung.jooby.bean;
public class Employee {
String id;
String name;
String email;
public Employee(String id, String name, String email) {
super();
this.id = id;
this.name = name;
this.email = email;
}
}
| java | MIT | 4463e58ffb73fe599bac2479abd84598c6e70a1a | 2026-01-04T14:45:57.069771Z | false |
eugenp/tutorials | https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/jsf/src/main/java/com/baeldung/springintegration/dao/UserManagementDAOImpl.java | web-modules/jsf/src/main/java/com/baeldung/springintegration/dao/UserManagementDAOImpl.java | package com.baeldung.springintegration.dao;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Repository;
import java.util.ArrayList;
import java.util.List;
import jakarta.annotation.PostConstruct;
@Repository
public class UserManagementDAOImpl implements UserManagementDAO {
private static final Logger LOGGER = LoggerFactory.getLogger(UserManagementDAOImpl.class);
private List<String> users;
@PostConstruct
public void initUserList() {
users = new ArrayList<>();
}
@Override
public boolean createUser(String newUserData) {
if (newUserData != null) {
users.add(newUserData);
LOGGER.info("User {} successfully created", newUserData);
return true;
} else {
return false;
}
}
public UserManagementDAOImpl() {
}
}
| java | MIT | 4463e58ffb73fe599bac2479abd84598c6e70a1a | 2026-01-04T14:45:57.069771Z | false |
eugenp/tutorials | https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/jsf/src/main/java/com/baeldung/springintegration/dao/UserManagementDAO.java | web-modules/jsf/src/main/java/com/baeldung/springintegration/dao/UserManagementDAO.java | package com.baeldung.springintegration.dao;
public interface UserManagementDAO {
boolean createUser(String newUserData);
}
| java | MIT | 4463e58ffb73fe599bac2479abd84598c6e70a1a | 2026-01-04T14:45:57.069771Z | false |
eugenp/tutorials | https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/jsf/src/main/java/com/baeldung/springintegration/controllers/RegistrationBean.java | web-modules/jsf/src/main/java/com/baeldung/springintegration/controllers/RegistrationBean.java | package com.baeldung.springintegration.controllers;
import com.baeldung.springintegration.dao.UserManagementDAO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import jakarta.faces.annotation.ManagedProperty;
import jakarta.faces.context.FacesContext;
import jakarta.faces.view.ViewScoped;
import jakarta.inject.Named;
import java.io.Serializable;
@Named("registration")
@ViewScoped
public class RegistrationBean implements Serializable {
private static final Logger LOGGER = LoggerFactory.getLogger(RegistrationBean.class);
@ManagedProperty(value = "#{userManagementDAO}")
transient private UserManagementDAO userDao;
private String userName;
private String operationMessage;
public void createNewUser() {
try {
LOGGER.info("Creating new user");
FacesContext context = FacesContext.getCurrentInstance();
boolean operationStatus = userDao.createUser(userName);
context.isValidationFailed();
if (operationStatus) {
operationMessage = "User " + userName + " created";
}
} catch (Exception ex) {
LOGGER.error("Error registering new user ");
ex.printStackTrace();
operationMessage = "Error " + userName + " not created";
}
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public void setUserDao(UserManagementDAO userDao) {
this.userDao = userDao;
}
public UserManagementDAO getUserDao() {
return this.userDao;
}
public String getOperationMessage() {
return operationMessage;
}
public void setOperationMessage(String operationMessage) {
this.operationMessage = operationMessage;
}
}
| java | MIT | 4463e58ffb73fe599bac2479abd84598c6e70a1a | 2026-01-04T14:45:57.069771Z | false |
eugenp/tutorials | https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/jsf/src/main/java/com/baeldung/springintegration/controllers/HelloPFBean.java | web-modules/jsf/src/main/java/com/baeldung/springintegration/controllers/HelloPFBean.java | package com.baeldung.springintegration.controllers;
import java.util.ArrayList;
import java.util.List;
import jakarta.annotation.PostConstruct;
import jakarta.faces.view.ViewScoped;
import jakarta.inject.Named;
@Named("helloPFBean")
@ViewScoped
public class HelloPFBean {
private String firstName;
private String lastName;
private String componentSuite;
private List<Technology> technologies;
private String inputText;
private String outputText;
@PostConstruct
public void init() {
firstName = "Hello";
lastName = "Primefaces";
technologies = new ArrayList<Technology>();
Technology technology1 = new Technology();
technology1.setCurrentVersion("10");
technology1.setName("Java");
technologies.add(technology1);
Technology technology2 = new Technology();
technology2.setCurrentVersion("5.0");
technology2.setName("Spring");
technologies.add(technology2);
}
public void onBlurEvent() {
outputText = inputText.toUpperCase();
}
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 getComponentSuite() {
return componentSuite;
}
public void setComponentSuite(String componentSuite) {
this.componentSuite = componentSuite;
}
public List<Technology> getTechnologies() {
return technologies;
}
public void setTechnologies(List<Technology> technologies) {
this.technologies = technologies;
}
public String getInputText() {
return inputText;
}
public void setInputText(String inputText) {
this.inputText = inputText;
}
public String getOutputText() {
return outputText;
}
public void setOutputText(String outputText) {
this.outputText = outputText;
}
public class Technology {
private String name;
private String currentVersion;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getCurrentVersion() {
return currentVersion;
}
public void setCurrentVersion(String currentVersion) {
this.currentVersion = currentVersion;
}
}
}
| java | MIT | 4463e58ffb73fe599bac2479abd84598c6e70a1a | 2026-01-04T14:45:57.069771Z | false |
eugenp/tutorials | https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/jsf/src/main/java/com/baeldung/springintegration/controllers/ELSampleBean.java | web-modules/jsf/src/main/java/com/baeldung/springintegration/controllers/ELSampleBean.java | package com.baeldung.springintegration.controllers;
import jakarta.annotation.PostConstruct;
import jakarta.el.ELContextEvent;
import jakarta.el.ELContextListener;
import jakarta.el.LambdaExpression;
import jakarta.faces.application.Application;
import jakarta.faces.application.FacesMessage;
import jakarta.faces.context.FacesContext;
import jakarta.faces.view.ViewScoped;
import jakarta.inject.Named;
import java.util.Random;
@Named("ELBean")
@ViewScoped
public class ELSampleBean {
private String firstName;
private String lastName;
private String pageDescription = "This page demos JSF EL Basics";
public static final String constantField = "THIS_IS_NOT_CHANGING_ANYTIME_SOON";
private int pageCounter;
private Random randomIntGen = new Random();
@PostConstruct
public void init() {
pageCounter = randomIntGen.nextInt();
FacesContext.getCurrentInstance()
.getApplication()
.addELContextListener(new ELContextListener() {
@Override
public void contextCreated(ELContextEvent evt) {
evt.getELContext()
.getImportHandler()
.importClass("com.baeldung.springintegration.controllers.ELSampleBean");
}
});
}
public void save() {
}
public static String constantField() {
return constantField;
}
public void saveFirstName(String firstName) {
this.firstName = firstName;
}
public Long multiplyValue(LambdaExpression expr) {
Long theResult = (Long) expr.invoke(FacesContext.getCurrentInstance()
.getELContext(), pageCounter);
return theResult;
}
public void saveByELEvaluation() {
firstName = (String) evaluateEL("#{firstName.value}", String.class);
FacesContext ctx = FacesContext.getCurrentInstance();
FacesMessage theMessage = new FacesMessage("Name component Evaluated: " + firstName);
theMessage.setSeverity(FacesMessage.SEVERITY_INFO);
ctx.addMessage(null, theMessage);
}
private Object evaluateEL(String elExpression, Class<?> clazz) {
Object toReturn = null;
FacesContext ctx = FacesContext.getCurrentInstance();
Application app = ctx.getApplication();
toReturn = app.evaluateExpressionGet(ctx, elExpression, clazz);
return toReturn;
}
/**
* @return the firstName
*/
public String getFirstName() {
return firstName;
}
/**
* @param firstName the firstName to set
*/
public void setFirstName(String firstName) {
this.firstName = firstName;
}
/**
* @return the lastName
*/
public String getLastName() {
return lastName;
}
/**
* @param lastName the lastName to set
*/
public void setLastName(String lastName) {
this.lastName = lastName;
}
/**
* @return the pageDescription
*/
public String getPageDescription() {
return pageDescription;
}
/**
* @param pageDescription the pageDescription to set
*/
public void setPageDescription(String pageDescription) {
this.pageDescription = pageDescription;
}
/**
* @return the pageCounter
*/
public int getPageCounter() {
return pageCounter;
}
/**
* @param pageCounter the pageCounter to set
*/
public void setPageCounter(int pageCounter) {
this.pageCounter = pageCounter;
}
}
| java | MIT | 4463e58ffb73fe599bac2479abd84598c6e70a1a | 2026-01-04T14:45:57.069771Z | false |
eugenp/tutorials | https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/jsf/src/main/java/com/baeldung/springintegration/controllers/HelloPFMBean.java | web-modules/jsf/src/main/java/com/baeldung/springintegration/controllers/HelloPFMBean.java | package com.baeldung.springintegration.controllers;
import jakarta.inject.Named;
import jakarta.enterprise.context.SessionScoped;
@Named("helloPFMBean")
@SessionScoped
public class HelloPFMBean {
private String magicWord;
public String getMagicWord() {
return magicWord;
}
public void setMagicWord(String magicWord) {
this.magicWord = magicWord;
}
public String go() {
if (this.magicWord != null && this.magicWord.toUpperCase()
.equals("BAELDUNG")) {
return "pm:success";
}
return "pm:failure";
}
}
| java | MIT | 4463e58ffb73fe599bac2479abd84598c6e70a1a | 2026-01-04T14:45:57.069771Z | false |
eugenp/tutorials | https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/jsf/src/main/java/com/baeldung/springintegration/config/SpringCoreConfig.java | web-modules/jsf/src/main/java/com/baeldung/springintegration/config/SpringCoreConfig.java | package com.baeldung.springintegration.config;
import com.baeldung.springintegration.dao.UserManagementDAO;
import com.baeldung.springintegration.dao.UserManagementDAOImpl;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class SpringCoreConfig {
@Bean
public UserManagementDAO userManagementDAO() {
return new UserManagementDAOImpl();
}
}
| java | MIT | 4463e58ffb73fe599bac2479abd84598c6e70a1a | 2026-01-04T14:45:57.069771Z | false |
eugenp/tutorials | https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/jsf/src/main/java/com/baeldung/springintegration/config/MainWebAppInitializer.java | web-modules/jsf/src/main/java/com/baeldung/springintegration/config/MainWebAppInitializer.java | package com.baeldung.springintegration.config;
import com.sun.faces.config.FacesInitializer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.WebApplicationInitializer;
import org.springframework.web.context.ContextLoaderListener;
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;
import jakarta.servlet.ServletContext;
import jakarta.servlet.ServletException;
import java.util.Set;
public class MainWebAppInitializer extends FacesInitializer implements WebApplicationInitializer {
private static final Logger LOGGER = LoggerFactory.getLogger(MainWebAppInitializer.class);
@Override
public void onStartup(Set<Class<?>> classes, ServletContext servletContext) throws ServletException {
super.onStartup(classes, servletContext);
}
/**
* Register and configure all Servlet container components necessary to power the web application.
*/
@Override
public void onStartup(final ServletContext sc) throws ServletException {
LOGGER.info("MainWebAppInitializer.onStartup()");
sc.setInitParameter("javax.faces.FACELETS_SKIP_COMMENTS", "true");
// Create the 'root' Spring application context
final AnnotationConfigWebApplicationContext root = new AnnotationConfigWebApplicationContext();
root.register(SpringCoreConfig.class);
sc.addListener(new ContextLoaderListener(root));
}
}
| java | MIT | 4463e58ffb73fe599bac2479abd84598c6e70a1a | 2026-01-04T14:45:57.069771Z | false |
eugenp/tutorials | https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/dropwizard/src/test/java/com/baeldung/dropwizard/introduction/repository/BrandRepositoryUnitTest.java | web-modules/dropwizard/src/test/java/com/baeldung/dropwizard/introduction/repository/BrandRepositoryUnitTest.java | package com.baeldung.dropwizard.introduction.repository;
import com.baeldung.dropwizard.introduction.domain.Brand;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import static org.junit.jupiter.api.Assertions.assertEquals;
class BrandRepositoryUnitTest {
private static final Brand BRAND_1 = new Brand(1L, "Brand1");
private final BrandRepository brandRepository = new BrandRepository(getBrands());
@Test
void givenSize_whenFindingAll_thenReturnList() {
final int size = 2;
final List<Brand> result = brandRepository.findAll(size);
assertEquals(size, result.size());
}
@Test
void givenId_whenFindingById_thenReturnFoundBrand() {
final Long id = BRAND_1.getId();
final Optional<Brand> result = brandRepository.findById(id);
Assertions.assertTrue(result.isPresent());
assertEquals(BRAND_1, result.get());
}
private List<Brand> getBrands() {
final List<Brand> brands = new ArrayList<>();
brands.add(BRAND_1);
brands.add(new Brand(2L, "Brand2"));
brands.add(new Brand(3L, "Brand3"));
return brands;
}
} | java | MIT | 4463e58ffb73fe599bac2479abd84598c6e70a1a | 2026-01-04T14:45:57.069771Z | false |
eugenp/tutorials | https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/dropwizard/src/main/java/com/baeldung/dropwizard/introduction/IntroductionApplication.java | web-modules/dropwizard/src/main/java/com/baeldung/dropwizard/introduction/IntroductionApplication.java | package com.baeldung.dropwizard.introduction;
import com.baeldung.dropwizard.introduction.configuration.ApplicationHealthCheck;
import com.baeldung.dropwizard.introduction.configuration.BasicConfiguration;
import com.baeldung.dropwizard.introduction.domain.Brand;
import com.baeldung.dropwizard.introduction.repository.BrandRepository;
import com.baeldung.dropwizard.introduction.resource.BrandResource;
import io.dropwizard.Application;
import io.dropwizard.configuration.ResourceConfigurationSourceProvider;
import io.dropwizard.setup.Bootstrap;
import io.dropwizard.setup.Environment;
import java.util.ArrayList;
import java.util.List;
public class IntroductionApplication extends Application<BasicConfiguration> {
public static void main(final String[] args) throws Exception {
new IntroductionApplication().run("server", "introduction-config.yml");
}
@Override
public void run(final BasicConfiguration basicConfiguration, final Environment environment) {
final int defaultSize = basicConfiguration.getDefaultSize();
final BrandRepository brandRepository = new BrandRepository(initBrands());
final BrandResource brandResource = new BrandResource(defaultSize, brandRepository);
environment
.jersey()
.register(brandResource);
final ApplicationHealthCheck healthCheck = new ApplicationHealthCheck();
environment
.healthChecks()
.register("application", healthCheck);
}
@Override
public void initialize(final Bootstrap<BasicConfiguration> bootstrap) {
bootstrap.setConfigurationSourceProvider(new ResourceConfigurationSourceProvider());
super.initialize(bootstrap);
}
private List<Brand> initBrands() {
final List<Brand> brands = new ArrayList<>();
brands.add(new Brand(1L, "Brand1"));
brands.add(new Brand(2L, "Brand2"));
brands.add(new Brand(3L, "Brand3"));
return brands;
}
}
| java | MIT | 4463e58ffb73fe599bac2479abd84598c6e70a1a | 2026-01-04T14:45:57.069771Z | false |
eugenp/tutorials | https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/dropwizard/src/main/java/com/baeldung/dropwizard/introduction/resource/BrandResource.java | web-modules/dropwizard/src/main/java/com/baeldung/dropwizard/introduction/resource/BrandResource.java | package com.baeldung.dropwizard.introduction.resource;
import com.baeldung.dropwizard.introduction.domain.Brand;
import com.baeldung.dropwizard.introduction.repository.BrandRepository;
import javax.ws.rs.*;
import javax.ws.rs.core.MediaType;
import java.util.List;
import java.util.Optional;
@Path("/brands")
@Produces(MediaType.APPLICATION_JSON)
public class BrandResource {
private final int defaultSize;
private final BrandRepository brandRepository;
public BrandResource(final int defaultSize, final BrandRepository brandRepository) {
this.defaultSize = defaultSize;
this.brandRepository = brandRepository;
}
@GET
public List<Brand> getBrands(@QueryParam("size") final Optional<Integer> size) {
return brandRepository.findAll(size.orElse(defaultSize));
}
@GET
@Path("/{id}")
public Brand getById(@PathParam("id") final Long id) {
return brandRepository
.findById(id)
.orElseThrow(RuntimeException::new);
}
}
| java | MIT | 4463e58ffb73fe599bac2479abd84598c6e70a1a | 2026-01-04T14:45:57.069771Z | false |
eugenp/tutorials | https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/dropwizard/src/main/java/com/baeldung/dropwizard/introduction/configuration/BasicConfiguration.java | web-modules/dropwizard/src/main/java/com/baeldung/dropwizard/introduction/configuration/BasicConfiguration.java | package com.baeldung.dropwizard.introduction.configuration;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.dropwizard.Configuration;
import javax.validation.constraints.NotNull;
public class BasicConfiguration extends Configuration {
@NotNull private final int defaultSize;
@JsonCreator
public BasicConfiguration(@JsonProperty("defaultSize") final int defaultSize) {
this.defaultSize = defaultSize;
}
public int getDefaultSize() {
return defaultSize;
}
}
| java | MIT | 4463e58ffb73fe599bac2479abd84598c6e70a1a | 2026-01-04T14:45:57.069771Z | false |
eugenp/tutorials | https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/dropwizard/src/main/java/com/baeldung/dropwizard/introduction/configuration/ApplicationHealthCheck.java | web-modules/dropwizard/src/main/java/com/baeldung/dropwizard/introduction/configuration/ApplicationHealthCheck.java | package com.baeldung.dropwizard.introduction.configuration;
import com.codahale.metrics.health.HealthCheck;
public class ApplicationHealthCheck extends HealthCheck {
@Override
protected Result check() throws Exception {
return Result.healthy();
}
}
| java | MIT | 4463e58ffb73fe599bac2479abd84598c6e70a1a | 2026-01-04T14:45:57.069771Z | false |
eugenp/tutorials | https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/dropwizard/src/main/java/com/baeldung/dropwizard/introduction/domain/Brand.java | web-modules/dropwizard/src/main/java/com/baeldung/dropwizard/introduction/domain/Brand.java | package com.baeldung.dropwizard.introduction.domain;
public class Brand {
private final Long id;
private final String name;
public Brand(final Long id, final String name) {
this.id = id;
this.name = name;
}
public Long getId() {
return id;
}
public String getName() {
return name;
}
}
| java | MIT | 4463e58ffb73fe599bac2479abd84598c6e70a1a | 2026-01-04T14:45:57.069771Z | false |
eugenp/tutorials | https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/dropwizard/src/main/java/com/baeldung/dropwizard/introduction/repository/BrandRepository.java | web-modules/dropwizard/src/main/java/com/baeldung/dropwizard/introduction/repository/BrandRepository.java | package com.baeldung.dropwizard.introduction.repository;
import com.baeldung.dropwizard.introduction.domain.Brand;
import com.google.common.collect.ImmutableList;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
public class BrandRepository {
private final List<Brand> brands;
public BrandRepository(final List<Brand> brands) {
this.brands = ImmutableList.copyOf(brands);
}
public List<Brand> findAll(final int size) {
return brands
.stream()
.limit(size)
.collect(Collectors.toList());
}
public Optional<Brand> findById(final Long id) {
return brands
.stream()
.filter(brand -> brand
.getId()
.equals(id))
.findFirst();
}
}
| java | MIT | 4463e58ffb73fe599bac2479abd84598c6e70a1a | 2026-01-04T14:45:57.069771Z | false |
eugenp/tutorials | https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/jee-7/src/test/java/com/baeldung/batch/understanding/CustomCheckPointIntegrationTest.java | web-modules/jee-7/src/test/java/com/baeldung/batch/understanding/CustomCheckPointIntegrationTest.java | package com.baeldung.batch.understanding;
import static org.junit.jupiter.api.Assertions.assertEquals;
import java.util.Properties;
import javax.batch.operations.JobOperator;
import javax.batch.runtime.BatchRuntime;
import javax.batch.runtime.BatchStatus;
import javax.batch.runtime.JobExecution;
import javax.batch.runtime.StepExecution;
import org.junit.jupiter.api.Test;
class CustomCheckPointIntegrationTest {
@Test
public void givenChunk_whenCustomCheckPoint_thenCommitCountIsThree() throws Exception {
JobOperator jobOperator = BatchRuntime.getJobOperator();
Long executionId = jobOperator.start("customCheckPoint", new Properties());
JobExecution jobExecution = jobOperator.getJobExecution(executionId);
jobExecution = BatchTestHelper.keepTestAlive(jobExecution);
for (StepExecution stepExecution : jobOperator.getStepExecutions(executionId)) {
if (stepExecution.getStepName()
.equals("firstChunkStep")) {
jobOperator.getStepExecutions(executionId)
.stream()
.map(BatchTestHelper::getCommitCount)
.forEach(count -> assertEquals(3L, count.longValue()));
}
}
assertEquals(jobExecution.getBatchStatus(), BatchStatus.COMPLETED);
}
}
| java | MIT | 4463e58ffb73fe599bac2479abd84598c6e70a1a | 2026-01-04T14:45:57.069771Z | false |
eugenp/tutorials | https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/jee-7/src/test/java/com/baeldung/batch/understanding/SimpleChunkIntegrationTest.java | web-modules/jee-7/src/test/java/com/baeldung/batch/understanding/SimpleChunkIntegrationTest.java | package com.baeldung.batch.understanding;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import javax.batch.operations.JobOperator;
import javax.batch.runtime.BatchRuntime;
import javax.batch.runtime.BatchStatus;
import javax.batch.runtime.JobExecution;
import javax.batch.runtime.Metric;
import javax.batch.runtime.StepExecution;
import org.junit.jupiter.api.Test;
class SimpleChunkIntegrationTest {
@Test
public void givenChunk_thenBatch_CompletesWithSucess() throws Exception {
JobOperator jobOperator = BatchRuntime.getJobOperator();
Long executionId = jobOperator.start("simpleChunk", new Properties());
JobExecution jobExecution = jobOperator.getJobExecution(executionId);
jobExecution = BatchTestHelper.keepTestAlive(jobExecution);
List<StepExecution> stepExecutions = jobOperator.getStepExecutions(executionId);
for (StepExecution stepExecution : stepExecutions) {
if (stepExecution.getStepName()
.equals("firstChunkStep")) {
Map<Metric.MetricType, Long> metricsMap = BatchTestHelper.getMetricsMap(stepExecution.getMetrics());
assertEquals(10L, metricsMap.get(Metric.MetricType.READ_COUNT)
.longValue());
assertEquals(10L / 2L, metricsMap.get(Metric.MetricType.WRITE_COUNT)
.longValue());
assertEquals(10L / 3 + (10L % 3 > 0 ? 1 : 0), metricsMap.get(Metric.MetricType.COMMIT_COUNT)
.longValue());
}
}
assertEquals(jobExecution.getBatchStatus(), BatchStatus.COMPLETED);
}
@Test
public void givenChunk__thenBatch_fetchInformation() throws Exception {
JobOperator jobOperator = BatchRuntime.getJobOperator();
Long executionId = jobOperator.start("simpleChunk", new Properties());
JobExecution jobExecution = jobOperator.getJobExecution(executionId);
jobExecution = BatchTestHelper.keepTestAlive(jobExecution);
// job name contains simpleBatchLet which is the name of the file
assertTrue(jobOperator.getJobNames().contains("simpleChunk"));
// job parameters are empty
assertTrue(jobOperator.getParameters(executionId).isEmpty());
// step execution information
List<StepExecution> stepExecutions = jobOperator.getStepExecutions(executionId);
assertEquals("firstChunkStep", stepExecutions.get(0).getStepName());
// finding out batch status
assertEquals(BatchStatus.COMPLETED, stepExecutions.get(0).getBatchStatus());
Map<Metric.MetricType, Long> metricTest = BatchTestHelper.getMetricsMap(stepExecutions.get(0).getMetrics());
assertEquals(10L, metricTest.get(Metric.MetricType.READ_COUNT).longValue());
assertEquals(5L, metricTest.get(Metric.MetricType.FILTER_COUNT).longValue());
assertEquals(4L, metricTest.get(Metric.MetricType.COMMIT_COUNT).longValue());
assertEquals(5L, metricTest.get(Metric.MetricType.WRITE_COUNT).longValue());
assertEquals(0L, metricTest.get(Metric.MetricType.READ_SKIP_COUNT).longValue());
assertEquals(0L, metricTest.get(Metric.MetricType.WRITE_SKIP_COUNT).longValue());
assertEquals(0L, metricTest.get(Metric.MetricType.PROCESS_SKIP_COUNT).longValue());
assertEquals(0L, metricTest.get(Metric.MetricType.ROLLBACK_COUNT).longValue());
assertEquals(jobExecution.getBatchStatus(), BatchStatus.COMPLETED);
}
}
| java | MIT | 4463e58ffb73fe599bac2479abd84598c6e70a1a | 2026-01-04T14:45:57.069771Z | false |
eugenp/tutorials | https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/jee-7/src/test/java/com/baeldung/batch/understanding/SimpleErrorChunkIntegrationTest.java | web-modules/jee-7/src/test/java/com/baeldung/batch/understanding/SimpleErrorChunkIntegrationTest.java | package com.baeldung.batch.understanding;
import static org.junit.Assert.assertEquals;
import java.util.List;
import java.util.Properties;
import javax.batch.operations.JobOperator;
import javax.batch.runtime.BatchRuntime;
import javax.batch.runtime.BatchStatus;
import javax.batch.runtime.JobExecution;
import javax.batch.runtime.StepExecution;
import org.junit.jupiter.api.Test;
class SimpleErrorChunkIntegrationTest {
@Test
public void givenChunkError_thenBatch_CompletesWithFailed() throws Exception {
JobOperator jobOperator = BatchRuntime.getJobOperator();
Long executionId = jobOperator.start("simpleErrorChunk", new Properties());
JobExecution jobExecution = jobOperator.getJobExecution(executionId);
jobExecution = BatchTestHelper.keepTestFailed(jobExecution);
assertEquals(jobExecution.getBatchStatus(), BatchStatus.FAILED);
}
@Test
public void givenChunkError_thenErrorSkipped_CompletesWithSuccess() throws Exception {
JobOperator jobOperator = BatchRuntime.getJobOperator();
Long executionId = jobOperator.start("simpleErrorSkipChunk", new Properties());
JobExecution jobExecution = jobOperator.getJobExecution(executionId);
jobExecution = BatchTestHelper.keepTestAlive(jobExecution);
List<StepExecution> stepExecutions = jobOperator.getStepExecutions(executionId);
for (StepExecution stepExecution : stepExecutions) {
if (stepExecution.getStepName()
.equals("errorStep")) {
jobOperator.getStepExecutions(executionId)
.stream()
.map(BatchTestHelper::getProcessSkipCount)
.forEach(skipCount -> assertEquals(1L, skipCount.longValue()));
}
}
assertEquals(jobExecution.getBatchStatus(), BatchStatus.COMPLETED);
}
}
| java | MIT | 4463e58ffb73fe599bac2479abd84598c6e70a1a | 2026-01-04T14:45:57.069771Z | false |
eugenp/tutorials | https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/jee-7/src/test/java/com/baeldung/batch/understanding/SimpleBatchLetIntegrationTest.java | web-modules/jee-7/src/test/java/com/baeldung/batch/understanding/SimpleBatchLetIntegrationTest.java | package com.baeldung.batch.understanding;
import static org.junit.jupiter.api.Assertions.assertEquals;
import java.util.Properties;
import javax.batch.operations.JobOperator;
import javax.batch.runtime.BatchRuntime;
import javax.batch.runtime.BatchStatus;
import javax.batch.runtime.JobExecution;
import org.junit.jupiter.api.Test;
class SimpleBatchLetIntegrationTest {
@Test
public void givenBatchLet_thenBatch_CompleteWithSuccess() throws Exception {
JobOperator jobOperator = BatchRuntime.getJobOperator();
Long executionId = jobOperator.start("simpleBatchLet", new Properties());
JobExecution jobExecution = jobOperator.getJobExecution(executionId);
jobExecution = BatchTestHelper.keepTestAlive(jobExecution);
assertEquals(jobExecution.getBatchStatus(), BatchStatus.COMPLETED);
}
@Test
public void givenBatchLetProperty_thenBatch_CompleteWithSuccess() throws Exception {
JobOperator jobOperator = BatchRuntime.getJobOperator();
Long executionId = jobOperator.start("injectionSimpleBatchLet", new Properties());
JobExecution jobExecution = jobOperator.getJobExecution(executionId);
jobExecution = BatchTestHelper.keepTestAlive(jobExecution);
assertEquals(jobExecution.getBatchStatus(), BatchStatus.COMPLETED);
}
@Test
public void givenBatchLetPartition_thenBatch_CompleteWithSuccess() throws Exception {
JobOperator jobOperator = BatchRuntime.getJobOperator();
Long executionId = jobOperator.start("partitionSimpleBatchLet", new Properties());
JobExecution jobExecution = jobOperator.getJobExecution(executionId);
jobExecution = BatchTestHelper.keepTestAlive(jobExecution);
assertEquals(jobExecution.getBatchStatus(), BatchStatus.COMPLETED);
}
@Test
public void givenBatchLetStarted_whenStopped_thenBatchStopped() throws Exception {
JobOperator jobOperator = BatchRuntime.getJobOperator();
Long executionId = jobOperator.start("simpleBatchLet", new Properties());
JobExecution jobExecution = jobOperator.getJobExecution(executionId);
jobOperator.stop(executionId);
jobExecution = BatchTestHelper.keepTestStopped(jobExecution);
assertEquals(jobExecution.getBatchStatus(), BatchStatus.STOPPED);
}
@Test
public void givenBatchLetStopped_whenRestarted_thenBatchCompletesSuccess() throws Exception {
JobOperator jobOperator = BatchRuntime.getJobOperator();
Long executionId = jobOperator.start("simpleBatchLet", new Properties());
JobExecution jobExecution = jobOperator.getJobExecution(executionId);
jobOperator.stop(executionId);
jobExecution = BatchTestHelper.keepTestStopped(jobExecution);
assertEquals(jobExecution.getBatchStatus(), BatchStatus.STOPPED);
executionId = jobOperator.restart(jobExecution.getExecutionId(), new Properties());
jobExecution = BatchTestHelper.keepTestAlive(jobOperator.getJobExecution(executionId));
assertEquals(jobExecution.getBatchStatus(), BatchStatus.COMPLETED);
}
}
| java | MIT | 4463e58ffb73fe599bac2479abd84598c6e70a1a | 2026-01-04T14:45:57.069771Z | false |
eugenp/tutorials | https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/jee-7/src/test/java/com/baeldung/batch/understanding/JobSequenceIntegrationTest.java | web-modules/jee-7/src/test/java/com/baeldung/batch/understanding/JobSequenceIntegrationTest.java | package com.baeldung.batch.understanding;
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
import javax.batch.operations.JobOperator;
import javax.batch.runtime.BatchRuntime;
import javax.batch.runtime.BatchStatus;
import javax.batch.runtime.JobExecution;
import javax.batch.runtime.StepExecution;
import org.junit.jupiter.api.Test;
class JobSequenceIntegrationTest {
@Test
public void givenTwoSteps_thenBatch_CompleteWithSuccess() throws Exception {
JobOperator jobOperator = BatchRuntime.getJobOperator();
Long executionId = jobOperator.start("simpleJobSequence", new Properties());
JobExecution jobExecution = jobOperator.getJobExecution(executionId);
jobExecution = BatchTestHelper.keepTestAlive(jobExecution);
assertEquals(2 , jobOperator.getStepExecutions(executionId).size());
assertEquals(jobExecution.getBatchStatus(), BatchStatus.COMPLETED);
}
@Test
public void givenFlow_thenBatch_CompleteWithSuccess() throws Exception {
JobOperator jobOperator = BatchRuntime.getJobOperator();
Long executionId = jobOperator.start("flowJobSequence", new Properties());
JobExecution jobExecution = jobOperator.getJobExecution(executionId);
jobExecution = BatchTestHelper.keepTestAlive(jobExecution);
assertEquals(3 , jobOperator.getStepExecutions(executionId).size());
assertEquals(jobExecution.getBatchStatus(), BatchStatus.COMPLETED);
}
@Test
public void givenDecider_thenBatch_CompleteWithSuccess() throws Exception {
JobOperator jobOperator = BatchRuntime.getJobOperator();
Long executionId = jobOperator.start("decideJobSequence", new Properties());
JobExecution jobExecution = jobOperator.getJobExecution(executionId);
jobExecution = BatchTestHelper.keepTestAlive(jobExecution);
List<StepExecution> stepExecutions = jobOperator.getStepExecutions(executionId);
List<String> executedSteps = new ArrayList<>();
for (StepExecution stepExecution : stepExecutions) {
executedSteps.add(stepExecution.getStepName());
}
assertEquals(2, jobOperator.getStepExecutions(executionId).size());
assertArrayEquals(new String[] { "firstBatchStepStep1", "firstBatchStepStep3" }, executedSteps.toArray());
assertEquals(jobExecution.getBatchStatus(), BatchStatus.COMPLETED);
}
@Test
public void givenSplit_thenBatch_CompletesWithSuccess() throws Exception {
JobOperator jobOperator = BatchRuntime.getJobOperator();
Long executionId = jobOperator.start("splitJobSequence", new Properties());
JobExecution jobExecution = jobOperator.getJobExecution(executionId);
jobExecution = BatchTestHelper.keepTestAlive(jobExecution);
List<StepExecution> stepExecutions = jobOperator.getStepExecutions(executionId);
List<String> executedSteps = new ArrayList<>();
for (StepExecution stepExecution : stepExecutions) {
executedSteps.add(stepExecution.getStepName());
}
assertEquals(3, stepExecutions.size());
assertTrue(executedSteps.contains("splitJobSequenceStep1"));
assertTrue(executedSteps.contains("splitJobSequenceStep2"));
assertTrue(executedSteps.contains("splitJobSequenceStep3"));
assertTrue(executedSteps.get(0).equals("splitJobSequenceStep1") || executedSteps.get(0).equals("splitJobSequenceStep2"));
assertTrue(executedSteps.get(1).equals("splitJobSequenceStep1") || executedSteps.get(1).equals("splitJobSequenceStep2"));
assertTrue(executedSteps.get(2).equals("splitJobSequenceStep3"));
assertEquals(jobExecution.getBatchStatus(), BatchStatus.COMPLETED);
}
}
| java | MIT | 4463e58ffb73fe599bac2479abd84598c6e70a1a | 2026-01-04T14:45:57.069771Z | false |
eugenp/tutorials | https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/jee-7/src/test/java/com/baeldung/batch/understanding/BatchTestHelper.java | web-modules/jee-7/src/test/java/com/baeldung/batch/understanding/BatchTestHelper.java | package com.baeldung.batch.understanding;
import java.util.HashMap;
import java.util.Map;
import javax.batch.runtime.BatchRuntime;
import javax.batch.runtime.BatchStatus;
import javax.batch.runtime.JobExecution;
import javax.batch.runtime.Metric;
import javax.batch.runtime.StepExecution;
public class BatchTestHelper {
private static final int MAX_TRIES = 40;
private static final int THREAD_SLEEP = 1000;
private BatchTestHelper() {
throw new UnsupportedOperationException();
}
public static JobExecution keepTestAlive(JobExecution jobExecution) throws InterruptedException {
int maxTries = 0;
while (!jobExecution.getBatchStatus()
.equals(BatchStatus.COMPLETED)) {
if (maxTries < MAX_TRIES) {
maxTries++;
Thread.sleep(THREAD_SLEEP);
jobExecution = BatchRuntime.getJobOperator()
.getJobExecution(jobExecution.getExecutionId());
} else {
break;
}
}
Thread.sleep(THREAD_SLEEP);
return jobExecution;
}
public static JobExecution keepTestFailed(JobExecution jobExecution) throws InterruptedException {
int maxTries = 0;
while (!jobExecution.getBatchStatus()
.equals(BatchStatus.FAILED)) {
if (maxTries < MAX_TRIES) {
maxTries++;
Thread.sleep(THREAD_SLEEP);
jobExecution = BatchRuntime.getJobOperator()
.getJobExecution(jobExecution.getExecutionId());
} else {
break;
}
}
Thread.sleep(THREAD_SLEEP);
return jobExecution;
}
public static JobExecution keepTestStopped(JobExecution jobExecution) throws InterruptedException {
int maxTries = 0;
while (!jobExecution.getBatchStatus()
.equals(BatchStatus.STOPPED)) {
if (maxTries < MAX_TRIES) {
maxTries++;
Thread.sleep(THREAD_SLEEP);
jobExecution = BatchRuntime.getJobOperator()
.getJobExecution(jobExecution.getExecutionId());
} else {
break;
}
}
Thread.sleep(THREAD_SLEEP);
return jobExecution;
}
public static long getCommitCount(StepExecution stepExecution) {
Map<Metric.MetricType, Long> metricsMap = getMetricsMap(stepExecution.getMetrics());
return metricsMap.get(Metric.MetricType.COMMIT_COUNT);
}
public static long getProcessSkipCount(StepExecution stepExecution) {
Map<Metric.MetricType, Long> metricsMap = getMetricsMap(stepExecution.getMetrics());
return metricsMap.get(Metric.MetricType.PROCESS_SKIP_COUNT);
}
public static Map<Metric.MetricType, Long> getMetricsMap(Metric[] metrics) {
Map<Metric.MetricType, Long> metricsMap = new HashMap<>();
for (Metric metric : metrics) {
metricsMap.put(metric.getType(), metric.getValue());
}
return metricsMap;
}
}
| java | MIT | 4463e58ffb73fe599bac2479abd84598c6e70a1a | 2026-01-04T14:45:57.069771Z | false |
eugenp/tutorials | https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/jee-7/src/test/java/com/baeldung/convListVal/ConvListValLiveTest.java | web-modules/jee-7/src/test/java/com/baeldung/convListVal/ConvListValLiveTest.java | package com.baeldung.convListVal;
import static org.jboss.arquillian.graphene.Graphene.guardHttp;
import java.io.File;
import java.net.URL;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.container.test.api.RunAsClient;
import org.jboss.arquillian.drone.api.annotation.Drone;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.arquillian.test.api.ArquillianResource;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.asset.EmptyAsset;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
@RunWith(Arquillian.class)
public class ConvListValLiveTest {
@ArquillianResource
private URL deploymentUrl;
private static final String WEBAPP_SRC = "src/main/webapp";
@Deployment(testable = false)
public static WebArchive createDeployment() {
return ( ShrinkWrap.create(
WebArchive.class, "jee7.war").
addClasses(ConvListVal.class, MyListener.class)).
addAsWebResource(new File(WEBAPP_SRC, "ConvListVal.xhtml")).
addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml");
}
@Drone
WebDriver browser;
@ArquillianResource
URL contextPath;
@FindBy(id="myForm:age")
private WebElement ageInput;
@FindBy(id="myForm:average")
private WebElement averageInput;
@FindBy(id="myForm:send")
private WebElement sendButton;
@Test
@RunAsClient
public void givenAge_whenAgeInvalid_thenErrorMessage() throws Exception {
browser.get(deploymentUrl.toExternalForm() + "ConvListVal.jsf");
ageInput.sendKeys("stringage");
guardHttp(sendButton).click();
Assert.assertTrue("Show Age error message", browser.findElements(By.id("myForm:ageError")).size() > 0);
}
@Test
@RunAsClient
public void givenAverage_whenAverageInvalid_thenErrorMessage() throws Exception {
browser.get(deploymentUrl.toExternalForm() + "ConvListVal.jsf");
averageInput.sendKeys("stringaverage");
guardHttp(sendButton).click();
Assert.assertTrue("Show Average error message", browser.findElements(By.id("myForm:averageError")).size() > 0);
}
@Test
@RunAsClient
public void givenDate_whenDateInvalid_thenErrorMessage() throws Exception {
browser.get(deploymentUrl.toExternalForm() + "ConvListVal.jsf");
averageInput.sendKeys("123");
guardHttp(sendButton).click();
Assert.assertTrue("Show Date error message", browser.findElements(By.id("myForm:myDateError")).size() > 0);
}
@Test
@RunAsClient
public void givenSurname_whenSurnameMinLenghtInvalid_thenErrorMessage() throws Exception {
browser.get(deploymentUrl.toExternalForm() + "ConvListVal.jsf");
averageInput.sendKeys("aaa");
guardHttp(sendButton).click();
Assert.assertTrue("Show Surname error message", browser.findElements(By.id("myForm:surnameError")).size() > 0);
}
@Test
@RunAsClient
public void givenSurname_whenSurnameMaxLenghtInvalid_thenErrorMessage() throws Exception {
browser.get(deploymentUrl.toExternalForm() + "ConvListVal.jsf");
averageInput.sendKeys("aaaaabbbbbc");
guardHttp(sendButton).click();
Assert.assertTrue("Show Surname error message", browser.findElements(By.id("myForm:surnameError")).size() > 0);
}
}
| java | MIT | 4463e58ffb73fe599bac2479abd84598c6e70a1a | 2026-01-04T14:45:57.069771Z | false |
eugenp/tutorials | https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/jee-7/src/test/java/com/baeldung/singleton/CarServiceLiveTest.java | web-modules/jee-7/src/test/java/com/baeldung/singleton/CarServiceLiveTest.java | 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.enterprise.context.spi.CreationalContext;
import javax.enterprise.inject.spi.Bean;
import javax.enterprise.inject.spi.BeanManager;
import javax.enterprise.inject.spi.CDI;
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 CarServiceLiveTest {
public static final Logger LOG = LoggerFactory.getLogger(CarServiceLiveTest.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;
@Test
public void givenASingleton_whenGetBeanIsCalledTwice_thenTheSameInstanceIsReturned() {
CarServiceSingleton one = getBean(CarServiceSingleton.class);
CarServiceSingleton two = getBean(CarServiceSingleton.class);
assertTrue(one == two);
}
@Test
public void givenAPojo_whenGetBeanIsCalledTwice_thenDifferentInstancesAreReturned() {
CarServiceBean one = getBean(CarServiceBean.class);
CarServiceBean two = getBean(CarServiceBean.class);
assertTrue(one != two);
}
@SuppressWarnings("unchecked")
private <T> T getBean(Class<T> beanClass) {
BeanManager bm = CDI.current().getBeanManager();
Bean<T> bean = (Bean<T>) bm.getBeans(beanClass).iterator().next();
CreationalContext<T> ctx = bm.createCreationalContext(bean);
return (T) bm.getReference(bean, beanClass, ctx);
}
@Test
public void givenCDI_whenConcurrentAccess_thenLockingIsNotProvided() {
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 givenEJB_whenConcurrentAccess_thenLockingIsProvided() {
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;
}
} | java | MIT | 4463e58ffb73fe599bac2479abd84598c6e70a1a | 2026-01-04T14:45:57.069771Z | false |
eugenp/tutorials | https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/jee-7/src/test/java/com/baeldung/soap/ws/client/CountryClientLiveTest.java | web-modules/jee-7/src/test/java/com/baeldung/soap/ws/client/CountryClientLiveTest.java | package com.baeldung.soap.ws.client;
import static org.junit.Assert.assertEquals;
import org.junit.BeforeClass;
import org.junit.Test;
import com.baeldung.soap.ws.client.generated.CountryService;
import com.baeldung.soap.ws.client.generated.CountryServiceImplService;
import com.baeldung.soap.ws.client.generated.Currency;
//Ensure that com.baeldung.soap.ws.server.CountryServicePublisher is running before executing this test
public class CountryClientLiveTest {
private static CountryService countryService;
@BeforeClass
public static void setup() {
CountryServiceImplService service = new CountryServiceImplService();
countryService = service.getCountryServiceImplPort();
}
@Test
public void givenCountryService_whenCountryIndia_thenCapitalIsNewDelhi() {
assertEquals("New Delhi", countryService.findByName("India").getCapital());
}
@Test
public void givenCountryService_whenCountryFrance_thenPopulationCorrect() {
assertEquals(66710000, countryService.findByName("France").getPopulation());
}
@Test
public void givenCountryService_whenCountryUSA_thenCurrencyUSD() {
assertEquals(Currency.USD, countryService.findByName("USA").getCurrency());
}
}
| java | MIT | 4463e58ffb73fe599bac2479abd84598c6e70a1a | 2026-01-04T14:45:57.069771Z | false |
eugenp/tutorials | https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/jee-7/src/test/java/com/baeldung/timer/ProgrammaticAtFixedRateTimerBeanLiveTest.java | web-modules/jee-7/src/test/java/com/baeldung/timer/ProgrammaticAtFixedRateTimerBeanLiveTest.java | package com.baeldung.timer;
import com.jayway.awaitility.Awaitility;
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.spec.WebArchive;
import org.jboss.shrinkwrap.resolver.api.maven.Maven;
import org.junit.Test;
import org.junit.runner.RunWith;
import javax.inject.Inject;
import java.io.File;
import java.util.concurrent.TimeUnit;
import static com.jayway.awaitility.Awaitility.await;
import static com.jayway.awaitility.Awaitility.to;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.is;
@RunWith(Arquillian.class)
public class ProgrammaticAtFixedRateTimerBeanLiveTest {
final static long TIMEOUT = 1000;
final static long TOLERANCE = 500l;
@Inject
TimerEventListener timerEventListener;
@Deployment
public static WebArchive deploy() {
File[] jars = Maven.resolver().loadPomFromFile("pom.xml")
.resolve("com.jayway.awaitility:awaitility")
.withTransitivity().asFile();
return ShrinkWrap.create(WebArchive.class)
.addAsLibraries(jars)
.addClasses(WithinWindowMatcher.class, TimerEvent.class, TimerEventListener.class, ProgrammaticAtFixedRateTimerBean.class);
}
@Test
public void should_receive_ten_pings() {
Awaitility.setDefaultTimeout(30, TimeUnit.SECONDS);
await().untilCall(to(timerEventListener.getEvents()).size(), equalTo(10));
TimerEvent firstEvent = timerEventListener.getEvents().get(0);
TimerEvent secondEvent = timerEventListener.getEvents().get(1);
long delay = secondEvent.getTime() - firstEvent.getTime();
System.out.println("Actual timeout = " + delay);
assertThat(delay, is(WithinWindowMatcher.withinWindow(TIMEOUT, TOLERANCE)));
}
} | java | MIT | 4463e58ffb73fe599bac2479abd84598c6e70a1a | 2026-01-04T14:45:57.069771Z | false |
eugenp/tutorials | https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/jee-7/src/test/java/com/baeldung/timer/ProgrammaticTimerBeanLiveTest.java | web-modules/jee-7/src/test/java/com/baeldung/timer/ProgrammaticTimerBeanLiveTest.java | package com.baeldung.timer;
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.spec.WebArchive;
import org.jboss.shrinkwrap.resolver.api.maven.Maven;
import org.junit.Test;
import org.junit.runner.RunWith;
import javax.inject.Inject;
import java.io.File;
import static com.jayway.awaitility.Awaitility.await;
import static com.jayway.awaitility.Awaitility.to;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.is;
@RunWith(Arquillian.class)
public class ProgrammaticTimerBeanLiveTest {
final static long TIMEOUT = 5000l;
final static long TOLERANCE = 1000l;
@Inject
TimerEventListener timerEventListener;
@Deployment
public static WebArchive deploy() {
File[] jars = Maven.resolver().loadPomFromFile("pom.xml")
.resolve("com.jayway.awaitility:awaitility")
.withTransitivity().asFile();
return ShrinkWrap.create(WebArchive.class)
.addAsLibraries(jars)
.addClasses(WithinWindowMatcher.class, TimerEvent.class, TimerEventListener.class, ProgrammaticTimerBean.class);
}
@Test
public void should_receive_two_pings() {
await().untilCall(to(timerEventListener.getEvents()).size(), equalTo(2));
TimerEvent firstEvent = timerEventListener.getEvents().get(0);
TimerEvent secondEvent = timerEventListener.getEvents().get(1);
long delay = secondEvent.getTime() - firstEvent.getTime();
System.out.println("Actual timeout = " + delay);
assertThat(delay, is(WithinWindowMatcher.withinWindow(TIMEOUT, TOLERANCE)));
}
} | java | MIT | 4463e58ffb73fe599bac2479abd84598c6e70a1a | 2026-01-04T14:45:57.069771Z | false |
eugenp/tutorials | https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/jee-7/src/test/java/com/baeldung/timer/WithinWindowMatcher.java | web-modules/jee-7/src/test/java/com/baeldung/timer/WithinWindowMatcher.java | package com.baeldung.timer;
import org.hamcrest.BaseMatcher;
import org.hamcrest.Description;
import org.hamcrest.Matcher;
class WithinWindowMatcher extends BaseMatcher<Long> {
private final long timeout;
private final long tolerance;
public WithinWindowMatcher(long timeout, long tolerance) {
this.timeout = timeout;
this.tolerance = tolerance;
}
@Override
public boolean matches(Object item) {
final Long actual = (Long) item;
return Math.abs(actual - timeout) < tolerance;
}
@Override
public void describeTo(Description description) {
//To change body of implemented methods use File | Settings | File Templates.
}
public static Matcher<Long> withinWindow(final long timeout, final long tolerance) {
return new WithinWindowMatcher(timeout, tolerance);
}
}
| java | MIT | 4463e58ffb73fe599bac2479abd84598c6e70a1a | 2026-01-04T14:45:57.069771Z | false |
eugenp/tutorials | https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/jee-7/src/test/java/com/baeldung/timer/AutomaticTimerBeanLiveTest.java | web-modules/jee-7/src/test/java/com/baeldung/timer/AutomaticTimerBeanLiveTest.java | package com.baeldung.timer;
import com.jayway.awaitility.Awaitility;
import org.hamcrest.Matchers;
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.spec.WebArchive;
import org.jboss.shrinkwrap.resolver.api.maven.Maven;
import org.junit.Test;
import org.junit.runner.RunWith;
import javax.inject.Inject;
import java.io.File;
import java.util.concurrent.TimeUnit;
import static com.jayway.awaitility.Awaitility.await;
import static com.jayway.awaitility.Awaitility.to;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo;
@RunWith(Arquillian.class)
public class AutomaticTimerBeanLiveTest {
//the @AutomaticTimerBean has a method called every 10 seconds
//testing the difference ==> 100000
final static long TIMEOUT = 10000l;
//the tolerance accepted , so if between two consecutive calls there has to be at least 9 or max 11 seconds.
//because the timer service is not intended for real-time applications so it will not be exactly 10 seconds
final static long TOLERANCE = 1000l;
@Inject
TimerEventListener timerEventListener;
@Deployment
public static WebArchive deploy() {
File[] jars = Maven.resolver().loadPomFromFile("pom.xml")
.resolve("com.jayway.awaitility:awaitility")
.withTransitivity().asFile();
//only @AutomaticTimerBean is deployed not the other timers
return ShrinkWrap.create(WebArchive.class)
.addAsLibraries(jars)
.addClasses(WithinWindowMatcher.class, TimerEvent.class, TimerEventListener.class, AutomaticTimerBean.class);
}
@Test
public void should_receive_two_pings() {
Awaitility.setDefaultTimeout(30, TimeUnit.SECONDS);
//the test will wait here until two events are triggered
await().untilCall(to(timerEventListener.getEvents()).size(), equalTo(2));
TimerEvent firstEvent = timerEventListener.getEvents().get(0);
TimerEvent secondEvent = timerEventListener.getEvents().get(1);
long delay = secondEvent.getTime() - firstEvent.getTime();
System.out.println("Actual timeout = " + delay);
//ensure that the delay between the events is more or less 10 seconds (no real time precision)
assertThat(delay, Matchers.is(WithinWindowMatcher.withinWindow(TIMEOUT, TOLERANCE)));
}
}
| java | MIT | 4463e58ffb73fe599bac2479abd84598c6e70a1a | 2026-01-04T14:45:57.069771Z | false |
eugenp/tutorials | https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/jee-7/src/test/java/com/baeldung/timer/ProgrammaticWithFixedDelayTimerBeanLiveTest.java | web-modules/jee-7/src/test/java/com/baeldung/timer/ProgrammaticWithFixedDelayTimerBeanLiveTest.java | package com.baeldung.timer;
import com.jayway.awaitility.Awaitility;
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.spec.WebArchive;
import org.jboss.shrinkwrap.resolver.api.maven.Maven;
import org.junit.Test;
import org.junit.runner.RunWith;
import javax.inject.Inject;
import java.io.File;
import java.util.concurrent.TimeUnit;
import static com.jayway.awaitility.Awaitility.await;
import static com.jayway.awaitility.Awaitility.to;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.is;
@RunWith(Arquillian.class)
public class ProgrammaticWithFixedDelayTimerBeanLiveTest {
final static long TIMEOUT = 15000l;
final static long TOLERANCE = 1000l;
@Inject
TimerEventListener timerEventListener;
@Deployment
public static WebArchive deploy() {
File[] jars = Maven.resolver().loadPomFromFile("pom.xml")
.resolve("com.jayway.awaitility:awaitility")
.withTransitivity().asFile();
return ShrinkWrap.create(WebArchive.class)
.addAsLibraries(jars)
.addClasses(WithinWindowMatcher.class, TimerEvent.class, TimerEventListener.class, ProgrammaticWithInitialFixedDelayTimerBean.class);
}
@Test
public void should_receive_two_pings() {
Awaitility.setDefaultTimeout(30, TimeUnit.SECONDS);
// 10 seconds pause so we get the startTime and it will trigger first event
long startTime = System.currentTimeMillis();
await().untilCall(to(timerEventListener.getEvents()).size(), equalTo(2));
TimerEvent firstEvent = timerEventListener.getEvents().get(0);
TimerEvent secondEvent = timerEventListener.getEvents().get(1);
long delay = secondEvent.getTime() - startTime;
System.out.println("Actual timeout = " + delay);
//apx 15 seconds = 10 delay + 2 timers (first after a pause of 10 seconds and the next others every 5 seconds)
assertThat(delay, is(WithinWindowMatcher.withinWindow(TIMEOUT, TOLERANCE)));
}
} | java | MIT | 4463e58ffb73fe599bac2479abd84598c6e70a1a | 2026-01-04T14:45:57.069771Z | false |
eugenp/tutorials | https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/jee-7/src/test/java/com/baeldung/timer/ScheduleTimerBeanLiveTest.java | web-modules/jee-7/src/test/java/com/baeldung/timer/ScheduleTimerBeanLiveTest.java | package com.baeldung.timer;
import com.jayway.awaitility.Awaitility;
import org.hamcrest.Matchers;
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.spec.WebArchive;
import org.jboss.shrinkwrap.resolver.api.maven.Maven;
import org.junit.Test;
import org.junit.runner.RunWith;
import javax.inject.Inject;
import java.io.File;
import java.util.concurrent.TimeUnit;
import static com.jayway.awaitility.Awaitility.await;
import static com.jayway.awaitility.Awaitility.to;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo;
@RunWith(Arquillian.class)
public class ScheduleTimerBeanLiveTest {
private final static long TIMEOUT = 5000l;
private final static long TOLERANCE = 1000l;
@Inject TimerEventListener timerEventListener;
@Deployment
public static WebArchive deploy() {
File[] jars = Maven
.resolver()
.loadPomFromFile("pom.xml")
.resolve("com.jayway.awaitility:awaitility")
.withTransitivity()
.asFile();
return ShrinkWrap
.create(WebArchive.class)
.addAsLibraries(jars)
.addClasses(WithinWindowMatcher.class, TimerEvent.class, TimerEventListener.class, ScheduleTimerBean.class);
}
@Test
public void should_receive_three_pings() {
Awaitility.setDefaultTimeout(30, TimeUnit.SECONDS);
await().untilCall(to(timerEventListener.getEvents()).size(), equalTo(3));
TimerEvent firstEvent = timerEventListener
.getEvents()
.get(0);
TimerEvent secondEvent = timerEventListener
.getEvents()
.get(1);
TimerEvent thirdEvent = timerEventListener
.getEvents()
.get(2);
long delay = secondEvent.getTime() - firstEvent.getTime();
assertThat(delay, Matchers.is(WithinWindowMatcher.withinWindow(TIMEOUT, TOLERANCE)));
delay = thirdEvent.getTime() - secondEvent.getTime();
assertThat(delay, Matchers.is(WithinWindowMatcher.withinWindow(TIMEOUT, TOLERANCE)));
}
}
| java | MIT | 4463e58ffb73fe599bac2479abd84598c6e70a1a | 2026-01-04T14:45:57.069771Z | false |
eugenp/tutorials | https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/jee-7/src/test/java/com/baeldung/arquillan/ArquillianLiveTest.java | web-modules/jee-7/src/test/java/com/baeldung/arquillan/ArquillianLiveTest.java | package com.baeldung.arquillan;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
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.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import com.baeldung.arquillian.CapsConvertor;
import com.baeldung.arquillian.CapsService;
import com.baeldung.arquillian.Car;
import com.baeldung.arquillian.CarEJB;
import com.baeldung.arquillian.Component;
import com.baeldung.arquillian.ConvertToLowerCase;
@RunWith(Arquillian.class)
public class ArquillianLiveTest {
@Deployment
public static JavaArchive createDeployment() {
return ShrinkWrap.create(JavaArchive.class).addClasses(Component.class, CapsService.class, CapsConvertor.class, ConvertToLowerCase.class, Car.class, CarEJB.class).addAsResource("META-INF/persistence.xml").addAsManifestResource(EmptyAsset.INSTANCE,
"beans.xml");
}
@Inject
Component component;
@Test
public void givenMessage_WhenComponentSendMessage_ThenMessageReceived() {
Assert.assertEquals("Message, MESSAGE", component.message(("MESSAGE")));
component.sendMessage(System.out, "MESSAGE");
}
@Inject
private CapsService capsService;
@Test
public void givenWord_WhenUppercase_ThenLowercase() {
assertTrue("capitalize".equals(capsService.getConvertedCaps("CAPITALIZE")));
assertEquals("capitalize", capsService.getConvertedCaps("CAPITALIZE"));
}
@Inject
private CarEJB carEJB;
@Test
public void testCars() {
assertTrue(carEJB.findAllCars().isEmpty());
Car c1 = new Car();
c1.setName("Impala");
Car c2 = new Car();
c2.setName("Maverick");
Car c3 = new Car();
c3.setName("Aspen");
Car c4 = new Car();
c4.setName("Lincoln");
carEJB.saveCar(c1);
carEJB.saveCar(c2);
carEJB.saveCar(c3);
carEJB.saveCar(c4);
assertEquals(4, carEJB.findAllCars().size());
carEJB.deleteCar(c4);
assertEquals(3, carEJB.findAllCars().size());
}
} | java | MIT | 4463e58ffb73fe599bac2479abd84598c6e70a1a | 2026-01-04T14:45:57.069771Z | false |
eugenp/tutorials | https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/jee-7/src/test/java/com/baeldung/jaxws/EmployeeServiceLiveTest.java | web-modules/jee-7/src/test/java/com/baeldung/jaxws/EmployeeServiceLiveTest.java | package com.baeldung.jaxws;
import static org.junit.Assert.assertEquals;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.List;
import javax.xml.namespace.QName;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.arquillian.test.api.ArquillianResource;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.asset.EmptyAsset;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import com.baeldung.jaxws.client.Employee;
import com.baeldung.jaxws.client.EmployeeAlreadyExists_Exception;
import com.baeldung.jaxws.client.EmployeeNotFound_Exception;
import com.baeldung.jaxws.client.EmployeeService;
import com.baeldung.jaxws.client.EmployeeService_Service;
@RunWith(Arquillian.class)
public class EmployeeServiceLiveTest {
private static final String APP_NAME = "jee7";
private static final String WSDL_PATH = "EmployeeService?wsdl";
private static QName SERVICE_NAME = new QName("http://bottomup.server.jaxws.baeldung.com/", "EmployeeService");
private static URL wsdlUrl;
@ArquillianResource
private URL deploymentUrl;
private EmployeeService employeeServiceProxy;
@Deployment(testable = false)
public static WebArchive createDeployment() {
return ShrinkWrap.create(WebArchive.class, APP_NAME + ".war")
.addPackage(com.baeldung.jaxws.server.bottomup.EmployeeService.class.getPackage())
.addPackage(com.baeldung.jaxws.server.bottomup.model.Employee.class.getPackage())
.addPackage(com.baeldung.jaxws.server.bottomup.exception.EmployeeNotFound.class.getPackage())
.addPackage(com.baeldung.jaxws.server.repository.EmployeeRepository.class.getPackage())
.addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml");
}
@Before
public void setUp() {
try {
wsdlUrl = new URL(deploymentUrl, WSDL_PATH);
} catch (MalformedURLException e) {
e.printStackTrace();
}
EmployeeService_Service employeeService_Service = new EmployeeService_Service(wsdlUrl);
employeeServiceProxy = employeeService_Service.getEmployeeServiceImplPort();
}
@Test
public void givenEmployees_whenGetCount_thenCorrectNumberOfEmployeesReturned() {
int employeeCount = employeeServiceProxy.countEmployees();
List<Employee> employeeList = employeeServiceProxy.getAllEmployees();
assertEquals(employeeList.size(), employeeCount);
}
@Test
public void givenEmployees_whenGetAvailableEmployee_thenCorrectEmployeeReturned() throws EmployeeNotFound_Exception {
Employee employee = employeeServiceProxy.getEmployee(2);
assertEquals(employee.getFirstName(), "Jack");
}
@Test(expected = EmployeeNotFound_Exception.class)
public void givenEmployees_whenGetNonAvailableEmployee_thenEmployeeNotFoundException() throws EmployeeNotFound_Exception {
employeeServiceProxy.getEmployee(20);
}
@Test
public void givenEmployees_whenAddNewEmployee_thenEmployeeCountIncreased() throws EmployeeAlreadyExists_Exception {
int employeeCount = employeeServiceProxy.countEmployees();
employeeServiceProxy.addEmployee(4, "Anna");
assertEquals(employeeServiceProxy.countEmployees(), employeeCount + 1);
}
@Test(expected = EmployeeAlreadyExists_Exception.class)
public void givenEmployees_whenAddAlreadyExistingEmployee_thenEmployeeAlreadyExistsException() throws EmployeeAlreadyExists_Exception {
employeeServiceProxy.addEmployee(1, "Anna");
}
@Test
public void givenEmployees_whenUpdateExistingEmployee_thenUpdatedEmployeeReturned() throws EmployeeNotFound_Exception {
Employee updated = employeeServiceProxy.updateEmployee(1, "Joan");
assertEquals(updated.getFirstName(), "Joan");
}
@Test(expected = EmployeeNotFound_Exception.class)
public void givenEmployees_whenUpdateNonExistingEmployee_thenEmployeeNotFoundException() throws EmployeeNotFound_Exception {
employeeServiceProxy.updateEmployee(20, "Joan");
}
@Test
public void givenEmployees_whenDeleteExistingEmployee_thenSuccessReturned() throws EmployeeNotFound_Exception {
boolean deleteEmployee = employeeServiceProxy.deleteEmployee(3);
assertEquals(deleteEmployee, true);
}
@Test(expected = EmployeeNotFound_Exception.class)
public void givenEmployee_whenDeleteNonExistingEmployee_thenEmployeeNotFoundException() throws EmployeeNotFound_Exception {
employeeServiceProxy.deleteEmployee(20);
}
}
| java | MIT | 4463e58ffb73fe599bac2479abd84598c6e70a1a | 2026-01-04T14:45:57.069771Z | false |
eugenp/tutorials | https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/jee-7/src/test/java/com/baeldug/json/JsonUnitTest.java | web-modules/jee-7/src/test/java/com/baeldug/json/JsonUnitTest.java | package com.baeldug.json;
import static org.hamcrest.CoreMatchers.hasItems;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
import java.io.IOException;
import java.io.StringReader;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import javax.json.Json;
import javax.json.JsonObject;
import javax.json.JsonReader;
import javax.json.stream.JsonParser;
import javax.json.stream.JsonParser.Event;
import org.junit.Before;
import org.junit.Test;
import com.baeldung.json.Person;
import com.baeldung.json.PersonBuilder;
import com.baeldung.json.PersonWriter;
public class JsonUnitTest {
private Person person;
private SimpleDateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy");
private String personJson;
private String petshopJson;
@Test
public void whenPersonIsConvertedToString_thenAValidJsonStringIsReturned() throws IOException {
String generatedJsonString = new PersonWriter(person).write();
assertEquals(
"Generated String has the expected format and content",
personJson,
generatedJsonString);
}
@Test
public void whenJsonStringIsConvertedToPerson_thenAValidObjectIsReturned(
) throws IOException, ParseException {
Person person = new PersonBuilder(personJson).build();
assertEquals("First name has expected value", "Michael", person.getFirstName());
assertEquals("Last name has expected value", "Scott", person.getLastName());
assertEquals(
"Birthdate has expected value",
dateFormat.parse("06/15/1978"),
person.getBirthdate());
assertThat(
"Email list has two items",
person.getEmails(),
hasItems("michael.scott@dd.com", "michael.scarn@gmail.com"));
}
@Test
public void whenUsingObjectModelToQueryForSpecificProperty_thenExpectedValueIsReturned(
) throws IOException, ParseException {
JsonReader reader = Json.createReader(new StringReader(petshopJson));
JsonObject jsonObject = reader.readObject();
assertEquals(
"The query should return the 'name' property of the third pet from the list",
"Jake",
jsonObject.getJsonArray("pets").getJsonObject(2).getString("name"));
}
@Test
public void whenUsingStreamingApiToQueryForSpecificProperty_thenExpectedValueIsReturned(
) throws IOException, ParseException {
JsonParser jsonParser = Json.createParser(new StringReader(petshopJson));
int count = 0;
String result = null;
while(jsonParser.hasNext()) {
Event e = jsonParser.next();
if (e == Event.KEY_NAME) {
if(jsonParser.getString().equals("name")) {
jsonParser.next();
if(++count == 3) {
result = jsonParser.getString();
break;
}
}
}
}
assertEquals(
"The query should return the 'name' property of the third pet from the list",
"Jake",
result);
}
@Before
public void init() throws ParseException {
// Creates a Person object
person = new Person();
person.setFirstName("Michael");
person.setLastName("Scott");
person.setBirthdate(dateFormat.parse("06/15/1978"));
person.setEmails(Arrays.asList("michael.scott@dd.com", "michael.scarn@gmail.com"));
// Initializes the Person Json
personJson = "\n" +
"{\n" +
" \"firstName\":\"Michael\",\n" +
" \"lastName\":\"Scott\",\n" +
" \"birthdate\":\"06/15/1978\",\n" +
" \"emails\":[\n" +
" \"michael.scott@dd.com\",\n" +
" \"michael.scarn@gmail.com\"\n" +
" ]\n" +
"}";
// Initializes the Pet Shop Json
petshopJson = "\n" +
"{\n" +
" \"ownerId\":\"1\", \n" +
" \"pets\":[ \n" +
" {\"name\": \"Kitty\", \"type\": \"cat\"}, \n" +
" {\"name\": \"Rex\", \"type\": \"dog\"}, \n" +
" {\"name\": \"Jake\", \"type\": \"dog\"} \n" +
" ]\n" +
"}";
}
}
| java | MIT | 4463e58ffb73fe599bac2479abd84598c6e70a1a | 2026-01-04T14:45:57.069771Z | false |
eugenp/tutorials | https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/jee-7/src/main/java/com/baeldung/batch/understanding/SimpleBatchLet.java | web-modules/jee-7/src/main/java/com/baeldung/batch/understanding/SimpleBatchLet.java | package com.baeldung.batch.understanding;
import javax.batch.api.AbstractBatchlet;
import javax.batch.runtime.BatchStatus;
import javax.inject.Named;
@Named
public class SimpleBatchLet extends AbstractBatchlet {
@Override
public String process() throws Exception {
return BatchStatus.FAILED.toString();
}
}
| java | MIT | 4463e58ffb73fe599bac2479abd84598c6e70a1a | 2026-01-04T14:45:57.069771Z | false |
eugenp/tutorials | https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/jee-7/src/main/java/com/baeldung/batch/understanding/InjectSimpleBatchLet.java | web-modules/jee-7/src/main/java/com/baeldung/batch/understanding/InjectSimpleBatchLet.java | package com.baeldung.batch.understanding;
import java.util.Properties;
import java.util.logging.Logger;
import javax.batch.api.AbstractBatchlet;
import javax.batch.api.BatchProperty;
import javax.batch.runtime.BatchStatus;
import javax.batch.runtime.context.JobContext;
import javax.batch.runtime.context.StepContext;
import javax.inject.Inject;
import javax.inject.Named;
@Named
public class InjectSimpleBatchLet extends AbstractBatchlet {
Logger logger = Logger.getLogger(InjectSimpleBatchLet.class.getName());
@Inject
@BatchProperty(name = "name")
private String nameString;
@Inject
StepContext stepContext;
private Properties stepProperties;
@Inject
JobContext jobContext;
private Properties jobProperties;
@Override
public String process() throws Exception {
logger.info("BatchProperty : " + nameString);
stepProperties = stepContext.getProperties();
jobProperties = jobContext.getProperties();
logger.info("Step property : "+ stepProperties.getProperty("stepProp1"));
logger.info("job property : "+jobProperties.getProperty("jobProp1"));
return BatchStatus.COMPLETED.toString();
}
}
| java | MIT | 4463e58ffb73fe599bac2479abd84598c6e70a1a | 2026-01-04T14:45:57.069771Z | false |
eugenp/tutorials | https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/jee-7/src/main/java/com/baeldung/batch/understanding/SimpleChunkItemReader.java | web-modules/jee-7/src/main/java/com/baeldung/batch/understanding/SimpleChunkItemReader.java | package com.baeldung.batch.understanding;
import java.io.Serializable;
import java.util.Properties;
import java.util.StringTokenizer;
import javax.batch.api.chunk.AbstractItemReader;
import javax.batch.runtime.BatchStatus;
import javax.batch.runtime.context.JobContext;
import javax.inject.Inject;
import javax.inject.Named;
@Named
public class SimpleChunkItemReader extends AbstractItemReader {
private StringTokenizer tokens;
private Integer count=0;
@Inject
JobContext jobContext;
@Override
public Integer readItem() throws Exception {
if (tokens.hasMoreTokens()) {
this.count++;
String tempTokenize = tokens.nextToken();
jobContext.setTransientUserData(count);
return Integer.valueOf(tempTokenize);
}
return null;
}
@Override
public void open(Serializable checkpoint) throws Exception {
tokens = new StringTokenizer("1,2,3,4,5,6,7,8,9,10", ",");
}
}
| java | MIT | 4463e58ffb73fe599bac2479abd84598c6e70a1a | 2026-01-04T14:45:57.069771Z | false |
eugenp/tutorials | https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/jee-7/src/main/java/com/baeldung/batch/understanding/DeciderJobSequence.java | web-modules/jee-7/src/main/java/com/baeldung/batch/understanding/DeciderJobSequence.java | package com.baeldung.batch.understanding;
import javax.batch.api.Decider;
import javax.batch.runtime.StepExecution;
import javax.inject.Named;
@Named
public class DeciderJobSequence implements Decider {
@Override
public String decide(StepExecution[] ses) throws Exception {
return "nothing";
}
} | java | MIT | 4463e58ffb73fe599bac2479abd84598c6e70a1a | 2026-01-04T14:45:57.069771Z | false |
eugenp/tutorials | https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/jee-7/src/main/java/com/baeldung/batch/understanding/ChunkExceptionSkipReadListener.java | web-modules/jee-7/src/main/java/com/baeldung/batch/understanding/ChunkExceptionSkipReadListener.java | package com.baeldung.batch.understanding;
import javax.batch.api.chunk.listener.SkipReadListener;
import javax.inject.Named;
@Named
public class ChunkExceptionSkipReadListener implements SkipReadListener {
@Override
public void onSkipReadItem(Exception e) throws Exception {
}
} | java | MIT | 4463e58ffb73fe599bac2479abd84598c6e70a1a | 2026-01-04T14:45:57.069771Z | false |
eugenp/tutorials | https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/jee-7/src/main/java/com/baeldung/batch/understanding/SimpleChunkItemProcessor.java | web-modules/jee-7/src/main/java/com/baeldung/batch/understanding/SimpleChunkItemProcessor.java | package com.baeldung.batch.understanding;
import javax.batch.api.chunk.ItemProcessor;
import javax.inject.Named;
@Named
public class SimpleChunkItemProcessor implements ItemProcessor {
@Override
public Integer processItem(Object t) {
return ((Integer) t).intValue() % 2 == 0 ? null : ((Integer) t).intValue();
}
}
| java | MIT | 4463e58ffb73fe599bac2479abd84598c6e70a1a | 2026-01-04T14:45:57.069771Z | false |
eugenp/tutorials | https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/jee-7/src/main/java/com/baeldung/batch/understanding/SimpleChunkWriter.java | web-modules/jee-7/src/main/java/com/baeldung/batch/understanding/SimpleChunkWriter.java | package com.baeldung.batch.understanding;
import java.util.ArrayList;
import java.util.List;
import javax.batch.api.chunk.AbstractItemWriter;
import javax.inject.Named;
@Named
public class SimpleChunkWriter extends AbstractItemWriter {
List<Integer> processed = new ArrayList<>();
@Override
public void writeItems(List<Object> items) throws Exception {
items.stream().map(Integer.class::cast).forEach(this.processed::add);
}
}
| java | MIT | 4463e58ffb73fe599bac2479abd84598c6e70a1a | 2026-01-04T14:45:57.069771Z | false |
eugenp/tutorials | https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/jee-7/src/main/java/com/baeldung/batch/understanding/CustomCheckPoint.java | web-modules/jee-7/src/main/java/com/baeldung/batch/understanding/CustomCheckPoint.java | package com.baeldung.batch.understanding;
import javax.batch.api.chunk.AbstractCheckpointAlgorithm;
import javax.batch.runtime.context.JobContext;
import javax.inject.Inject;
import javax.inject.Named;
@Named
public class CustomCheckPoint extends AbstractCheckpointAlgorithm {
@Inject
JobContext jobContext;
private Integer counterRead = 0;
@Override
public boolean isReadyToCheckpoint() throws Exception {
counterRead = (Integer)jobContext.getTransientUserData();
System.out.println("counterRead : " + counterRead);
return counterRead % 5 == 0;
}
}
| java | MIT | 4463e58ffb73fe599bac2479abd84598c6e70a1a | 2026-01-04T14:45:57.069771Z | false |
eugenp/tutorials | https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/jee-7/src/main/java/com/baeldung/batch/understanding/SimpleChunkItemReaderError.java | web-modules/jee-7/src/main/java/com/baeldung/batch/understanding/SimpleChunkItemReaderError.java | package com.baeldung.batch.understanding;
import java.io.Serializable;
import java.util.StringTokenizer;
import javax.batch.api.chunk.AbstractItemReader;
import javax.batch.runtime.context.JobContext;
import javax.inject.Inject;
import javax.inject.Named;
@Named
public class SimpleChunkItemReaderError extends AbstractItemReader {
@Inject
JobContext jobContext;
private StringTokenizer tokens;
private Integer count = 0;
@Override
public Integer readItem() throws Exception {
if (tokens.hasMoreTokens()) {
count++;
jobContext.setTransientUserData(count);
int token = Integer.valueOf(tokens.nextToken());
if (token == 3) {
throw new RuntimeException("Something happened");
}
return Integer.valueOf(token);
}
return null;
}
@Override
public void open(Serializable checkpoint) throws Exception {
tokens = new StringTokenizer("1,2,3,4,5,6,7,8,9,10", ",");
}
} | java | MIT | 4463e58ffb73fe599bac2479abd84598c6e70a1a | 2026-01-04T14:45:57.069771Z | false |
eugenp/tutorials | https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/jee-7/src/main/java/com/baeldung/batch/understanding/exception/MyItemWriter.java | web-modules/jee-7/src/main/java/com/baeldung/batch/understanding/exception/MyItemWriter.java |
package com.baeldung.batch.understanding.exception;
import javax.batch.api.chunk.AbstractItemWriter;
import javax.inject.Named;
import java.util.List;
@Named
public class MyItemWriter extends AbstractItemWriter {
private static int retries = 0;
@Override
public void writeItems(List list) {
if (retries <= 3 && list.contains(new MyOutputRecord(8))) {
retries++;
throw new UnsupportedOperationException();
}
}
}
| java | MIT | 4463e58ffb73fe599bac2479abd84598c6e70a1a | 2026-01-04T14:45:57.069771Z | false |
eugenp/tutorials | https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/jee-7/src/main/java/com/baeldung/batch/understanding/exception/MyInputRecord.java | web-modules/jee-7/src/main/java/com/baeldung/batch/understanding/exception/MyInputRecord.java | package com.baeldung.batch.understanding.exception;
import java.io.Serializable;
public class MyInputRecord implements Serializable {
private int id;
public MyInputRecord(int id) {
this.id = id;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
@Override
public boolean equals(Object o) {
if (this == o)
return true;
if (o == null || getClass() != o.getClass())
return false;
MyInputRecord that = (MyInputRecord) o;
return id == that.id;
}
@Override
public int hashCode() {
return id;
}
@Override
public String toString() {
return "MyInputRecord: " + id;
}
}
| java | MIT | 4463e58ffb73fe599bac2479abd84598c6e70a1a | 2026-01-04T14:45:57.069771Z | false |
eugenp/tutorials | https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/jee-7/src/main/java/com/baeldung/batch/understanding/exception/MySkipWriteListener.java | web-modules/jee-7/src/main/java/com/baeldung/batch/understanding/exception/MySkipWriteListener.java | package com.baeldung.batch.understanding.exception;
import javax.batch.api.chunk.listener.SkipWriteListener;
import javax.inject.Named;
import java.util.List;
@Named
public class MySkipWriteListener implements SkipWriteListener {
@Override
public void onSkipWriteItem(List list, Exception e) throws Exception {
list.remove(new MyOutputRecord(2));
}
}
| java | MIT | 4463e58ffb73fe599bac2479abd84598c6e70a1a | 2026-01-04T14:45:57.069771Z | false |
eugenp/tutorials | https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/jee-7/src/main/java/com/baeldung/batch/understanding/exception/MyItemReader.java | web-modules/jee-7/src/main/java/com/baeldung/batch/understanding/exception/MyItemReader.java | package com.baeldung.batch.understanding.exception;
import javax.batch.api.chunk.AbstractItemReader;
import javax.inject.Named;
import java.io.Serializable;
import java.util.StringTokenizer;
@Named
public class MyItemReader extends AbstractItemReader {
private StringTokenizer tokens;
private MyInputRecord lastElement;
private boolean alreadyFailed;
@Override
public void open(Serializable checkpoint) {
tokens = new StringTokenizer("1,2,3,4,5,6,7,8,9,10", ",");
if (checkpoint != null) {
while (!Integer.valueOf(tokens.nextToken())
.equals(((MyInputRecord) checkpoint).getId())) {
}
}
}
@Override
public Object readItem() {
if (tokens.hasMoreTokens()) {
int token = Integer.valueOf(tokens.nextToken());
if (token == 5 && !alreadyFailed) {
alreadyFailed = true;
throw new IllegalArgumentException("Could not read record");
}
lastElement = new MyInputRecord(token);
return lastElement;
}
return null;
}
@Override
public Serializable checkpointInfo() throws Exception {
return lastElement;
}
}
| java | MIT | 4463e58ffb73fe599bac2479abd84598c6e70a1a | 2026-01-04T14:45:57.069771Z | false |
eugenp/tutorials | https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/jee-7/src/main/java/com/baeldung/batch/understanding/exception/MyRetryReadListener.java | web-modules/jee-7/src/main/java/com/baeldung/batch/understanding/exception/MyRetryReadListener.java | package com.baeldung.batch.understanding.exception;
import javax.batch.api.chunk.listener.RetryReadListener;
import javax.inject.Named;
@Named
public class MyRetryReadListener implements RetryReadListener {
@Override
public void onRetryReadException(Exception ex) throws Exception {
}
}
| java | MIT | 4463e58ffb73fe599bac2479abd84598c6e70a1a | 2026-01-04T14:45:57.069771Z | false |
eugenp/tutorials | https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/jee-7/src/main/java/com/baeldung/batch/understanding/exception/MySkipReadListener.java | web-modules/jee-7/src/main/java/com/baeldung/batch/understanding/exception/MySkipReadListener.java | package com.baeldung.batch.understanding.exception;
import javax.batch.api.chunk.listener.SkipReadListener;
import javax.inject.Named;
@Named
public class MySkipReadListener implements SkipReadListener {
@Override
public void onSkipReadItem(Exception e) throws Exception {
}
}
| java | MIT | 4463e58ffb73fe599bac2479abd84598c6e70a1a | 2026-01-04T14:45:57.069771Z | false |
eugenp/tutorials | https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/jee-7/src/main/java/com/baeldung/batch/understanding/exception/MyRetryProcessorListener.java | web-modules/jee-7/src/main/java/com/baeldung/batch/understanding/exception/MyRetryProcessorListener.java | package com.baeldung.batch.understanding.exception;
import javax.batch.api.chunk.listener.RetryProcessListener;
import javax.inject.Named;
@Named
public class MyRetryProcessorListener implements RetryProcessListener {
@Override
public void onRetryProcessException(Object item, Exception ex) throws Exception {
}
}
| java | MIT | 4463e58ffb73fe599bac2479abd84598c6e70a1a | 2026-01-04T14:45:57.069771Z | false |
eugenp/tutorials | https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/jee-7/src/main/java/com/baeldung/batch/understanding/exception/MyOutputRecord.java | web-modules/jee-7/src/main/java/com/baeldung/batch/understanding/exception/MyOutputRecord.java | package com.baeldung.batch.understanding.exception;
import java.io.Serializable;
public class MyOutputRecord implements Serializable {
private int id;
public MyOutputRecord(int id) {
this.id = id;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
MyOutputRecord that = (MyOutputRecord) o;
return id == that.id;
}
@Override
public int hashCode() {
return id;
}
@Override
public String toString() {
return "MyOutputRecord: " + id;
}
}
| java | MIT | 4463e58ffb73fe599bac2479abd84598c6e70a1a | 2026-01-04T14:45:57.069771Z | false |
eugenp/tutorials | https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/jee-7/src/main/java/com/baeldung/batch/understanding/exception/MySkipProcessorListener.java | web-modules/jee-7/src/main/java/com/baeldung/batch/understanding/exception/MySkipProcessorListener.java | package com.baeldung.batch.understanding.exception;
import javax.batch.api.chunk.listener.SkipProcessListener;
import javax.inject.Named;
@Named
public class MySkipProcessorListener implements SkipProcessListener {
@Override
public void onSkipProcessItem(Object t, Exception e) throws Exception {
}
}
| java | MIT | 4463e58ffb73fe599bac2479abd84598c6e70a1a | 2026-01-04T14:45:57.069771Z | false |
eugenp/tutorials | https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/jee-7/src/main/java/com/baeldung/batch/understanding/exception/MyItemProcessor.java | web-modules/jee-7/src/main/java/com/baeldung/batch/understanding/exception/MyItemProcessor.java | package com.baeldung.batch.understanding.exception;
import javax.batch.api.chunk.ItemProcessor;
import javax.inject.Named;
@Named
public class MyItemProcessor implements ItemProcessor {
@Override
public Object processItem(Object t) {
if (((MyInputRecord) t).getId() == 6) {
throw new NullPointerException();
}
return new MyOutputRecord(((MyInputRecord) t).getId());
}
}
| java | MIT | 4463e58ffb73fe599bac2479abd84598c6e70a1a | 2026-01-04T14:45:57.069771Z | false |
eugenp/tutorials | https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/jee-7/src/main/java/com/baeldung/batch/understanding/exception/MyRetryWriteListener.java | web-modules/jee-7/src/main/java/com/baeldung/batch/understanding/exception/MyRetryWriteListener.java | package com.baeldung.batch.understanding.exception;
import javax.batch.api.chunk.listener.RetryWriteListener;
import javax.inject.Named;
import java.util.List;
@Named
public class MyRetryWriteListener implements RetryWriteListener {
@Override
public void onRetryWriteException(List<Object> items, Exception ex) throws Exception {
}
}
| java | MIT | 4463e58ffb73fe599bac2479abd84598c6e70a1a | 2026-01-04T14:45:57.069771Z | false |
eugenp/tutorials | https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/jee-7/src/main/java/com/baeldung/convListVal/MyListener.java | web-modules/jee-7/src/main/java/com/baeldung/convListVal/MyListener.java | package com.baeldung.convListVal;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.faces.event.AbortProcessingException;
import javax.faces.event.ValueChangeEvent;
import javax.faces.event.ValueChangeListener;
public class MyListener implements ValueChangeListener {
private static final Logger LOG = Logger.getLogger(MyListener.class.getName());
@Override
public void processValueChange(ValueChangeEvent event) throws AbortProcessingException {
if (event.getNewValue() != null) {
LOG.log(Level.INFO, "\tNew Value:{0}", event.getNewValue());
}
}
}
| java | MIT | 4463e58ffb73fe599bac2479abd84598c6e70a1a | 2026-01-04T14:45:57.069771Z | false |
eugenp/tutorials | https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/jee-7/src/main/java/com/baeldung/convListVal/ConvListVal.java | web-modules/jee-7/src/main/java/com/baeldung/convListVal/ConvListVal.java | package com.baeldung.convListVal;
import java.util.Date;
import javax.faces.bean.ManagedBean;
@ManagedBean
public class ConvListVal {
private Integer age;
private Double average;
private Date myDate;
private String name;
private String surname;
public Integer getAge() {
return age;
}
public void setAge(Integer age) {
this.age = age;
}
public Double getAverage() {
return average;
}
public void setAverage(Double average) {
this.average = average;
}
public Date getMyDate() {
return myDate;
}
public void setMyDate(Date myDate) {
this.myDate = myDate;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getSurname() {
return surname;
}
public void setSurname(String surname) {
this.surname = surname;
}
}
| java | MIT | 4463e58ffb73fe599bac2479abd84598c6e70a1a | 2026-01-04T14:45:57.069771Z | false |
eugenp/tutorials | https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/jee-7/src/main/java/com/baeldung/singleton/CarServiceEjbSingleton.java | web-modules/jee-7/src/main/java/com/baeldung/singleton/CarServiceEjbSingleton.java | 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);
}
}
}
| java | MIT | 4463e58ffb73fe599bac2479abd84598c6e70a1a | 2026-01-04T14:45:57.069771Z | false |
eugenp/tutorials | https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/jee-7/src/main/java/com/baeldung/singleton/CarServiceSingleton.java | web-modules/jee-7/src/main/java/com/baeldung/singleton/CarServiceSingleton.java | 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);
}
}
}
| java | MIT | 4463e58ffb73fe599bac2479abd84598c6e70a1a | 2026-01-04T14:45:57.069771Z | false |
eugenp/tutorials | https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/jee-7/src/main/java/com/baeldung/singleton/Car.java | web-modules/jee-7/src/main/java/com/baeldung/singleton/Car.java | 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 + "]";
}
}
| java | MIT | 4463e58ffb73fe599bac2479abd84598c6e70a1a | 2026-01-04T14:45:57.069771Z | false |
eugenp/tutorials | https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/jee-7/src/main/java/com/baeldung/singleton/CarServiceBean.java | web-modules/jee-7/src/main/java/com/baeldung/singleton/CarServiceBean.java | 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 + "]";
}
}
| java | MIT | 4463e58ffb73fe599bac2479abd84598c6e70a1a | 2026-01-04T14:45:57.069771Z | false |
eugenp/tutorials | https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/jee-7/src/main/java/com/baeldung/soap/ws/server/Country.java | web-modules/jee-7/src/main/java/com/baeldung/soap/ws/server/Country.java | package com.baeldung.soap.ws.server;
public class Country {
protected String name;
protected int population;
protected String capital;
protected Currency currency;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getPopulation() {
return population;
}
public void setPopulation(int population) {
this.population = population;
}
public String getCapital() {
return capital;
}
public void setCapital(String capital) {
this.capital = capital;
}
public Currency getCurrency() {
return currency;
}
public void setCurrency(Currency currency) {
this.currency = currency;
}
} | java | MIT | 4463e58ffb73fe599bac2479abd84598c6e70a1a | 2026-01-04T14:45:57.069771Z | false |
eugenp/tutorials | https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/jee-7/src/main/java/com/baeldung/soap/ws/server/CountryServiceImpl.java | web-modules/jee-7/src/main/java/com/baeldung/soap/ws/server/CountryServiceImpl.java | package com.baeldung.soap.ws.server;
import javax.jws.WebService;
@WebService(endpointInterface = "com.baeldung.soap.ws.server.CountryService")
public class CountryServiceImpl implements CountryService {
private CountryRepository countryRepository = new CountryRepository();
@Override
public Country findByName(String name) {
return countryRepository.findCountry(name);
}
}
| java | MIT | 4463e58ffb73fe599bac2479abd84598c6e70a1a | 2026-01-04T14:45:57.069771Z | false |
eugenp/tutorials | https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/jee-7/src/main/java/com/baeldung/soap/ws/server/CountryService.java | web-modules/jee-7/src/main/java/com/baeldung/soap/ws/server/CountryService.java | package com.baeldung.soap.ws.server;
import javax.jws.WebMethod;
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
import javax.jws.soap.SOAPBinding.Style;
@WebService
@SOAPBinding(style=Style.RPC)
public interface CountryService {
@WebMethod
Country findByName(String name);
}
| java | MIT | 4463e58ffb73fe599bac2479abd84598c6e70a1a | 2026-01-04T14:45:57.069771Z | false |
eugenp/tutorials | https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/jee-7/src/main/java/com/baeldung/soap/ws/server/CountryServicePublisher.java | web-modules/jee-7/src/main/java/com/baeldung/soap/ws/server/CountryServicePublisher.java | package com.baeldung.soap.ws.server;
import javax.xml.ws.Endpoint;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class CountryServicePublisher {
private static final Logger logger = LoggerFactory.getLogger(CountryServicePublisher.class);
public static void main(String[] args) {
Endpoint endpoint = Endpoint.create(new CountryServiceImpl());
endpoint.publish("http://localhost:8888/ws/country");
logger.info("Country web service ready to consume requests!");
}
} | java | MIT | 4463e58ffb73fe599bac2479abd84598c6e70a1a | 2026-01-04T14:45:57.069771Z | false |
eugenp/tutorials | https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/jee-7/src/main/java/com/baeldung/soap/ws/server/CountryRepository.java | web-modules/jee-7/src/main/java/com/baeldung/soap/ws/server/CountryRepository.java | package com.baeldung.soap.ws.server;
import java.util.HashMap;
import java.util.Map;
public class CountryRepository {
private static final Map<String, Country> countries = new HashMap<>();
{
initData();
}
private final static void initData() {
Country usa = new Country();
usa.setName("USA");
usa.setCapital("Washington D.C.");
usa.setCurrency(Currency.USD);
usa.setPopulation(323947000);
countries.put(usa.getName(), usa);
Country india = new Country();
india.setName("India");
india.setCapital("New Delhi");
india.setCurrency(Currency.INR);
india.setPopulation(1295210000);
countries.put(india.getName(), india);
Country france = new Country();
france.setName("France");
france.setCapital("Paris");
france.setCurrency(Currency.EUR);
france.setPopulation(66710000);
countries.put(france.getName(), france);
}
public Country findCountry(String name) {
return countries.get(name);
}
}
| java | MIT | 4463e58ffb73fe599bac2479abd84598c6e70a1a | 2026-01-04T14:45:57.069771Z | false |
eugenp/tutorials | https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/jee-7/src/main/java/com/baeldung/soap/ws/server/Currency.java | web-modules/jee-7/src/main/java/com/baeldung/soap/ws/server/Currency.java | package com.baeldung.soap.ws.server;
public enum Currency {
EUR, INR, USD;
public String value() {
return name();
}
public static Currency fromValue(String v) {
return valueOf(v);
}
}
| java | MIT | 4463e58ffb73fe599bac2479abd84598c6e70a1a | 2026-01-04T14:45:57.069771Z | false |
eugenp/tutorials | https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/jee-7/src/main/java/com/baeldung/soap/ws/client/generated/Country.java | web-modules/jee-7/src/main/java/com/baeldung/soap/ws/client/generated/Country.java |
package com.baeldung.soap.ws.client.generated;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlSchemaType;
import javax.xml.bind.annotation.XmlType;
/**
* <p>Java class for country complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* <complexType name="country">
* <complexContent>
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* <sequence>
* <element name="capital" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
* <element name="currency" type="{http://server.ws.soap.baeldung.com/}currency" minOccurs="0"/>
* <element name="name" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
* <element name="population" type="{http://www.w3.org/2001/XMLSchema}int"/>
* </sequence>
* </restriction>
* </complexContent>
* </complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "country", propOrder = { "capital", "currency", "name", "population" })
public class Country {
protected String capital;
@XmlSchemaType(name = "string")
protected Currency currency;
protected String name;
protected int population;
/**
* Gets the value of the capital property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getCapital() {
return capital;
}
/**
* Sets the value of the capital property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setCapital(String value) {
this.capital = value;
}
/**
* Gets the value of the currency property.
*
* @return
* possible object is
* {@link Currency }
*
*/
public Currency getCurrency() {
return currency;
}
/**
* Sets the value of the currency property.
*
* @param value
* allowed object is
* {@link Currency }
*
*/
public void setCurrency(Currency value) {
this.currency = value;
}
/**
* Gets the value of the name property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getName() {
return name;
}
/**
* Sets the value of the name property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setName(String value) {
this.name = value;
}
/**
* Gets the value of the population property.
*
*/
public int getPopulation() {
return population;
}
/**
* Sets the value of the population property.
*
*/
public void setPopulation(int value) {
this.population = value;
}
}
| java | MIT | 4463e58ffb73fe599bac2479abd84598c6e70a1a | 2026-01-04T14:45:57.069771Z | false |
eugenp/tutorials | https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/jee-7/src/main/java/com/baeldung/soap/ws/client/generated/package-info.java | web-modules/jee-7/src/main/java/com/baeldung/soap/ws/client/generated/package-info.java | @javax.xml.bind.annotation.XmlSchema(namespace = "http://server.ws.soap.baeldung.com/", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED)
package com.baeldung.soap.ws.client.generated;
| java | MIT | 4463e58ffb73fe599bac2479abd84598c6e70a1a | 2026-01-04T14:45:57.069771Z | false |
eugenp/tutorials | https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/jee-7/src/main/java/com/baeldung/soap/ws/client/generated/CountryService.java | web-modules/jee-7/src/main/java/com/baeldung/soap/ws/client/generated/CountryService.java |
package com.baeldung.soap.ws.client.generated;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebResult;
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
import javax.xml.bind.annotation.XmlSeeAlso;
import javax.xml.ws.Action;
/**
* This class was generated by the JAX-WS RI.
* JAX-WS RI 2.3.2
* Generated source version: 2.2
*
*/
@WebService(name = "CountryService", targetNamespace = "http://server.ws.soap.baeldung.com/")
@SOAPBinding(style = SOAPBinding.Style.RPC)
@XmlSeeAlso({ ObjectFactory.class })
public interface CountryService {
/**
*
* @param arg0
* @return
* returns com.baeldung.soap.ws.client.generated.Country
*/
@WebMethod
@WebResult(partName = "return")
@Action(input = "http://server.ws.soap.baeldung.com/CountryService/findByNameRequest", output = "http://server.ws.soap.baeldung.com/CountryService/findByNameResponse")
public Country findByName(@WebParam(name = "arg0", partName = "arg0") String arg0);
}
| java | MIT | 4463e58ffb73fe599bac2479abd84598c6e70a1a | 2026-01-04T14:45:57.069771Z | false |
eugenp/tutorials | https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/jee-7/src/main/java/com/baeldung/soap/ws/client/generated/CountryServiceImplService.java | web-modules/jee-7/src/main/java/com/baeldung/soap/ws/client/generated/CountryServiceImplService.java |
package com.baeldung.soap.ws.client.generated;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import javax.xml.namespace.QName;
import javax.xml.ws.Service;
import javax.xml.ws.WebEndpoint;
import javax.xml.ws.WebServiceClient;
import javax.xml.ws.WebServiceException;
import javax.xml.ws.WebServiceFeature;
/**
* This class was generated by the JAX-WS RI.
* JAX-WS RI 2.2.9-b130926.1035
* Generated source version: 2.2
*
*/
@WebServiceClient(name = "CountryServiceImplService", targetNamespace = "http://server.ws.soap.baeldung.com/", wsdlLocation = "http://localhost:8888/ws/country?wsdl")
public class CountryServiceImplService extends Service {
private final static URL COUNTRYSERVICEIMPLSERVICE_WSDL_LOCATION;
private final static WebServiceException COUNTRYSERVICEIMPLSERVICE_EXCEPTION;
private final static QName COUNTRYSERVICEIMPLSERVICE_QNAME = new QName("http://server.ws.soap.baeldung.com/", "CountryServiceImplService");
static {
URL url = null;
WebServiceException e = null;
try {
url = new URI("http://localhost:8888/ws/country?wsdl").toURL();
} catch (MalformedURLException | URISyntaxException ex) {
e = new WebServiceException(ex);
}
COUNTRYSERVICEIMPLSERVICE_WSDL_LOCATION = url;
COUNTRYSERVICEIMPLSERVICE_EXCEPTION = e;
}
public CountryServiceImplService() {
super(__getWsdlLocation(), COUNTRYSERVICEIMPLSERVICE_QNAME);
}
public CountryServiceImplService(WebServiceFeature... features) {
super(__getWsdlLocation(), COUNTRYSERVICEIMPLSERVICE_QNAME, features);
}
public CountryServiceImplService(URL wsdlLocation) {
super(wsdlLocation, COUNTRYSERVICEIMPLSERVICE_QNAME);
}
public CountryServiceImplService(URL wsdlLocation, WebServiceFeature... features) {
super(wsdlLocation, COUNTRYSERVICEIMPLSERVICE_QNAME, features);
}
public CountryServiceImplService(URL wsdlLocation, QName serviceName) {
super(wsdlLocation, serviceName);
}
public CountryServiceImplService(URL wsdlLocation, QName serviceName, WebServiceFeature... features) {
super(wsdlLocation, serviceName, features);
}
/**
*
* @return
* returns CountryService
*/
@WebEndpoint(name = "CountryServiceImplPort")
public CountryService getCountryServiceImplPort() {
return super.getPort(new QName("http://server.ws.soap.baeldung.com/", "CountryServiceImplPort"), CountryService.class);
}
/**
*
* @param features
* A list of {@link javax.xml.ws.WebServiceFeature} to configure on the proxy. Supported features not in the <code>features</code> parameter will have their default values.
* @return
* returns CountryService
*/
@WebEndpoint(name = "CountryServiceImplPort")
public CountryService getCountryServiceImplPort(WebServiceFeature... features) {
return super.getPort(new QName("http://server.ws.soap.baeldung.com/", "CountryServiceImplPort"), CountryService.class, features);
}
private static URL __getWsdlLocation() {
if (COUNTRYSERVICEIMPLSERVICE_EXCEPTION != null) {
throw COUNTRYSERVICEIMPLSERVICE_EXCEPTION;
}
return COUNTRYSERVICEIMPLSERVICE_WSDL_LOCATION;
}
}
| java | MIT | 4463e58ffb73fe599bac2479abd84598c6e70a1a | 2026-01-04T14:45:57.069771Z | false |
eugenp/tutorials | https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/jee-7/src/main/java/com/baeldung/soap/ws/client/generated/ObjectFactory.java | web-modules/jee-7/src/main/java/com/baeldung/soap/ws/client/generated/ObjectFactory.java |
package com.baeldung.soap.ws.client.generated;
import javax.xml.bind.annotation.XmlRegistry;
/**
* This object contains factory methods for each
* Java content interface and Java element interface
* generated in the com.baeldung.soap.ws.client.generated package.
* <p>An ObjectFactory allows you to programatically
* construct new instances of the Java representation
* for XML content. The Java representation of XML
* content can consist of schema derived interfaces
* and classes representing the binding of schema
* type definitions, element declarations and model
* groups. Factory methods for each of these are
* provided in this class.
*
*/
@XmlRegistry
public class ObjectFactory {
/**
* Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: com.baeldung.soap.ws.client.generated
*
*/
public ObjectFactory() {
}
/**
* Create an instance of {@link Country }
*
*/
public Country createCountry() {
return new Country();
}
}
| java | MIT | 4463e58ffb73fe599bac2479abd84598c6e70a1a | 2026-01-04T14:45:57.069771Z | false |
eugenp/tutorials | https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/jee-7/src/main/java/com/baeldung/soap/ws/client/generated/Currency.java | web-modules/jee-7/src/main/java/com/baeldung/soap/ws/client/generated/Currency.java |
package com.baeldung.soap.ws.client.generated;
import javax.xml.bind.annotation.XmlEnum;
import javax.xml.bind.annotation.XmlType;
/**
* <p>Java class for currency.
*
* <p>The following schema fragment specifies the expected content contained within this class.
* <p>
* <pre>
* <simpleType name="currency">
* <restriction base="{http://www.w3.org/2001/XMLSchema}string">
* <enumeration value="EUR"/>
* <enumeration value="INR"/>
* <enumeration value="USD"/>
* </restriction>
* </simpleType>
* </pre>
*
*/
@XmlType(name = "currency")
@XmlEnum
public enum Currency {
EUR, INR, USD;
public String value() {
return name();
}
public static Currency fromValue(String v) {
return valueOf(v);
}
}
| java | MIT | 4463e58ffb73fe599bac2479abd84598c6e70a1a | 2026-01-04T14:45:57.069771Z | false |
eugenp/tutorials | https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/jee-7/src/main/java/com/baeldung/json/PersonWriter.java | web-modules/jee-7/src/main/java/com/baeldung/json/PersonWriter.java | package com.baeldung.json;
import javax.json.*;
import javax.json.stream.JsonGenerator;
import java.io.IOException;
import java.io.StringWriter;
import java.io.Writer;
import java.text.SimpleDateFormat;
import java.util.HashMap;
import java.util.Map;
public class PersonWriter {
private Person person;
private SimpleDateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy");
public PersonWriter(Person person) {
this.person = person;
}
public String write() throws IOException {
JsonObjectBuilder objectBuilder = Json
.createObjectBuilder()
.add("firstName", person.getFirstName())
.add("lastName", person.getLastName())
.add("birthdate", dateFormat.format(person.getBirthdate()));
final JsonArrayBuilder arrayBuilder = Json.createArrayBuilder();
person.getEmails().forEach(arrayBuilder::add);
objectBuilder.add("emails", arrayBuilder);
JsonObject jsonObject = objectBuilder.build();
JsonWriterFactory writerFactory = createWriterFactory();
return writeToString(jsonObject, writerFactory);
}
private String writeToString(JsonObject jsonObject, JsonWriterFactory writerFactory) throws IOException {
String jsonString;
try (Writer writer = new StringWriter()) {
writerFactory
.createWriter(writer)
.write(jsonObject);
jsonString = writer.toString();
}
return jsonString;
}
private JsonWriterFactory createWriterFactory() {
Map<String, Boolean> config = new HashMap<>();
config.put(JsonGenerator.PRETTY_PRINTING, true);
return Json.createWriterFactory(config);
}
}
| java | MIT | 4463e58ffb73fe599bac2479abd84598c6e70a1a | 2026-01-04T14:45:57.069771Z | false |
eugenp/tutorials | https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/jee-7/src/main/java/com/baeldung/json/Person.java | web-modules/jee-7/src/main/java/com/baeldung/json/Person.java | package com.baeldung.json;
import java.util.Date;
import java.util.List;
public class Person {
private String firstName;
private String lastName;
private Date birthdate;
private List<String> emails;
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 Date getBirthdate() {
return birthdate;
}
public void setBirthdate(Date birthdate) {
this.birthdate = birthdate;
}
public List<String> getEmails() {
return emails;
}
public void setEmails(List<String> emails) {
this.emails = emails;
}
}
| java | MIT | 4463e58ffb73fe599bac2479abd84598c6e70a1a | 2026-01-04T14:45:57.069771Z | false |
eugenp/tutorials | https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/jee-7/src/main/java/com/baeldung/json/PersonBuilder.java | web-modules/jee-7/src/main/java/com/baeldung/json/PersonBuilder.java | package com.baeldung.json;
import javax.json.*;
import java.io.IOException;
import java.io.StringReader;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.List;
import java.util.stream.Collectors;
public class PersonBuilder {
private String jsonString;
private SimpleDateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy");
public PersonBuilder(String jsonString) {
this.jsonString = jsonString;
}
public Person build() throws IOException, ParseException {
JsonReader reader = Json.createReader(new StringReader(jsonString));
JsonObject jsonObject = reader.readObject();
Person person = new Person();
person.setFirstName(jsonObject.getString("firstName"));
person.setLastName(jsonObject.getString("lastName"));
person.setBirthdate(dateFormat.parse(jsonObject.getString("birthdate")));
JsonArray emailsJson = jsonObject.getJsonArray("emails");
List<String> emails = emailsJson.getValuesAs(JsonString.class).stream()
.map(JsonString::getString)
.collect(Collectors.toList());
person.setEmails(emails);
return person;
}
}
| java | MIT | 4463e58ffb73fe599bac2479abd84598c6e70a1a | 2026-01-04T14:45:57.069771Z | false |
eugenp/tutorials | https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/jee-7/src/main/java/com/baeldung/timer/TimerEventListener.java | web-modules/jee-7/src/main/java/com/baeldung/timer/TimerEventListener.java | package com.baeldung.timer;
import javax.ejb.Singleton;
import javax.ejb.Startup;
import javax.enterprise.event.Observes;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
/**
* This class will listen to all TimerEvent and will collect them
*/
@Startup
@Singleton
public class TimerEventListener {
final List<TimerEvent> events = new CopyOnWriteArrayList<>();
public void listen(@Observes TimerEvent event) {
System.out.println("event = " + event);
events.add(event);
}
public List<TimerEvent> getEvents() {
return events;
}
}
| java | MIT | 4463e58ffb73fe599bac2479abd84598c6e70a1a | 2026-01-04T14:45:57.069771Z | false |
eugenp/tutorials | https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/jee-7/src/main/java/com/baeldung/timer/WorkerBean.java | web-modules/jee-7/src/main/java/com/baeldung/timer/WorkerBean.java | package com.baeldung.timer;
import javax.ejb.Lock;
import javax.ejb.LockType;
import javax.ejb.Singleton;
import java.util.concurrent.atomic.AtomicBoolean;
/**
* Created by cristianchiovari on 5/2/16.
*/
@Singleton
public class WorkerBean {
private AtomicBoolean busy = new AtomicBoolean(false);
@Lock(LockType.READ)
public void doTimerWork() throws InterruptedException {
System.out.println("Timer method called but not started yet !");
if (!busy.compareAndSet(false, true)) {
return;
}
try {
System.out.println("Timer work started");
Thread.sleep(12000);
System.out.println("Timer work done");
} finally {
busy.set(false);
}
}
} | java | MIT | 4463e58ffb73fe599bac2479abd84598c6e70a1a | 2026-01-04T14:45:57.069771Z | false |
eugenp/tutorials | https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/jee-7/src/main/java/com/baeldung/timer/ScheduleTimerBean.java | web-modules/jee-7/src/main/java/com/baeldung/timer/ScheduleTimerBean.java | package com.baeldung.timer;
import javax.ejb.Schedule;
import javax.ejb.Singleton;
import javax.ejb.Startup;
import javax.ejb.Timer;
import javax.enterprise.event.Event;
import javax.inject.Inject;
@Startup
@Singleton
public class ScheduleTimerBean {
@Inject
Event<TimerEvent> event;
@Schedule(hour = "*", minute = "*", second = "*/5", info = "Every 5 second timer")
public void automaticallyScheduled(Timer timer) {
fireEvent(timer);
}
private void fireEvent(Timer timer) {
event.fire(new TimerEvent(timer.getInfo().toString()));
}
}
| java | MIT | 4463e58ffb73fe599bac2479abd84598c6e70a1a | 2026-01-04T14:45:57.069771Z | false |
eugenp/tutorials | https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/jee-7/src/main/java/com/baeldung/timer/ProgrammaticWithInitialFixedDelayTimerBean.java | web-modules/jee-7/src/main/java/com/baeldung/timer/ProgrammaticWithInitialFixedDelayTimerBean.java | package com.baeldung.timer;
import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import javax.ejb.*;
import javax.enterprise.event.Event;
import javax.inject.Inject;
/**
* author: Cristian Chiovari
*/
@Startup
@Singleton
public class ProgrammaticWithInitialFixedDelayTimerBean {
@Inject
Event<TimerEvent> event;
@Resource
TimerService timerService;
@PostConstruct
public void initialize() {
timerService.createTimer(10000l,5000l, "Delay 10 seconds then every 5 second timer");
}
@Timeout
public void programmaticTimout(Timer timer) {
event.fire(new TimerEvent(timer.getInfo().toString()));
}
}
| java | MIT | 4463e58ffb73fe599bac2479abd84598c6e70a1a | 2026-01-04T14:45:57.069771Z | false |
eugenp/tutorials | https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/jee-7/src/main/java/com/baeldung/timer/ProgrammaticAtFixedRateTimerBean.java | web-modules/jee-7/src/main/java/com/baeldung/timer/ProgrammaticAtFixedRateTimerBean.java | package com.baeldung.timer;
import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import javax.ejb.*;
import javax.enterprise.event.Event;
import javax.inject.Inject;
/**
* author: Cristian Chiovari
*/
@Startup
@Singleton
public class ProgrammaticAtFixedRateTimerBean {
@Inject
Event<TimerEvent> event;
@Resource
TimerService timerService;
@PostConstruct
public void initialize() {
timerService.createTimer(0,1000, "Every second timer");
}
@Timeout
public void programmaticTimout(Timer timer) {
event.fire(new TimerEvent(timer.getInfo().toString()));
}
}
| java | MIT | 4463e58ffb73fe599bac2479abd84598c6e70a1a | 2026-01-04T14:45:57.069771Z | false |
eugenp/tutorials | https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/jee-7/src/main/java/com/baeldung/timer/FixedDelayTimerBean.java | web-modules/jee-7/src/main/java/com/baeldung/timer/FixedDelayTimerBean.java | package com.baeldung.timer;
import javax.ejb.*;
/**
* Created by ccristianchiovari on 5/2/16.
*/
@Singleton
public class FixedDelayTimerBean {
@EJB
private WorkerBean workerBean;
@Lock(LockType.READ)
@Schedule(second = "*/5", minute = "*", hour = "*", persistent = false)
public void atSchedule() throws InterruptedException {
workerBean.doTimerWork();
}
} | java | MIT | 4463e58ffb73fe599bac2479abd84598c6e70a1a | 2026-01-04T14:45:57.069771Z | false |
eugenp/tutorials | https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/jee-7/src/main/java/com/baeldung/timer/AutomaticTimerBean.java | web-modules/jee-7/src/main/java/com/baeldung/timer/AutomaticTimerBean.java | package com.baeldung.timer;
import javax.ejb.Schedule;
import javax.ejb.Singleton;
import javax.ejb.Startup;
import javax.enterprise.event.Event;
import javax.inject.Inject;
import java.util.Date;
@Startup
@Singleton
public class AutomaticTimerBean {
@Inject
Event<TimerEvent> event;
/**
* This method will be called every 10 second and will fire an @TimerEvent
*/
@Schedule(hour = "*", minute = "*", second = "*/10", info = "Every 10 second timer")
public void printDate() {
event.fire(new TimerEvent("TimerEvent sent at :" + new Date()));
}
}
| java | MIT | 4463e58ffb73fe599bac2479abd84598c6e70a1a | 2026-01-04T14:45:57.069771Z | false |
eugenp/tutorials | https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/jee-7/src/main/java/com/baeldung/timer/ProgrammaticTimerBean.java | web-modules/jee-7/src/main/java/com/baeldung/timer/ProgrammaticTimerBean.java | package com.baeldung.timer;
import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import javax.ejb.*;
import javax.enterprise.event.Event;
import javax.inject.Inject;
/**
* author: Jacek Jackowiak
*/
@Startup
@Singleton
public class ProgrammaticTimerBean {
@Inject
Event<TimerEvent> event;
@Resource
TimerService timerService;
@PostConstruct
public void initialize() {
ScheduleExpression scheduleExpression = new ScheduleExpression()
.hour("*")
.minute("*")
.second("*/5");
TimerConfig timerConfig = new TimerConfig();
timerConfig.setInfo("Every 5 second timer");
timerService.createCalendarTimer(scheduleExpression, timerConfig);
}
@Timeout
public void programmaticTimout(Timer timer) {
event.fire(new TimerEvent(timer.getInfo().toString()));
}
}
| java | MIT | 4463e58ffb73fe599bac2479abd84598c6e70a1a | 2026-01-04T14:45:57.069771Z | false |
eugenp/tutorials | https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/jee-7/src/main/java/com/baeldung/timer/TimerEvent.java | web-modules/jee-7/src/main/java/com/baeldung/timer/TimerEvent.java | package com.baeldung.timer;
public class TimerEvent {
private String eventInfo;
private long time = System.currentTimeMillis();
public TimerEvent(String s) {
this.eventInfo = s;
}
public long getTime() {
return time;
}
public String getEventInfo() {
return eventInfo;
}
@Override
public String toString() {
return "TimerEvent {" +
"eventInfo='" + eventInfo + '\'' +
", time=" + time +
'}';
}
}
| java | MIT | 4463e58ffb73fe599bac2479abd84598c6e70a1a | 2026-01-04T14:45:57.069771Z | false |
eugenp/tutorials | https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/jee-7/src/main/java/com/baeldung/arquillian/CarEJB.java | web-modules/jee-7/src/main/java/com/baeldung/arquillian/CarEJB.java | package com.baeldung.arquillian;
import java.util.ArrayList;
import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
@Stateless
public class CarEJB {
@PersistenceContext(unitName = "defaultPersistenceUnit")
private EntityManager em;
public Car saveCar(final Car car) {
em.persist(car);
return car;
}
@SuppressWarnings("unchecked")
public List<Car> findAllCars() {
final Query query = em.createQuery("SELECT b FROM Car b ORDER BY b.name ASC");
List<Car> entries = query.getResultList();
if (entries == null) {
entries = new ArrayList<Car>();
}
return entries;
}
public void deleteCar(Car car) {
car = em.merge(car);
em.remove(car);
}
} | java | MIT | 4463e58ffb73fe599bac2479abd84598c6e70a1a | 2026-01-04T14:45:57.069771Z | false |
eugenp/tutorials | https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/jee-7/src/main/java/com/baeldung/arquillian/CapsService.java | web-modules/jee-7/src/main/java/com/baeldung/arquillian/CapsService.java | package com.baeldung.arquillian;
import javax.ejb.Stateless;
import javax.inject.Inject;
@Stateless
public class CapsService {
@Inject
private CapsConvertor capsConvertor;
public String getConvertedCaps(final String word){
return capsConvertor.getLowerCase().convert(word);
}
} | java | MIT | 4463e58ffb73fe599bac2479abd84598c6e70a1a | 2026-01-04T14:45:57.069771Z | false |
eugenp/tutorials | https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/jee-7/src/main/java/com/baeldung/arquillian/CapsConvertor.java | web-modules/jee-7/src/main/java/com/baeldung/arquillian/CapsConvertor.java | package com.baeldung.arquillian;
import javax.ejb.Stateless;
@Stateless
public class CapsConvertor {
public ConvertToLowerCase getLowerCase(){
return new ConvertToLowerCase();
}
} | java | MIT | 4463e58ffb73fe599bac2479abd84598c6e70a1a | 2026-01-04T14:45:57.069771Z | false |
eugenp/tutorials | https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/jee-7/src/main/java/com/baeldung/arquillian/Car.java | web-modules/jee-7/src/main/java/com/baeldung/arquillian/Car.java | package com.baeldung.arquillian;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.validation.constraints.NotNull;
@Entity
public class Car {
@Id
@GeneratedValue
private Long id;
@NotNull
private String name;
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 String toString() {
return "Car [id=" + id + ", name=" + name + "]";
}
} | java | MIT | 4463e58ffb73fe599bac2479abd84598c6e70a1a | 2026-01-04T14:45:57.069771Z | false |
eugenp/tutorials | https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/jee-7/src/main/java/com/baeldung/arquillian/Component.java | web-modules/jee-7/src/main/java/com/baeldung/arquillian/Component.java | package com.baeldung.arquillian;
import java.io.PrintStream;
public class Component {
public void sendMessage(PrintStream to, String msg) {
to.println(message(msg));
}
public String message(String msg) {
return "Message, " + msg;
}
} | java | MIT | 4463e58ffb73fe599bac2479abd84598c6e70a1a | 2026-01-04T14:45:57.069771Z | false |
eugenp/tutorials | https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/jee-7/src/main/java/com/baeldung/arquillian/ConvertToLowerCase.java | web-modules/jee-7/src/main/java/com/baeldung/arquillian/ConvertToLowerCase.java | package com.baeldung.arquillian;
public class ConvertToLowerCase {
public String convert(String word){
return word.toLowerCase();
}
}
| java | MIT | 4463e58ffb73fe599bac2479abd84598c6e70a1a | 2026-01-04T14:45:57.069771Z | false |
eugenp/tutorials | https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/jee-7/src/main/java/com/baeldung/jaxws/server/topdown/EmployeeServiceTopDown.java | web-modules/jee-7/src/main/java/com/baeldung/jaxws/server/topdown/EmployeeServiceTopDown.java |
package com.baeldung.jaxws.server.topdown;
import javax.jws.WebMethod;
import javax.jws.WebResult;
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
import javax.xml.bind.annotation.XmlSeeAlso;
/**
* This class was generated by the JAX-WS RI.
* JAX-WS RI 2.2.4-b01
* Generated source version: 2.2
*
*/
@WebService(name = "EmployeeServiceTopDown", targetNamespace = "http://topdown.server.jaxws.baeldung.com/")
@SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE)
@XmlSeeAlso({
ObjectFactory.class
})
public interface EmployeeServiceTopDown {
/**
*
* @return
* returns int
*/
@WebMethod(action = "http://topdown.server.jaxws.baeldung.com/EmployeeServiceTopDown/countEmployees")
@WebResult(name = "countEmployeesResponse", targetNamespace = "http://topdown.server.jaxws.baeldung.com/", partName = "parameters")
public int countEmployees();
}
| java | MIT | 4463e58ffb73fe599bac2479abd84598c6e70a1a | 2026-01-04T14:45:57.069771Z | false |
eugenp/tutorials | https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/jee-7/src/main/java/com/baeldung/jaxws/server/topdown/ObjectFactory.java | web-modules/jee-7/src/main/java/com/baeldung/jaxws/server/topdown/ObjectFactory.java |
package com.baeldung.jaxws.server.topdown;
import javax.xml.bind.JAXBElement;
import javax.xml.bind.annotation.XmlElementDecl;
import javax.xml.bind.annotation.XmlRegistry;
import javax.xml.namespace.QName;
/**
* This object contains factory methods for each
* Java content interface and Java element interface
* generated in the com.baeldung.jaxws.server.topdown package.
* <p>An ObjectFactory allows you to programatically
* construct new instances of the Java representation
* for XML content. The Java representation of XML
* content can consist of schema derived interfaces
* and classes representing the binding of schema
* type definitions, element declarations and model
* groups. Factory methods for each of these are
* provided in this class.
*
*/
@XmlRegistry
public class ObjectFactory {
private final static QName _CountEmployeesResponse_QNAME = new QName("http://topdown.server.jaxws.baeldung.com/", "countEmployeesResponse");
/**
* Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: com.baeldung.jaxws.server.topdown
*
*/
public ObjectFactory() {
}
/**
* Create an instance of {@link JAXBElement }{@code <}{@link Integer }{@code >}}
*
*/
@XmlElementDecl(namespace = "http://topdown.server.jaxws.baeldung.com/", name = "countEmployeesResponse")
public JAXBElement<Integer> createCountEmployeesResponse(Integer value) {
return new JAXBElement<Integer>(_CountEmployeesResponse_QNAME, Integer.class, null, value);
}
}
| java | MIT | 4463e58ffb73fe599bac2479abd84598c6e70a1a | 2026-01-04T14:45:57.069771Z | false |
eugenp/tutorials | https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/jee-7/src/main/java/com/baeldung/jaxws/server/topdown/EmployeeServiceTopDownImpl.java | web-modules/jee-7/src/main/java/com/baeldung/jaxws/server/topdown/EmployeeServiceTopDownImpl.java | package com.baeldung.jaxws.server.topdown;
import com.baeldung.jaxws.server.repository.EmployeeRepository;
import javax.inject.Inject;
import javax.jws.WebMethod;
import javax.jws.WebService;
@WebService(name = "EmployeeServiceTopDown", targetNamespace = "http://topdown.server.jaxws.baeldung.com/", endpointInterface = "com.baeldung.jaxws.server.topdown.EmployeeServiceTopDown")
public class EmployeeServiceTopDownImpl implements EmployeeServiceTopDown {
@Inject private EmployeeRepository employeeRepositoryImpl;
@WebMethod
public int countEmployees() {
return employeeRepositoryImpl.count();
}
}
| java | MIT | 4463e58ffb73fe599bac2479abd84598c6e70a1a | 2026-01-04T14:45:57.069771Z | false |
eugenp/tutorials | https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/jee-7/src/main/java/com/baeldung/jaxws/server/topdown/EmployeeServiceTopDown_Service.java | web-modules/jee-7/src/main/java/com/baeldung/jaxws/server/topdown/EmployeeServiceTopDown_Service.java |
package com.baeldung.jaxws.server.topdown;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import javax.xml.namespace.QName;
import javax.xml.ws.Service;
import javax.xml.ws.WebEndpoint;
import javax.xml.ws.WebServiceClient;
import javax.xml.ws.WebServiceException;
import javax.xml.ws.WebServiceFeature;
/**
* This class was generated by the JAX-WS RI.
* JAX-WS RI 2.2.4-b01
* Generated source version: 2.2
*
*/
@WebServiceClient(name = "EmployeeServiceTopDown", targetNamespace = "http://topdown.server.jaxws.baeldung.com/", wsdlLocation = "file:/Users/do-enr-lap-4/Developer/baeldung/source/tutorials/jee7/src/main/java/com/baeldung/jaxws/server/topdown/wsdl/employeeservicetopdown.wsdl")
public class EmployeeServiceTopDown_Service
extends Service
{
private final static URL EMPLOYEESERVICETOPDOWN_WSDL_LOCATION;
private final static WebServiceException EMPLOYEESERVICETOPDOWN_EXCEPTION;
private final static QName EMPLOYEESERVICETOPDOWN_QNAME = new QName("http://topdown.server.jaxws.baeldung.com/", "EmployeeServiceTopDown");
static {
URL url = null;
WebServiceException e = null;
try {
url = new URI("file:/Users/do-enr-lap-4/Developer/baeldung/source/tutorials/jee7/src/main/java/com/baeldung/jaxws/server/topdown/wsdl/employeeservicetopdown.wsdl").toURL();
} catch (MalformedURLException | URISyntaxException ex) {
e = new WebServiceException(ex);
}
EMPLOYEESERVICETOPDOWN_WSDL_LOCATION = url;
EMPLOYEESERVICETOPDOWN_EXCEPTION = e;
}
public EmployeeServiceTopDown_Service() {
super(__getWsdlLocation(), EMPLOYEESERVICETOPDOWN_QNAME);
}
public EmployeeServiceTopDown_Service(WebServiceFeature... features) {
super(__getWsdlLocation(), EMPLOYEESERVICETOPDOWN_QNAME, features);
}
public EmployeeServiceTopDown_Service(URL wsdlLocation) {
super(wsdlLocation, EMPLOYEESERVICETOPDOWN_QNAME);
}
public EmployeeServiceTopDown_Service(URL wsdlLocation, WebServiceFeature... features) {
super(wsdlLocation, EMPLOYEESERVICETOPDOWN_QNAME, features);
}
public EmployeeServiceTopDown_Service(URL wsdlLocation, QName serviceName) {
super(wsdlLocation, serviceName);
}
public EmployeeServiceTopDown_Service(URL wsdlLocation, QName serviceName, WebServiceFeature... features) {
super(wsdlLocation, serviceName, features);
}
/**
*
* @return
* returns EmployeeServiceTopDown
*/
@WebEndpoint(name = "EmployeeServiceTopDownSOAP")
public EmployeeServiceTopDown getEmployeeServiceTopDownSOAP() {
return super.getPort(new QName("http://topdown.server.jaxws.baeldung.com/", "EmployeeServiceTopDownSOAP"), EmployeeServiceTopDown.class);
}
/**
*
* @param features
* A list of {@link javax.xml.ws.WebServiceFeature} to configure on the proxy. Supported features not in the <code>features</code> parameter will have their default values.
* @return
* returns EmployeeServiceTopDown
*/
@WebEndpoint(name = "EmployeeServiceTopDownSOAP")
public EmployeeServiceTopDown getEmployeeServiceTopDownSOAP(WebServiceFeature... features) {
return super.getPort(new QName("http://topdown.server.jaxws.baeldung.com/", "EmployeeServiceTopDownSOAP"), EmployeeServiceTopDown.class, features);
}
private static URL __getWsdlLocation() {
if (EMPLOYEESERVICETOPDOWN_EXCEPTION!= null) {
throw EMPLOYEESERVICETOPDOWN_EXCEPTION;
}
return EMPLOYEESERVICETOPDOWN_WSDL_LOCATION;
}
}
| java | MIT | 4463e58ffb73fe599bac2479abd84598c6e70a1a | 2026-01-04T14:45:57.069771Z | false |
eugenp/tutorials | https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/jee-7/src/main/java/com/baeldung/jaxws/server/repository/EmployeeRepositoryImpl.java | web-modules/jee-7/src/main/java/com/baeldung/jaxws/server/repository/EmployeeRepositoryImpl.java | package com.baeldung.jaxws.server.repository;
import java.util.ArrayList;
import java.util.List;
import com.baeldung.jaxws.server.bottomup.exception.EmployeeAlreadyExists;
import com.baeldung.jaxws.server.bottomup.exception.EmployeeNotFound;
import com.baeldung.jaxws.server.bottomup.model.Employee;
public class EmployeeRepositoryImpl implements EmployeeRepository {
private List<Employee> employeeList;
public EmployeeRepositoryImpl() {
employeeList = new ArrayList<>();
employeeList.add(new Employee(1, "Jane"));
employeeList.add(new Employee(2, "Jack"));
employeeList.add(new Employee(3, "George"));
}
public List<Employee> getAllEmployees() {
return employeeList;
}
public Employee getEmployee(int id) throws EmployeeNotFound {
for (Employee emp : employeeList) {
if (emp.getId() == id) {
return emp;
}
}
throw new EmployeeNotFound();
}
public Employee updateEmployee(int id, String name) throws EmployeeNotFound {
for (Employee employee1 : employeeList) {
if (employee1.getId() == id) {
employee1.setId(id);
employee1.setFirstName(name);
return employee1;
}
}
throw new EmployeeNotFound();
}
public boolean deleteEmployee(int id) throws EmployeeNotFound {
for (Employee emp : employeeList) {
if (emp.getId() == id) {
employeeList.remove(emp);
return true;
}
}
throw new EmployeeNotFound();
}
public Employee addEmployee(int id, String name) throws EmployeeAlreadyExists {
for (Employee emp : employeeList) {
if (emp.getId() == id) {
throw new EmployeeAlreadyExists();
}
}
Employee employee = new Employee(id, name);
employeeList.add(employee);
return employee;
}
public int count() {
return employeeList.size();
}
}
| java | MIT | 4463e58ffb73fe599bac2479abd84598c6e70a1a | 2026-01-04T14:45:57.069771Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.