Skip to content

Commit 52911fe

Browse files
varomorfpivovarit
authored andcommitted
Remove module and try-catch (eugenp#701)
* Add new module for mocks comparison. * Add sources for testing. * Changes on testCase. * Enter some tests for mockito. * More tests for Mockito. * Even more tests. * Add the rest of the mocking libraries. * Javadoc on test. * Test bare bones for EasyMock. * Fist kind of test and setup. * Add tests using EasyMock with a change on LoginService. * Create LoginControllerTest.java * Test setup * [JMockit] No method called test. * [JMockit] Two methods called test. * [JMockit] One method called test. * [JMockit] Exception mock test * [JMockit] Mocked object to pass around test. * [JMockit] Custom matcher test. * [JMockit] Partial mocking test. * [JMockit] Fix with IDE. * Not stubs. Mocks. MOCKS!!! * Remove unnecesary import. * Use correct encoding. Was having problems with buildings. * Remove failing module. * Create new module mocks and move mock-comparisons there. * Add jmockit module. * Add model class. * Add collaborator class. * Add performer class. * Add performer test. * Fix * Add interface for tests. * Test for any. * Test for with. * Test for null. * Test for times. * Test for arg that. * Test for result and returns. * Test for delegate. * Add verifications to any tests. * Add verifications to with test. * Add verification examples to methods using null. * Add verifications to methods using times. * Formatting. * Compress tests and fix one test. * Adding new article to readme. * [BAEL-178] Add collaborator for advanced article. * [BAEL-178] Add link to readme. * [BAEL-178] Add test for mockUp. * [BAEL-178] Add test for invoke method. * [BAEL-178] Add constructors and tests for mockup for constructors. * [BAEL-178] Add private fields and more test for deencapsulation. * [BAEL-178] Add inner class and test for instantiating inner classes. * [BAEL-178] Multimocks. * [BAEL-178] Add test for expectation reusing. * [BAEL-178] Move test class to tests folders. * Add postgresql dependency. * Add test and config with properties. * [BAEL-114] Add new project for JPA with JNDI. * [BAEL-114] Config without xml. * [BAEL-114] Bring part of Foo, FooServie and FooDao. * [BAEL-114] Show all foos. * [BAEL-114] Readme. * [BAEL-114] Undo changes on main jpa project. * [BAEL-114] Remove unnecesary dependencies. * [BAEL-114] Add tomcat config. * [BAEL-114] Fixes. * Add tests for Optional streams. * Add Java 9 version of the test. * Rename and move to new core-java-9 module. * Move contents from spring-jpa-jndi to spring-jpa and make necessary changes. * Do not use try-catch on configuration.
1 parent eae09bb commit 52911fe

16 files changed

Lines changed: 36 additions & 270 deletions

File tree

‎spring-jpa-jndi/.gitignore‎

Lines changed: 0 additions & 13 deletions
This file was deleted.

‎spring-jpa-jndi/README.md‎

Lines changed: 0 additions & 7 deletions
This file was deleted.

‎spring-jpa-jndi/pom.xml‎

Lines changed: 0 additions & 145 deletions
This file was deleted.

‎spring-jpa-jndi/src/main/java/org/baeldung/persistence/dao/FooDao.java‎

Lines changed: 0 additions & 22 deletions
This file was deleted.

‎spring-jpa-jndi/src/main/java/org/baeldung/persistence/model/Foo.java‎

Lines changed: 0 additions & 34 deletions
This file was deleted.

‎spring-jpa-jndi/src/main/java/org/baeldung/persistence/service/FooService.java‎

Lines changed: 0 additions & 22 deletions
This file was deleted.

‎spring-jpa-jndi/src/main/resources/logback.xml‎

Lines changed: 0 additions & 20 deletions
This file was deleted.

‎spring-jpa/pom.xml‎

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
<groupId>com.baeldung</groupId>
55
<artifactId>spring-jpa</artifactId>
66
<version>0.1-SNAPSHOT</version>
7+
<packaging>war</packaging>
78

89
<name>spring-jpa</name>
910

@@ -21,6 +22,11 @@
2122
<artifactId>spring-context</artifactId>
2223
<version>${org.springframework.version}</version>
2324
</dependency>
25+
<dependency>
26+
<groupId>org.springframework</groupId>
27+
<artifactId>spring-webmvc</artifactId>
28+
<version>${org.springframework.version}</version>
29+
</dependency>
2430

2531
<!-- persistence -->
2632

@@ -73,6 +79,18 @@
7379
<artifactId>javax.el-api</artifactId>
7480
<version>2.2.5</version>
7581
</dependency>
82+
83+
<!-- web -->
84+
<dependency>
85+
<groupId>javax.servlet</groupId>
86+
<artifactId>jstl</artifactId>
87+
<version>${javax.servlet.jstl.version}</version>
88+
</dependency>
89+
<dependency>
90+
<groupId>javax.servlet</groupId>
91+
<artifactId>servlet-api</artifactId>
92+
<version>${javax.servlet.servlet-api.version}</version>
93+
</dependency>
7694

7795
<!-- utils -->
7896

@@ -147,6 +165,16 @@
147165
<target>1.8</target>
148166
</configuration>
149167
</plugin>
168+
169+
<plugin>
170+
<groupId>org.apache.maven.plugins</groupId>
171+
<artifactId>maven-war-plugin</artifactId>
172+
<version>${maven-war-plugin.version}</version>
173+
<configuration>
174+
<warSourceDirectory>src/main/webapp</warSourceDirectory>
175+
<failOnMissingWebXml>false</failOnMissingWebXml>
176+
</configuration>
177+
</plugin>
150178

151179
<plugin>
152180
<groupId>org.apache.maven.plugins</groupId>
@@ -197,6 +225,10 @@
197225
<mysql-connector-java.version>5.1.38</mysql-connector-java.version>
198226
<spring-data-jpa.version>1.10.2.RELEASE</spring-data-jpa.version>
199227
<h2.version>1.4.192</h2.version>
228+
229+
<!-- web -->
230+
<javax.servlet.jstl.version>1.2</javax.servlet.jstl.version>
231+
<javax.servlet.servlet-api.version>2.5</javax.servlet.servlet-api.version>
200232

201233
<!-- logging -->
202234
<org.slf4j.version>1.7.13</org.slf4j.version>
@@ -224,6 +256,7 @@
224256
<maven-surefire-plugin.version>2.19.1</maven-surefire-plugin.version>
225257
<maven-resources-plugin.version>2.7</maven-resources-plugin.version>
226258
<cargo-maven2-plugin.version>1.4.18</cargo-maven2-plugin.version>
259+
<maven-war-plugin.version>2.4</maven-war-plugin.version>
227260
<!-- <maven-war-plugin.version>2.6</maven-war-plugin.version> -->
228261

229262
</properties>

spring-jpa-jndi/src/main/java/org/baeldung/config/PersistenceJNDIConfig.java renamed to spring-jpa/src/main/java/org/baeldung/config/PersistenceJNDIConfig.java

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public PersistenceJNDIConfig() {
3636
}
3737

3838
@Bean
39-
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
39+
public LocalContainerEntityManagerFactoryBean entityManagerFactory() throws NamingException {
4040
final LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean();
4141
em.setDataSource(dataSource());
4242
em.setPackagesToScan(new String[] { "org.baeldung.persistence.model" });
@@ -46,12 +46,8 @@ public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
4646
}
4747

4848
@Bean
49-
public DataSource dataSource() {
50-
try {
51-
return (DataSource) new JndiTemplate().lookup(env.getProperty("jdbc.url"));
52-
} catch (NamingException e) {
53-
throw new IllegalArgumentException("Error looking up JNDI datasource", e);
54-
}
49+
public DataSource dataSource() throws NamingException {
50+
return (DataSource) new JndiTemplate().lookup(env.getProperty("jdbc.url"));
5551
}
5652

5753
@Bean

spring-jpa-jndi/src/main/java/org/baeldung/config/SpringWebConfig.java renamed to spring-jpa/src/main/java/org/baeldung/config/SpringWebConfig.java

File renamed without changes.

0 commit comments

Comments
 (0)