diff --git a/core-java-8/src/test/java/com/baeldung/file/FileOperationsTest.java b/core-java-8/src/test/java/com/baeldung/file/FileOperationsTest.java index 3752fc5b7f..30f6fc713f 100644 --- a/core-java-8/src/test/java/com/baeldung/file/FileOperationsTest.java +++ b/core-java-8/src/test/java/com/baeldung/file/FileOperationsTest.java @@ -107,17 +107,13 @@ public class FileOperationsTest { } private String readFromInputStream(InputStream inputStream) throws IOException { - InputStreamReader inputStreamReader = new InputStreamReader(inputStream); - BufferedReader bufferedReader = new BufferedReader(inputStreamReader); StringBuilder resultStringBuilder = new StringBuilder(); - String line; - while ((line = bufferedReader.readLine()) != null) { - resultStringBuilder.append(line); - resultStringBuilder.append("\n"); + try (BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream))) { + String line; + while ((line = bufferedReader.readLine()) != null) { + resultStringBuilder.append(line).append("\n"); + } } - bufferedReader.close(); - inputStreamReader.close(); - inputStream.close(); return resultStringBuilder.toString(); } } \ No newline at end of file diff --git a/core-java/src/test/resources/test_md5.txt b/core-java/src/test/resources/test_md5.txt new file mode 100644 index 0000000000..95d09f2b10 --- /dev/null +++ b/core-java/src/test/resources/test_md5.txt @@ -0,0 +1 @@ +hello world \ No newline at end of file diff --git a/play-framework/student-api/test/ApplicationTest.java b/play-framework/student-api/test/ApplicationTest.java index 3d7c4875aa..1133978e9a 100644 --- a/play-framework/student-api/test/ApplicationTest.java +++ b/play-framework/student-api/test/ApplicationTest.java @@ -1,45 +1,172 @@ -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import com.fasterxml.jackson.databind.JsonNode; -import org.junit.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; -import play.mvc.*; +import java.io.BufferedReader; +import java.io.DataOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.net.HttpURLConnection; +import java.net.MalformedURLException; +import java.net.URL; +import java.util.Arrays; + +import org.json.JSONArray; +import org.json.JSONObject; +import org.junit.Before; +import org.junit.Test; +import model.Student; import play.test.*; -import play.data.DynamicForm; -import play.data.validation.ValidationError; -import play.data.validation.Constraints.RequiredValidator; -import play.i18n.Lang; -import play.libs.F; -import play.libs.F.*; -import play.twirl.api.Content; - import static play.test.Helpers.*; -import static org.junit.Assert.*; - - -/** - * - * Simple (JUnit) tests that can call all parts of a play app. - * If you are interested in mocking a whole application, see the wiki for more details. - * - */ -public class ApplicationTest { - - @Test - public void simpleCheck() { - int a = 1 + 1; - assertEquals(2, a); - } - - @Test - public void renderTemplate() { - Content html = views.html.index.render("Your new application is ready."); - assertEquals("text/html", html.contentType()); - assertTrue(html.body().contains("Your new application is ready.")); - } +public class ApplicationTest{ + private static final String BASE_URL = "http://localhost:9000"; + @Test +public void testInServer() throws Exception { + TestServer server = testServer(3333); + running(server, () -> { + try { + WSClient ws = play.libs.ws.WS.newClient(3333); + CompletionStage completionStage = ws.url("/").get(); + WSResponse response = completionStage.toCompletableFuture().get(); + ws.close(); + assertEquals(OK, response.getStatus()); + } catch (Exception e) { + logger.error(e.getMessage(), e); + } + }); +} + @Test + public void whenCreatesRecord_thenCorrect() { + Student student = new Student("jody", "west", 50); + JSONObject obj = new JSONObject(makeRequest(BASE_URL, "POST", new JSONObject(student))); + assertTrue(obj.getBoolean("isSuccessfull")); + JSONObject body = obj.getJSONObject("body"); + assertEquals(student.getAge(), body.getInt("age")); + assertEquals(student.getFirstName(), body.getString("firstName")); + assertEquals(student.getLastName(), body.getString("lastName")); + } + + @Test + public void whenDeletesCreatedRecord_thenCorrect() { + Student student = new Student("Usain", "Bolt", 25); + JSONObject ob1 = new JSONObject(makeRequest(BASE_URL, "POST", new JSONObject(student))).getJSONObject("body"); + int id = ob1.getInt("id"); + JSONObject obj1 = new JSONObject(makeRequest(BASE_URL + "/" + id, "POST", new JSONObject())); + assertTrue(obj1.getBoolean("isSuccessfull")); + makeRequest(BASE_URL + "/" + id, "DELETE", null); + JSONObject obj2 = new JSONObject(makeRequest(BASE_URL + "/" + id, "POST", new JSONObject())); + assertFalse(obj2.getBoolean("isSuccessfull")); + } + + @Test + public void whenUpdatesCreatedRecord_thenCorrect() { + Student student = new Student("john", "doe", 50); + JSONObject body1 = new JSONObject(makeRequest(BASE_URL, "POST", new JSONObject(student))).getJSONObject("body"); + assertEquals(student.getAge(), body1.getInt("age")); + int newAge = 60; + body1.put("age", newAge); + JSONObject body2 = new JSONObject(makeRequest(BASE_URL, "PUT", body1)).getJSONObject("body"); + assertFalse(student.getAge() == body2.getInt("age")); + assertTrue(newAge == body2.getInt("age")); + } + + @Test + public void whenGetsAllRecords_thenCorrect() { + Student student1 = new Student("jane", "daisy", 50); + Student student2 = new Student("john", "daniel", 60); + Student student3 = new Student("don", "mason", 55); + Student student4 = new Student("scarlet", "ohara", 90); + + makeRequest(BASE_URL, "POST", new JSONObject(student1)); + makeRequest(BASE_URL, "POST", new JSONObject(student2)); + makeRequest(BASE_URL, "POST", new JSONObject(student3)); + makeRequest(BASE_URL, "POST", new JSONObject(student4)); + + JSONObject objects = new JSONObject(makeRequest(BASE_URL, "GET", null)); + assertTrue(objects.getBoolean("isSuccessfull")); + JSONArray array = objects.getJSONArray("body"); + assertTrue(array.length() >= 4); + } + + public static String makeRequest(String myUrl, String httpMethod, JSONObject parameters) { + + URL url = null; + try { + url = new URL(myUrl); + } catch (MalformedURLException e) { + e.printStackTrace(); + } + HttpURLConnection conn = null; + try { + + conn = (HttpURLConnection) url.openConnection(); + } catch (IOException e) { + e.printStackTrace(); + } + conn.setDoInput(true); + + conn.setReadTimeout(10000); + + conn.setRequestProperty("Content-Type", "application/json"); + DataOutputStream dos = null; + int respCode = 0; + String inputString = null; + try { + conn.setRequestMethod(httpMethod); + + if (Arrays.asList("POST", "PUT").contains(httpMethod)) { + String params = parameters.toString(); + + conn.setDoOutput(true); + + dos = new DataOutputStream(conn.getOutputStream()); + dos.writeBytes(params); + dos.flush(); + dos.close(); + } + respCode = conn.getResponseCode(); + if (respCode != 200 && respCode != 201) { + String error = inputStreamToString(conn.getErrorStream()); + return error; + } + inputString = inputStreamToString(conn.getInputStream()); + + } catch (IOException e) { + + e.printStackTrace(); + } + return inputString; + } + + public static String inputStreamToString(InputStream is) { + BufferedReader br = null; + StringBuilder sb = new StringBuilder(); + + String line; + try { + + br = new BufferedReader(new InputStreamReader(is)); + while ((line = br.readLine()) != null) { + sb.append(line); + } + + } catch (IOException e) { + e.printStackTrace(); + } finally { + if (br != null) { + try { + br.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + + return sb.toString(); + + } } diff --git a/play-framework/student-api/test/IntegrationTest.java b/play-framework/student-api/test/IntegrationTest.java deleted file mode 100644 index c53c71e124..0000000000 --- a/play-framework/student-api/test/IntegrationTest.java +++ /dev/null @@ -1,25 +0,0 @@ -import org.junit.*; - -import play.mvc.*; -import play.test.*; - -import static play.test.Helpers.*; -import static org.junit.Assert.*; - -import static org.fluentlenium.core.filter.FilterConstructor.*; - -public class IntegrationTest { - - /** - * add your integration test here - * in this example we just check if the welcome page is being shown - */ - @Test - public void test() { - running(testServer(3333, fakeApplication(inMemoryDatabase())), HTMLUNIT, browser -> { - browser.goTo("http://localhost:3333"); - assertTrue(browser.pageSource().contains("Your new application is ready.")); - }); - } - -} diff --git a/spring-jms/pom.xml b/spring-jms/pom.xml index 8f78469989..b15c18f991 100644 --- a/spring-jms/pom.xml +++ b/spring-jms/pom.xml @@ -26,6 +26,12 @@ activemq-all ${activemq.version} + + junit + junit + 4.12 + test + @@ -36,8 +42,8 @@ maven-compiler-plugin 3.2 - 1.7 - 1.7 + 1.8 + 1.8 @@ -52,6 +58,16 @@ - spring-jms + + + org.apache.maven.plugins + maven-compiler-plugin + + 1.8 + 1.8 + + + + spring-jms \ No newline at end of file diff --git a/spring-jms/src/main/java/com/baeldung/spring/jms/Employee.java b/spring-jms/src/main/java/com/baeldung/spring/jms/Employee.java index 4da02907a9..ff4f262b38 100644 --- a/spring-jms/src/main/java/com/baeldung/spring/jms/Employee.java +++ b/spring-jms/src/main/java/com/baeldung/spring/jms/Employee.java @@ -18,6 +18,6 @@ public class Employee { } public String toString() { - return "Person: name(" + name + "), age(" + age + ")"; + return "Employee: name(" + name + "), age(" + age + ")"; } } diff --git a/spring-jms/src/main/java/com/baeldung/spring/jms/SampleJMSExample.java b/spring-jms/src/main/java/com/baeldung/spring/jms/SampleJMSExample.java deleted file mode 100644 index a243bc1390..0000000000 --- a/spring-jms/src/main/java/com/baeldung/spring/jms/SampleJMSExample.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.baeldung.spring.jms; - -import org.apache.activemq.broker.BrokerFactory; -import org.apache.activemq.broker.BrokerService; -import org.springframework.context.support.ClassPathXmlApplicationContext; - -import java.net.URI; - -public class SampleJMSExample { - public static void main(String[] args) throws Exception { - BrokerService broker = BrokerFactory.createBroker(new URI("broker:(tcp://localhost:61616)")); - broker.start(); - ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml"); - - } -} diff --git a/spring-jms/src/main/java/com/baeldung/spring/jms/SampleJmsMessageSender.java b/spring-jms/src/main/java/com/baeldung/spring/jms/SampleJmsMessageSender.java index 865a1d4747..1ef3902a31 100644 --- a/spring-jms/src/main/java/com/baeldung/spring/jms/SampleJmsMessageSender.java +++ b/spring-jms/src/main/java/com/baeldung/spring/jms/SampleJmsMessageSender.java @@ -1,17 +1,18 @@ package com.baeldung.spring.jms; import org.springframework.jms.core.JmsTemplate; -import org.springframework.jms.core.MessageCreator; -import javax.jms.*; +import javax.jms.Queue; +import java.util.HashMap; +import java.util.Map; public class SampleJmsMessageSender { private JmsTemplate jmsTemplate; private Queue queue; - public void createJmsTemplate(ConnectionFactory cf) { - this.jmsTemplate = new JmsTemplate(cf); + public void setJmsTemplate(JmsTemplate jmsTemplate) { + this.jmsTemplate = jmsTemplate; } public void setQueue(Queue queue) { @@ -19,10 +20,14 @@ public class SampleJmsMessageSender { } public void simpleSend() { - this.jmsTemplate.send(this.queue, new MessageCreator() { - public Message createMessage(Session session) throws JMSException { - return session.createTextMessage("hello queue world"); - } - }); + jmsTemplate.send(queue, s -> s.createTextMessage("hello queue world")); } -} \ No newline at end of file + + public void sendMessage(final Employee employee) { + System.out.println("Jms Message Sender : " + employee); + Map map = new HashMap<>(); + map.put("name", employee.getName()); + map.put("age", employee.getAge()); + this.jmsTemplate.convertAndSend(map); + } +} diff --git a/spring-jms/src/main/java/com/baeldung/spring/jms/SampleListener.java b/spring-jms/src/main/java/com/baeldung/spring/jms/SampleListener.java index 0320870d88..eb9d51160d 100644 --- a/spring-jms/src/main/java/com/baeldung/spring/jms/SampleListener.java +++ b/spring-jms/src/main/java/com/baeldung/spring/jms/SampleListener.java @@ -1,18 +1,25 @@ package com.baeldung.spring.jms; +import org.springframework.jms.core.JmsTemplate; + import javax.jms.JMSException; import javax.jms.Message; import javax.jms.MessageListener; import javax.jms.TextMessage; +import java.util.Map; public class SampleListener implements MessageListener { - private String textMessage; + public JmsTemplate getJmsTemplate() { + return getJmsTemplate(); + } public void onMessage(Message message) { if (message instanceof TextMessage) { try { - textMessage = ((TextMessage) message).getText(); + + String msg = ((TextMessage) message).getText(); + System.out.println("Message has been consumed : " + msg); } catch (JMSException ex) { throw new RuntimeException(ex); } @@ -20,4 +27,9 @@ public class SampleListener implements MessageListener { throw new IllegalArgumentException("Message Error"); } } -} \ No newline at end of file + + public Employee receiveMessage() throws JMSException { + Map map = (Map) getJmsTemplate().receiveAndConvert(); + return new Employee((String) map.get("name"), (Integer) map.get("age")); + } +} diff --git a/spring-jms/src/main/java/com/baeldung/spring/jms/SampleMessageConverter.java b/spring-jms/src/main/java/com/baeldung/spring/jms/SampleMessageConverter.java index 6cfc588f13..368a62841f 100644 --- a/spring-jms/src/main/java/com/baeldung/spring/jms/SampleMessageConverter.java +++ b/spring-jms/src/main/java/com/baeldung/spring/jms/SampleMessageConverter.java @@ -11,10 +11,10 @@ import javax.jms.Session; public class SampleMessageConverter implements MessageConverter { public Message toMessage(Object object, Session session) throws JMSException, MessageConversionException { - Employee person = (Employee) object; + Employee employee = (Employee) object; MapMessage message = session.createMapMessage(); - message.setString("name", person.getName()); - message.setInt("age", person.getAge()); + message.setString("name", employee.getName()); + message.setInt("age", employee.getAge()); return message; } diff --git a/spring-jms/src/main/resources/EmbeddedActiveMQ.xml b/spring-jms/src/main/resources/EmbeddedActiveMQ.xml new file mode 100644 index 0000000000..5e956144fd --- /dev/null +++ b/spring-jms/src/main/resources/EmbeddedActiveMQ.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/spring-jms/src/main/resources/applicationContext.xml b/spring-jms/src/main/resources/applicationContext.xml index c15289763f..d94eb4c371 100644 --- a/spring-jms/src/main/resources/applicationContext.xml +++ b/spring-jms/src/main/resources/applicationContext.xml @@ -3,16 +3,27 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> - - - - - - - - + + + + + + + + + + + + + + + + + + - + @@ -23,8 +34,7 @@ - + - - \ No newline at end of file + diff --git a/spring-jms/src/test/java/com/baeldung/spring/jms/DefaultTextMessageSenderTest.java b/spring-jms/src/test/java/com/baeldung/spring/jms/DefaultTextMessageSenderTest.java new file mode 100644 index 0000000000..439bc6caad --- /dev/null +++ b/spring-jms/src/test/java/com/baeldung/spring/jms/DefaultTextMessageSenderTest.java @@ -0,0 +1,25 @@ +package com.baeldung.spring.jms; + +import org.junit.BeforeClass; +import org.junit.Test; +import org.springframework.context.ApplicationContext; +import org.springframework.context.support.ClassPathXmlApplicationContext; + +public class DefaultTextMessageSenderTest { + + private static SampleJmsMessageSender messageProducer; + + @SuppressWarnings("resource") + @BeforeClass + public static void setUp() { + ApplicationContext applicationContext = new ClassPathXmlApplicationContext( + "classpath:EmbeddedActiveMQ.xml", "classpath:applicationContext.xml"); + messageProducer = (SampleJmsMessageSender) applicationContext.getBean("SampleJmsMessageSender"); + } + + @Test + public void testSimpleSend() { + messageProducer.simpleSend(); + } + +} diff --git a/spring-jms/src/test/java/com/baeldung/spring/jms/MapMessageConvertAndSendTest.java b/spring-jms/src/test/java/com/baeldung/spring/jms/MapMessageConvertAndSendTest.java new file mode 100644 index 0000000000..da9bb0294d --- /dev/null +++ b/spring-jms/src/test/java/com/baeldung/spring/jms/MapMessageConvertAndSendTest.java @@ -0,0 +1,25 @@ +package com.baeldung.spring.jms; + +import org.junit.BeforeClass; +import org.junit.Test; +import org.springframework.context.ApplicationContext; +import org.springframework.context.support.ClassPathXmlApplicationContext; + +public class MapMessageConvertAndSendTest { + + private static SampleJmsMessageSender messageProducer; + + @SuppressWarnings("resource") + @BeforeClass + public static void setUp() { + ApplicationContext applicationContext = new ClassPathXmlApplicationContext( + "classpath:EmbeddedActiveMQ.xml", "classpath:applicationContext.xml"); + messageProducer = (SampleJmsMessageSender) applicationContext.getBean("SampleJmsMessageSender"); + } + + @Test + public void testSendMessage() { + messageProducer.sendMessage(new Employee("JavaDeveloper2", 22)); + } + +} diff --git a/wicket/src/main/java/com/baeldung/wicket/examples/Examples.html b/wicket/src/main/java/com/baeldung/wicket/examples/HelloWorld.html similarity index 100% rename from wicket/src/main/java/com/baeldung/wicket/examples/Examples.html rename to wicket/src/main/java/com/baeldung/wicket/examples/HelloWorld.html diff --git a/wicket/src/main/java/com/baeldung/wicket/examples/Examples.java b/wicket/src/main/java/com/baeldung/wicket/examples/HelloWorld.java similarity index 77% rename from wicket/src/main/java/com/baeldung/wicket/examples/Examples.java rename to wicket/src/main/java/com/baeldung/wicket/examples/HelloWorld.java index 358e4f7b19..ceb0836467 100644 --- a/wicket/src/main/java/com/baeldung/wicket/examples/Examples.java +++ b/wicket/src/main/java/com/baeldung/wicket/examples/HelloWorld.java @@ -2,7 +2,7 @@ package com.baeldung.wicket.examples; import org.apache.wicket.markup.html.WebPage; -public class Examples extends WebPage { +public class HelloWorld extends WebPage { private static final long serialVersionUID = 1L; diff --git a/wicket/src/main/java/com/baeldung/wicket/examples/ExamplesApplication.java b/wicket/src/main/java/com/baeldung/wicket/examples/HelloWorldApplication.java similarity index 80% rename from wicket/src/main/java/com/baeldung/wicket/examples/ExamplesApplication.java rename to wicket/src/main/java/com/baeldung/wicket/examples/HelloWorldApplication.java index 711e8f01fd..079280adce 100644 --- a/wicket/src/main/java/com/baeldung/wicket/examples/ExamplesApplication.java +++ b/wicket/src/main/java/com/baeldung/wicket/examples/HelloWorldApplication.java @@ -4,15 +4,14 @@ import org.apache.wicket.markup.html.WebPage; import org.apache.wicket.protocol.http.WebApplication; import com.baeldung.wicket.examples.cafeaddress.CafeAddress; -import com.baeldung.wicket.examples.helloworld.HelloWorld; -public class ExamplesApplication extends WebApplication { +public class HelloWorldApplication extends WebApplication { /** * @see org.apache.wicket.Application#getHomePage() */ @Override public Class getHomePage() { - return Examples.class; + return HelloWorld.class; } /** diff --git a/wicket/src/main/java/com/baeldung/wicket/examples/cafeaddress/CafeAddress.java b/wicket/src/main/java/com/baeldung/wicket/examples/cafeaddress/CafeAddress.java index ce26c5a1ad..86820393c7 100644 --- a/wicket/src/main/java/com/baeldung/wicket/examples/cafeaddress/CafeAddress.java +++ b/wicket/src/main/java/com/baeldung/wicket/examples/cafeaddress/CafeAddress.java @@ -1,10 +1,5 @@ package com.baeldung.wicket.examples.cafeaddress; -import java.io.Serializable; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Map; - import org.apache.wicket.ajax.AjaxRequestTarget; import org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior; import org.apache.wicket.markup.html.WebPage; @@ -13,29 +8,29 @@ import org.apache.wicket.markup.html.form.DropDownChoice; import org.apache.wicket.model.PropertyModel; import org.apache.wicket.request.mapper.parameter.PageParameters; +import java.io.Serializable; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Map; + public class CafeAddress extends WebPage { - - private static final long serialVersionUID = 1L; - - String selectedCafe; - Address address; - Map cafeNamesAndAddresses = new HashMap<>(); + private String selectedCafe; + private Address address; + private Map cafeNamesAndAddresses = new HashMap<>(); public CafeAddress(final PageParameters parameters) { super(parameters); initCafes(); - ArrayList cafeNames = new ArrayList<>(this.cafeNamesAndAddresses.keySet()); - this.selectedCafe = cafeNames.get(0); - this.address = new Address(this.cafeNamesAndAddresses.get(this.selectedCafe).getAddress()); + ArrayList cafeNames = new ArrayList<>(cafeNamesAndAddresses.keySet()); + selectedCafe = cafeNames.get(0); + address = new Address(cafeNamesAndAddresses.get(selectedCafe).getAddress()); final Label addressLabel = new Label("address", new PropertyModel(this.address, "address")); addressLabel.setOutputMarkupId(true); - final DropDownChoice cafeDropdown = new DropDownChoice<>("cafes", new PropertyModel(this, "selectedCafe"), cafeNames); + final DropDownChoice cafeDropdown = new DropDownChoice<>("cafes", new PropertyModel<>(this, "selectedCafe"), cafeNames); cafeDropdown.add(new AjaxFormComponentUpdatingBehavior("onchange") { - private static final long serialVersionUID = 1L; - @Override protected void onUpdate(AjaxRequestTarget target) { String name = (String) cafeDropdown.getDefaultModel().getObject(); @@ -61,11 +56,11 @@ public class CafeAddress extends WebPage { this.sAddress = address; } - public String getAddress() { + String getAddress() { return this.sAddress; } - public void setAddress(String address) { + void setAddress(String address) { this.sAddress = address; } } diff --git a/wicket/src/main/java/com/baeldung/wicket/examples/helloworld/HelloWorld.java b/wicket/src/main/java/com/baeldung/wicket/examples/helloworld/HelloWorld.java index f819e05be6..6dc7295798 100644 --- a/wicket/src/main/java/com/baeldung/wicket/examples/helloworld/HelloWorld.java +++ b/wicket/src/main/java/com/baeldung/wicket/examples/helloworld/HelloWorld.java @@ -4,9 +4,6 @@ import org.apache.wicket.markup.html.WebPage; import org.apache.wicket.markup.html.basic.Label; public class HelloWorld extends WebPage { - - private static final long serialVersionUID = 1L; - public HelloWorld() { add(new Label("hello", "Hello World!")); } diff --git a/wicket/src/main/test/java/com/baeldung/wicket/examples/TestHomePage.java b/wicket/src/main/test/java/com/baeldung/wicket/examples/TestHomePage.java index a393f1d178..7015ffd255 100644 --- a/wicket/src/main/test/java/com/baeldung/wicket/examples/TestHomePage.java +++ b/wicket/src/main/test/java/com/baeldung/wicket/examples/TestHomePage.java @@ -9,15 +9,15 @@ public class TestHomePage { @Before public void setUp() { - tester = new WicketTester(new ExamplesApplication()); + tester = new WicketTester(new HelloWorldApplication()); } @Test public void whenPageInvoked_thanRenderedOK() { //start and render the test page - tester.startPage(Examples.class); + tester.startPage(HelloWorld.class); //assert rendered page class - tester.assertRenderedPage(Examples.class); + tester.assertRenderedPage(HelloWorld.class); } } diff --git a/wicket/src/main/webapp/WEB-INF/web.xml b/wicket/src/main/webapp/WEB-INF/web.xml index 8a4451c80e..8fc1b1aa95 100644 --- a/wicket/src/main/webapp/WEB-INF/web.xml +++ b/wicket/src/main/webapp/WEB-INF/web.xml @@ -21,7 +21,7 @@ org.apache.wicket.protocol.http.WicketFilter applicationClassName - com.baeldung.wicket.examples.ExamplesApplication + com.baeldung.wicket.examples.HelloWorldApplication