forked from AntonioTrovato/GradleProject
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 7a55b5a
Showing
20 changed files
with
966 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Auto detect text files and perform LF normalization | ||
* text=auto |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
.gradle | ||
build/ | ||
!gradle/wrapper/gradle-wrapper.jar | ||
!**/src/main/**/build/ | ||
!**/src/test/**/build/ | ||
|
||
### IntelliJ IDEA ### | ||
.idea/modules.xml | ||
.idea/jarRepositories.xml | ||
.idea/compiler.xml | ||
.idea/libraries/ | ||
*.iws | ||
*.iml | ||
*.ipr | ||
out/ | ||
!**/src/main/**/out/ | ||
!**/src/test/**/out/ | ||
|
||
### Eclipse ### | ||
.apt_generated | ||
.classpath | ||
.factorypath | ||
.project | ||
.settings | ||
.springBeans | ||
.sts4-cache | ||
bin/ | ||
!**/src/main/**/bin/ | ||
!**/src/test/**/bin/ | ||
|
||
### NetBeans ### | ||
/nbproject/private/ | ||
/nbbuild/ | ||
/dist/ | ||
/nbdist/ | ||
/.nb-gradle/ | ||
|
||
### VS Code ### | ||
.vscode/ | ||
|
||
### Mac OS ### | ||
.DS_Store |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
Using: java 17.0.10 e gradle 7.4.2 | ||
|
||
Build the ju2jmh tool (In the Tool Root): | ||
gradle build | ||
|
||
New Gradle Project using Kotling language | ||
Make 2 subproject: | ||
GradleProject | ||
|--app (build.gradle.kts must have the right dependencies for junit 4.13.2) | ||
|--src/main/java/(containing packages of classes) | ||
|--src/test/java/(containing packages of test classes) | ||
|--ju2jmh | ||
|--src/jmh/java/(containing packages of benchmarks) | ||
|--src/main/java/ | ||
|--src/test/java/ | ||
|
||
the ju2jmh/src/jmh/java and ju2jmh/src/jmh/resources folders must be created by hand, then run the build.gradle.kts (using id("me.champeau.jmh") version "0.6.6" as plugin and the needed dependencies) | ||
packages must have the same name and be organized the same way for each module | ||
|
||
build GradleProject (In the Target Project Root): | ||
gradle build | ||
|
||
remove existent benchmarks (In the Target Project Root): | ||
rm -r ju2jmh/src/jmh/java/* | ||
|
||
re-build GradleProject (In the Target Project Root): | ||
gradle clean | ||
gradle build | ||
|
||
run generation | ||
gradle converter:run --args="C:/Users/anton/Documents/IntellijProjects/GradleProject/app/src/test/java/ C:/Users/anton/Documents/IntellijProjects/GradleProject/app/build/classes/java/test/ C:/Users/anton/Documents/IntellijProjects/GradleProject/ju2jmh/src/jmh/java/ banca.ContoBancario" | ||
|
||
build benchmarks (In the Target Project Root): | ||
gradle jmhJar | ||
|
||
list avaible benchmarks: | ||
java -jar C:/Users/anton/Documents/IntellijProjects/GradleProject/ju2jmh/build/libs/ju2jmh-jmh.jar -l | ||
|
||
run benchmarks (first way): | ||
use the jmh task in the gradle menu under ju2jmh opening GradleProject with IntelliJ | ||
|
||
run the benchmarks (second way): | ||
java -jar C:/Users/anton/Documents/IntellijProjects/GradleProject/ju2jmh/build/libs/ju2jmh-jmh.jar -f 1 -wi 0 -i 1 -r 100ms -foe true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
plugins { | ||
java | ||
} | ||
|
||
dependencies { | ||
testImplementation("junit:junit:4.13.2") | ||
} | ||
|
||
tasks.named<Test>("test") { | ||
useJUnit() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package banca; | ||
|
||
public class ContoBancario { | ||
public ContoBancario(String id, int saldo_iniziale) { | ||
this.id = id; | ||
this.saldo = saldo_iniziale; | ||
} | ||
|
||
public String getId() { | ||
return id; | ||
} | ||
|
||
public int getSaldo() { | ||
return saldo; | ||
} | ||
|
||
public void setId(String id) { | ||
this.id = id; | ||
} | ||
|
||
public void setSaldo(int saldo) { | ||
this.saldo = saldo; | ||
} | ||
|
||
public void versamento(int quota) { | ||
this.saldo += quota; | ||
} | ||
|
||
public int prelievo(int quota) { | ||
if (this.saldo < quota) | ||
return 0; | ||
else | ||
this.saldo -= quota; | ||
return 1; | ||
} | ||
|
||
private String id; | ||
private int saldo; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package banca; | ||
|
||
import banca.ContoBancario; | ||
import org.junit.Test; | ||
import static org.junit.Assert.*; | ||
|
||
public class ContoBancarioTest { | ||
|
||
@Test | ||
public void testVersamento() { | ||
ContoBancario conto = new ContoBancario("123", 100); | ||
conto.versamento(50); | ||
assertEquals(150, conto.getSaldo()); | ||
} | ||
|
||
@Test | ||
public void testPrelievo_SufficienteSaldo() { | ||
ContoBancario conto = new ContoBancario("123", 100); | ||
int result = conto.prelievo(50); | ||
assertEquals(1, result); | ||
assertEquals(50, conto.getSaldo()); | ||
} | ||
|
||
@Test | ||
public void testPrelievo_InsufficienteSaldo() { | ||
ContoBancario conto = new ContoBancario("123", 100); | ||
int result = conto.prelievo(150); | ||
assertEquals(0, result); | ||
assertEquals(100, conto.getSaldo()); | ||
} | ||
|
||
@Test | ||
public void testGetId() { | ||
ContoBancario conto = new ContoBancario("123", 100); | ||
assertEquals("123", conto.getId()); | ||
} | ||
|
||
@Test | ||
public void testSetId() { | ||
ContoBancario conto = new ContoBancario("123", 100); | ||
conto.setId("456"); | ||
assertEquals("456", conto.getId()); | ||
} | ||
|
||
@Test | ||
public void testGetSaldo() { | ||
ContoBancario conto = new ContoBancario("123", 100); | ||
assertEquals(100, conto.getSaldo()); | ||
} | ||
|
||
@Test | ||
public void testSetSaldo() { | ||
ContoBancario conto = new ContoBancario("123", 100); | ||
conto.setSaldo(200); | ||
assertEquals(200, conto.getSaldo()); | ||
} | ||
} |
Oops, something went wrong.