Skip to content

Commit fd6ee52

Browse files
committed
2014-04-02
1 parent ebc3e0b commit fd6ee52

File tree

20 files changed

+326
-26
lines changed

20 files changed

+326
-26
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#Generated by Maven
2-
#Wed Mar 19 18:16:13 CET 2014
2+
#Wed Apr 02 15:36:12 CEST 2014
33
version=0.0.1-SNAPSHOT
44
groupId=org.springframework.samples.service.service
55
artifactId=mvc_springapp

Exercises/test-example/.classpath

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<classpath>
3+
<classpathentry kind="src" output="target/classes" path="src/main/java">
4+
<attributes>
5+
<attribute name="optional" value="true"/>
6+
<attribute name="maven.pomderived" value="true"/>
7+
</attributes>
8+
</classpathentry>
9+
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
10+
<attributes>
11+
<attribute name="optional" value="true"/>
12+
<attribute name="maven.pomderived" value="true"/>
13+
</attributes>
14+
</classpathentry>
15+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5">
16+
<attributes>
17+
<attribute name="maven.pomderived" value="true"/>
18+
</attributes>
19+
</classpathentry>
20+
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
21+
<attributes>
22+
<attribute name="maven.pomderived" value="true"/>
23+
</attributes>
24+
</classpathentry>
25+
<classpathentry kind="output" path="target/classes"/>
26+
</classpath>

Exercises/test-example/.project

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>test-example</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.eclipse.jdt.core.javabuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
<buildCommand>
14+
<name>org.eclipse.m2e.core.maven2Builder</name>
15+
<arguments>
16+
</arguments>
17+
</buildCommand>
18+
</buildSpec>
19+
<natures>
20+
<nature>org.eclipse.jdt.core.javanature</nature>
21+
<nature>org.eclipse.m2e.core.maven2Nature</nature>
22+
</natures>
23+
</projectDescription>
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
eclipse.preferences.version=1
2+
encoding//src/main/java=UTF-8
3+
encoding//src/test/java=UTF-8
4+
encoding/<project>=UTF-8
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
eclipse.preferences.version=1
2+
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
3+
org.eclipse.jdt.core.compiler.compliance=1.5
4+
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
5+
org.eclipse.jdt.core.compiler.source=1.5
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
activeProfiles=
2+
eclipse.preferences.version=1
3+
resolveWorkspaceProjects=true
4+
version=1

Exercises/test-example/pom.xml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
5+
<groupId>pl.krzysh</groupId>
6+
<artifactId>test-example</artifactId>
7+
<version>0.0.1-SNAPSHOT</version>
8+
<packaging>jar</packaging>
9+
10+
<name>test-example</name>
11+
<url>http://maven.apache.org</url>
12+
13+
<properties>
14+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
15+
</properties>
16+
17+
<dependencies>
18+
<dependency>
19+
<groupId>junit</groupId>
20+
<artifactId>junit</artifactId>
21+
<version>4.8.2</version>
22+
<scope>test</scope>
23+
</dependency>
24+
</dependencies>
25+
</project>
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package pl.krzysh.test_example;
2+
3+
public class Account {
4+
private int money = 0;
5+
6+
public void addMoney(int i) {
7+
money += i;
8+
}
9+
10+
public int getMoney() {
11+
return money;
12+
}
13+
14+
public void removeMoney(int i) {
15+
money -= i;
16+
}
17+
18+
@Override
19+
public int hashCode() {
20+
final int prime = 31;
21+
int result = 1;
22+
result = prime * result + money;
23+
return result;
24+
}
25+
26+
@Override
27+
public boolean equals(Object obj) {
28+
if (this == obj)
29+
return true;
30+
if (obj == null)
31+
return false;
32+
if (getClass() != obj.getClass())
33+
return false;
34+
Account other = (Account) obj;
35+
if (money != other.money)
36+
return false;
37+
return true;
38+
}
39+
40+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package pl.krzysh.test_example;
2+
3+
/**
4+
* Hello world!
5+
*
6+
*/
7+
public class App
8+
{
9+
public static void main( String[] args )
10+
{
11+
System.out.println( "Hello World!" );
12+
}
13+
14+
public int dodaj(int a, int b) {
15+
return a+b;
16+
}
17+
}
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
package pl.krzysh.test_example;
2+
3+
import static org.junit.Assert.*;
4+
5+
import java.util.Arrays;
6+
7+
import org.junit.Before;
8+
import org.junit.Test;
9+
10+
public class AppTest
11+
{
12+
App app;
13+
14+
@Before
15+
public void setUp()
16+
{
17+
app = new App();
18+
}
19+
20+
@Test
21+
public void testApp()
22+
{
23+
assertTrue( true );
24+
}
25+
26+
@Test
27+
public void testCalulations()
28+
{
29+
assertEquals(4, app.dodaj(2, 2));
30+
assertNotSame(4, app.dodaj(2, 3));
31+
}
32+
33+
@Test
34+
public void testAccount()
35+
{
36+
Account account = new Account();
37+
assertEquals(0, account.getMoney());
38+
account.addMoney(50);
39+
assertEquals(50, account.getMoney());
40+
assertNotSame(0, account.getMoney());
41+
account.removeMoney(25);
42+
assertEquals(25, account.getMoney());
43+
assertNotSame(50, account.getMoney());
44+
}
45+
46+
@Test
47+
public void testAccountArray()
48+
{
49+
Account[] accounts1 = new Account[2];
50+
accounts1[0] = new Account();
51+
accounts1[1] = new Account();
52+
Account[] accounts2 = new Account[2];
53+
accounts2[0] = new Account();
54+
accounts2[1] = new Account();
55+
assertTrue(Arrays.equals(accounts1, accounts2));
56+
accounts1[0].addMoney(15);
57+
assertFalse(Arrays.equals(accounts1, accounts2));
58+
}
59+
60+
@Test(expected = ArithmeticException.class)
61+
public void testExceptions()
62+
{
63+
int i = 5/0;
64+
}
65+
}

0 commit comments

Comments
 (0)