Merge remote-tracking branch 'upstream/master'
This commit is contained in:
commit
9eab427cf4
|
@ -1,3 +1,4 @@
|
||||||
###Relevant Articles:
|
###Relevant Articles:
|
||||||
- [A Guide to the Front Controller Pattern in Java](http://www.baeldung.com/java-front-controller-pattern)
|
- [A Guide to the Front Controller Pattern in Java](http://www.baeldung.com/java-front-controller-pattern)
|
||||||
- [Introduction to Intercepting Filter Pattern in Java](http://www.baeldung.com/intercepting-filter-pattern-in-java)
|
- [Introduction to Intercepting Filter Pattern in Java](http://www.baeldung.com/intercepting-filter-pattern-in-java)
|
||||||
|
- [Implementing the Template Method Pattern in Java](http://www.baeldung.com/template-method-pattern-in-java)
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
<modules>
|
<modules>
|
||||||
<module>front-controller</module>
|
<module>front-controller</module>
|
||||||
<module>intercepting-filter</module>
|
<module>intercepting-filter</module>
|
||||||
|
<module>template-method</module>
|
||||||
</modules>
|
</modules>
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
|
@ -51,4 +52,4 @@
|
||||||
<maven-war-plugin.version>3.0.0</maven-war-plugin.version>
|
<maven-war-plugin.version>3.0.0</maven-war-plugin.version>
|
||||||
<jetty-maven-plugin.version>9.4.0.v20161208</jetty-maven-plugin.version>
|
<jetty-maven-plugin.version>9.4.0.v20161208</jetty-maven-plugin.version>
|
||||||
</properties>
|
</properties>
|
||||||
</project>
|
</project>
|
|
@ -1,15 +1,17 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>com.baeldung.templatemethodpattern</groupId>
|
<groupId>com.baeldung.templatemethod</groupId>
|
||||||
<artifactId>templatemethodpattern</artifactId>
|
<artifactId>template-method</artifactId>
|
||||||
<version>1.0</version>
|
<version>1.0</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
<properties>
|
<parent>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<groupId>com.baeldung.patterns</groupId>
|
||||||
<maven.compiler.source>1.8</maven.compiler.source>
|
<artifactId>patterns-parent</artifactId>
|
||||||
<maven.compiler.target>1.8</maven.compiler.target>
|
<version>1.0.0-SNAPSHOT</version>
|
||||||
</properties>
|
<relativePath>..</relativePath>
|
||||||
|
</parent>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>junit</groupId>
|
<groupId>junit</groupId>
|
||||||
|
@ -18,4 +20,18 @@
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<version>3.7.0</version>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
<properties>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
<maven.compiler.source>1.8</maven.compiler.source>
|
||||||
|
<maven.compiler.target>1.8</maven.compiler.target>
|
||||||
|
</properties>
|
||||||
</project>
|
</project>
|
|
@ -0,0 +1,10 @@
|
||||||
|
package org.baeldung.mockito;
|
||||||
|
|
||||||
|
public class FinalList extends MyList {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int size() {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,35 @@
|
||||||
|
package org.baeldung.mockito;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertNotEquals;
|
||||||
|
import static org.mockito.Mockito.mock;
|
||||||
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
|
public class MockFinals {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void whenMockFinalClassMockWorks() {
|
||||||
|
|
||||||
|
FinalList finalList = new FinalList();
|
||||||
|
|
||||||
|
FinalList mock = mock(FinalList.class);
|
||||||
|
when(mock.size()).thenReturn(2);
|
||||||
|
|
||||||
|
assertNotEquals(mock.size(), finalList.size());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void whenMockFinalMethodMockWorks() {
|
||||||
|
|
||||||
|
MyList myList = new MyList();
|
||||||
|
|
||||||
|
MyList mock = mock(MyList.class);
|
||||||
|
when(mock.finalMethod()).thenReturn(1);
|
||||||
|
|
||||||
|
assertNotEquals(mock.finalMethod(), myList.finalMethod());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -19,4 +19,7 @@ class MyList extends AbstractList<String> {
|
||||||
// no-op
|
// no-op
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final public int finalMethod() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
mock-maker-inline
|
Loading…
Reference in New Issue