Skip to content

Commit 2cf3e54

Browse files
committed
Merge branch 'master' of github.com:nurous/java-koans
Conflicts: README.md koans-lib/src/com/sandwich/koan/runner/RunKoans.java koans/README.md koans/lib/koans.jar
2 parents 6dbc533 + 81d3817 commit 2cf3e54

30 files changed

Lines changed: 525 additions & 233 deletions

‎README.md‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ https://github.com/matyb/java-koans/archives/master
1414

1515
Developing a Koan:
1616
==================
17+
<<<<<<< HEAD
1718
* Follow any of the existing koans as an example to create a new class with koan methods (indicated by the @Koan annotation, they're public and specify no arguments)
1819
* Define the order the koan suite (if it's new) will run in the koans/config/PathToEnlightenment.xml file
1920
* Optionally you may use dynamic content in your lesson, examples are located in the XmlVariableInjector class (and Test) and the AboutKoans.java file
21+
=======
22+
1. Follow any of the existing koans as an example to create a new class w/ koan methods (indicated by the @Koan annotation)
23+
2. Define the order and metadata associated with each koan in the PathToEnlightenment.xml
24+
3. If necessary - use dynamic content in your lesson, examples are located in XmlVariableInjector class (and Test) and the AboutKoans.java file
25+
>>>>>>> 81d381746890bea20bccf589fa8e5ed63a9ec90b

‎koans-lib/src/com/sandwich/koan/cmdline/CommandLineArgumentBuilder.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public CommandLineArgumentBuilder(String...args){
3636
// - in other words, argumentType will be argumentTypePlusOne in next iteration
3737
continue;
3838
}
39-
// ok 2nd argument wasn't a recongized argument type - go
39+
// ok 2nd argument wasn't a recognized argument type - go
4040
// ahead and see if it's a class, if not, it must be a
4141
// method - or bogus
4242
else if(stringArgPlusOne != null){

‎koans-lib/src/com/sandwich/koan/path/PathToEnlightenment.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public static void filterByKoan(String koan){
6060
xmlToPathTransformer = null;
6161
}
6262

63-
public static Path getPathToEnlightment(){
63+
public static Path getPathToEnlightenment(){
6464
if(theWay == null){
6565
theWay = createPath();
6666
}

‎koans-lib/src/com/sandwich/koan/runner/RunKoans.java‎

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,16 +49,20 @@ KoanSuiteResult runKoans() {
4949
String level = null;
5050
KoanMethodResult failure = null;
5151
DynamicClassLoader loader = new DynamicClassLoader();
52-
Path pathToEnlightement = getPathToEnlightement();
52+
Path pathToEnlightenment = getPathToEnlightenment();
5353
KoanSuiteCompilationListener compilationListener = new KoanSuiteCompilationListener();
54+
<<<<<<< HEAD
5455
int successfull = 0;
5556
for (Entry<String, Map<String, Map<String, KoanElementAttributes>>> packages : pathToEnlightement) {
57+
=======
58+
for (Entry<String, Map<String, Map<String, KoanElementAttributes>>> packages : pathToEnlightenment) {
59+
>>>>>>> 81d381746890bea20bccf589fa8e5ed63a9ec90b
5660
for (Entry<String, Map<String, KoanElementAttributes>> e : packages.getValue().entrySet()) {
5761
String name = e.getKey().substring(e.getKey().lastIndexOf('.')+1);
5862
if(failure == null){
5963
Object suite = safelyConstructSuite(loader, compilationListener, e);
6064
final List<KoanElementAttributes> attributes = new ArrayList<KoanElementAttributes>(e.getValue().values());
61-
final List<KoanMethod> methods = mergeJavaFilesMethodsAndThoseInXml(suite, attributes, pathToEnlightement.getOnlyMethodNameToRun());
65+
final List<KoanMethod> methods = mergeJavaFilesMethodsAndThoseInXml(suite, attributes, pathToEnlightenment.getOnlyMethodNameToRun());
6266
Collections.sort(methods, new KoanComparator());
6367
for (final KoanMethod koan : methods) {
6468
KoanMethodResult result = KoanMethodRunner.run(suite, koan);
@@ -81,8 +85,13 @@ KoanSuiteResult runKoans() {
8185
}
8286
}
8387
return new KoanResultBuilder() .level(level)
88+
<<<<<<< HEAD
8489
.numberPassing(successfull)
8590
.totalNumberOfKoanMethods(pathToEnlightement.getTotalNumberOfKoans())
91+
=======
92+
.numberPassing((int)successfull.getCount())
93+
.totalNumberOfKoanMethods(pathToEnlightenment.getTotalNumberOfKoans())
94+
>>>>>>> 81d381746890bea20bccf589fa8e5ed63a9ec90b
8695
.methodResult(failure)
8796
.passingCases(passingSuites).remainingCases(failingSuites).build();
8897
}
@@ -166,9 +175,9 @@ private Object constructSuite(DynamicClassLoader loader, String className, Compi
166175
return suite;
167176
}
168177

169-
private Path getPathToEnlightement() {
178+
private Path getPathToEnlightenment() {
170179
if(pathToEnlightenment == null){
171-
pathToEnlightenment = PathToEnlightenment.getPathToEnlightment();
180+
pathToEnlightenment = PathToEnlightenment.getPathToEnlightenment();
172181
}
173182
return pathToEnlightenment;
174183
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
package com.sandwich.util;
2+
3+
import java.util.ArrayList;
4+
import java.util.List;
5+
6+
import static com.sandwich.util.Assert.fail;
7+
8+
public class TypeUtils {
9+
10+
public static Class<?> getType(int value) {
11+
return int.class;
12+
}
13+
14+
public static Class<?> getType(long value) {
15+
return long.class;
16+
}
17+
18+
public static Class<?> getType(float value) {
19+
return float.class;
20+
}
21+
22+
public static Class<?> getType(double value) {
23+
return double.class;
24+
}
25+
26+
public static Class<?> getType(byte value) {
27+
return byte.class;
28+
}
29+
30+
public static Class<?> getType(char value) {
31+
return char.class;
32+
}
33+
34+
public static Class<?> getType(short value) {
35+
return short.class;
36+
}
37+
38+
public static Class<?> getType(Object value) {
39+
return value.getClass();
40+
}
41+
42+
public static Class[] ancestors(Object object) {
43+
List<Class> ancestors = new ArrayList<Class>();
44+
Class clazz = object.getClass();
45+
while(clazz != null) {
46+
ancestors.add(clazz);
47+
clazz = clazz.getSuperclass();
48+
}
49+
return ancestors.toArray(new Class[]{});
50+
}
51+
}

‎koans-tests/data/src/com/sandwich/koan/path/CommandLineTestCase.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ protected void setRealPath(){
5555
}
5656

5757
protected Path stubAllKoans(String packageName, List<String> path){
58-
Path oldKoans = PathToEnlightenment.getPathToEnlightment();
58+
Path oldKoans = PathToEnlightenment.getPathToEnlightenment();
5959
Map<String, Map<String, KoanElementAttributes>> tempSuitesAndMethods =
6060
new LinkedHashMap<String, Map<String, KoanElementAttributes>>();
6161
DynamicClassLoader loader = new DynamicClassLoader();

‎koans-tests/data/src/com/sandwich/koan/path/DefaultKoanDescriptionTest.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public void tearDown(){
2828
public void defaultKoanDescriptions() throws Exception {
2929
StringBuilder exceptionStringBuilder = new StringBuilder(KoanConstants.EOL);
3030
for (Entry<String, Map<String, KoanElementAttributes>> suiteAndKoans :
31-
PathToEnlightenment.getPathToEnlightment().getKoanMethodsBySuiteByPackage().next().getValue().entrySet()) {
31+
PathToEnlightenment.getPathToEnlightenment().getKoanMethodsBySuiteByPackage().next().getValue().entrySet()) {
3232
for(Entry<String, KoanElementAttributes> koanEntry : suiteAndKoans.getValue().entrySet()){
3333
KoanMethod koan = KoanMethod.getInstance(koanEntry.getValue());
3434
Koan annotation = koan.getMethod().getAnnotation(Koan.class);

‎koans-tests/data/src/com/sandwich/koan/runner/AppReadinessForDeploymentTest.java‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public static class TwoFailingKoans extends OneFailingKoan {
7171
@Test
7272
public void testGetKoans() throws Exception {
7373
stubAllKoans(Arrays.asList(new OnePassingKoan()));
74-
Map<String, Map<String, KoanElementAttributes>> koans = PathToEnlightenment.getPathToEnlightment().iterator().next().getValue();
74+
Map<String, Map<String, KoanElementAttributes>> koans = PathToEnlightenment.getPathToEnlightenment().iterator().next().getValue();
7575
assertEquals(1, koans.size());
7676
Entry<String, Map<String, KoanElementAttributes>> entry = koans.entrySet().iterator().next();
7777
assertEquals(OnePassingKoan.class.getName(), entry.getKey());
@@ -91,10 +91,10 @@ public void displayResult(KoanSuiteResult actualAppResult) {
9191
};
9292
doAsIfInProd(new Runnable(){
9393
public void run(){
94-
new RunKoans(presenter, PathToEnlightenment.getPathToEnlightment()).run(null);
94+
new RunKoans(presenter, PathToEnlightenment.getPathToEnlightenment()).run(null);
9595
}
9696
});
97-
String firstSuiteClassRan = PathToEnlightenment.getPathToEnlightment()
97+
String firstSuiteClassRan = PathToEnlightenment.getPathToEnlightenment()
9898
.iterator().next().getValue().entrySet().iterator().next().getKey();
9999
assertEquals(result[0].getFailingCase(), firstSuiteClassRan.substring(firstSuiteClassRan.lastIndexOf(".") + 1));
100100
}
@@ -111,7 +111,7 @@ public void displayResult(KoanSuiteResult actualAppResult) {
111111
};
112112
doAsIfInProd(new Runnable(){
113113
public void run(){
114-
new RunKoans(presenter, PathToEnlightenment.getPathToEnlightment()).run(null);
114+
new RunKoans(presenter, PathToEnlightenment.getPathToEnlightenment()).run(null);
115115
}
116116
});
117117
String message = "Not all koans need solving! Each should ship in a failing state.";

‎koans-tests/data/src/com/sandwich/koan/runner/CommandLineTestCaseTest.java‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -73,25 +73,25 @@ public void testThatTearDownDetachesDummiedConsoleFromSystem(){
7373

7474
@Test
7575
public void testThatStubAllKoansStubsAllKoansReference() throws Exception {
76-
Path oldKoans = PathToEnlightenment.getPathToEnlightment();
76+
Path oldKoans = PathToEnlightenment.getPathToEnlightenment();
7777
List<Object> newKoans = Collections.emptyList();
7878
testCase.stubAllKoans(newKoans);
79-
assertNotSame(oldKoans, PathToEnlightenment.getPathToEnlightment());
79+
assertNotSame(oldKoans, PathToEnlightenment.getPathToEnlightenment());
8080
// number of suites
81-
assertEquals(0, PathToEnlightenment.getPathToEnlightment()
81+
assertEquals(0, PathToEnlightenment.getPathToEnlightenment()
8282
.iterator().next().getValue().size());
8383
}
8484

8585
@Test
8686
public void testTestCaseRestoresAllKoansReference() throws Exception {
87-
Path oldKoans = PathToEnlightenment.getPathToEnlightment();
87+
Path oldKoans = PathToEnlightenment.getPathToEnlightenment();
8888
List<Object> newKoans = Collections.emptyList();
8989
testCase.stubAllKoans(newKoans);
90-
assertNotSame(oldKoans, PathToEnlightenment.getPathToEnlightment());
90+
assertNotSame(oldKoans, PathToEnlightenment.getPathToEnlightenment());
9191
testCase.tearDown();
9292
// creates all new instance
93-
assertNotSame(oldKoans, PathToEnlightenment.getPathToEnlightment());
94-
assertEquals(oldKoans, PathToEnlightenment.getPathToEnlightment());
93+
assertNotSame(oldKoans, PathToEnlightenment.getPathToEnlightenment());
94+
assertEquals(oldKoans, PathToEnlightenment.getPathToEnlightenment());
9595
}
9696

9797
@Test

‎koans-tests/test/com/sandwich/koan/TestUtilsTest.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ public void testForEachLine_emptyString() throws Exception {
377377
}
378378

379379
@Test
380-
public void testForEachLine_nothingThreeNewLinesSeperatedBy1Space() throws Exception {
380+
public void testForEachLine_nothingThreeNewLinesSeparatedBy1Space() throws Exception {
381381
@SuppressWarnings("unchecked")
382382
ArgRunner<String> runner = EasyMock.createStrictMock(ArgRunner.class);
383383

@@ -400,7 +400,7 @@ public void testForEachLine_nothingThreeNewLinesSeperatedBy1Space() throws Excep
400400
}
401401

402402
@Test
403-
public void testForEachLine_nothingThreeNewLinesSeperatedBy1SpaceThen2Spaces() throws Exception {
403+
public void testForEachLine_nothingThreeNewLinesSeparatedBy1SpaceThen2Spaces() throws Exception {
404404
@SuppressWarnings("unchecked")
405405
ArgRunner<String> runner = EasyMock.createStrictMock(ArgRunner.class);
406406

0 commit comments

Comments
 (0)