Skip to content

Commit 3f55dcb

Browse files
committed
general cleanup
1 parent 1666b59 commit 3f55dcb

6 files changed

Lines changed: 114 additions & 78 deletions

File tree

koans-tests/test/com/sandwich/koan/runner/AppReadinessForDeploymentTest.java

Lines changed: 99 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -30,133 +30,168 @@
3030
import com.sandwich.koan.ui.SuitePresenter;
3131

3232
/**
33-
* Anything that absoutely has to happen before bundling client jar - to be sure:
34-
* - all koans fail by default
35-
* - necessary aspects of app presentation are preserved
36-
* - progression through koans (the sequence of koans) is consistent
33+
* Anything that absoutely has to happen before bundling client jar - to be
34+
* sure: - all koans fail by default - necessary aspects of app presentation are
35+
* preserved - progression through koans (the sequence of koans) is consistent
3736
*/
3837
public class AppReadinessForDeploymentTest extends CommandLineTestCase {
39-
38+
4039
@Test
41-
public void testMainMethodWithClassNameArg_qualifiedWithPkgName() throws Throwable {
40+
public void testMainMethodWithClassNameArg_qualifiedWithPkgName()
41+
throws Throwable {
4242
stubAllKoans(Arrays.asList(new OnePassingKoan()));
4343
new KoanSuiteRunner().run();
44-
assertSystemOutContains(KoanConstants.PASSING_SUITES+" "+OnePassingKoan.class.getSimpleName());
44+
assertSystemOutContains(KoanConstants.PASSING_SUITES + " "
45+
+ OnePassingKoan.class.getSimpleName());
4546
}
4647

4748
@Test
48-
public void testMainMethodWithClassNameArg_classSimpleName() throws Throwable {
49+
public void testMainMethodWithClassNameArg_classSimpleName()
50+
throws Throwable {
4951
stubAllKoans(Arrays.asList(new OnePassingKoan()));
5052
new KoanSuiteRunner().run();
51-
assertSystemOutContains(KoanConstants.PASSING_SUITES+" "+OnePassingKoan.class.getSimpleName());
53+
assertSystemOutContains(KoanConstants.PASSING_SUITES + " "
54+
+ OnePassingKoan.class.getSimpleName());
5255
}
53-
56+
5457
@Test
55-
public void testMainMethodWithClassNameArg_classNameAndMethod() throws Throwable {
56-
String failingKoanMethodName = TwoFailingKoans.class.getDeclaredMethod("koanTwo").getName();
58+
public void testMainMethodWithClassNameArg_classNameAndMethod()
59+
throws Throwable {
60+
String failingKoanMethodName = TwoFailingKoans.class.getDeclaredMethod(
61+
"koanTwo").getName();
5762
stubAllKoans(Arrays.asList(new TwoFailingKoans()));
5863
new KoanSuiteRunner().run();
5964
assertSystemOutContains(failingKoanMethodName);
60-
assertSystemOutDoesntContain(OneFailingKoan.class.getDeclaredMethods()[0].getName());
65+
assertSystemOutDoesntContain(OneFailingKoan.class.getDeclaredMethods()[0]
66+
.getName());
6167
}
62-
68+
6369
public static class TwoFailingKoans extends OneFailingKoan {
6470
@Koan
65-
public void koanTwo(){assertEquals(true, false);}
71+
public void koanTwo() {
72+
assertEquals(true, false);
73+
}
6674
}
67-
75+
6876
@Test
6977
public void testGetKoans() throws Exception {
7078
stubAllKoans(Arrays.asList(new OnePassingKoan()));
71-
Map<Object, List<KoanMethod>> koans = PathToEnlightenment.getPathToEnlightment()
72-
.iterator().next().getValue();
79+
Map<Object, List<KoanMethod>> koans = PathToEnlightenment
80+
.getPathToEnlightment().iterator().next().getValue();
7381
assertEquals(1, koans.size());
74-
Entry<Object, List<KoanMethod>> entry = koans.entrySet().iterator().next();
82+
Entry<Object, List<KoanMethod>> entry = koans.entrySet().iterator()
83+
.next();
7584
assertEquals(OnePassingKoan.class, entry.getKey().getClass());
76-
assertEquals(OnePassingKoan.class.getDeclaredMethod("koan"), entry.getValue().get(0).getMethod());
85+
assertEquals(OnePassingKoan.class.getDeclaredMethod("koan"), entry
86+
.getValue().get(0).getMethod());
7787
}
78-
79-
@Test /** Ensures that koans are ready for packaging & distribution */
88+
89+
@Test
90+
/** Ensures that koans are ready for packaging & distribution */
8091
public void testKoanSuiteRunner_firstKoanFail() throws Exception {
81-
final KoanSuiteResult[] result = new KoanSuiteResult[]{null};
82-
final SuitePresenter presenter = new SuitePresenter(){
92+
final KoanSuiteResult[] result = new KoanSuiteResult[] { null };
93+
final SuitePresenter presenter = new SuitePresenter() {
8394
public void displayResult(KoanSuiteResult actualAppResult) {
84-
// don't display, capture them so we can analyze and ensure first failure is reported
95+
// don't display, capture them so we can analyze and ensure
96+
// first failure is reported
8597
result[0] = actualAppResult;
8698
}
8799
};
88-
new RunKoans(presenter, PathToEnlightenment.getPathToEnlightment()).run(null);
89-
assertEquals(result[0].getFailingCase(), PathToEnlightenment.getPathToEnlightment()
90-
.iterator().next().getValue().entrySet().iterator().next().getKey().getClass());
100+
new RunKoans(presenter, PathToEnlightenment.getPathToEnlightment())
101+
.run(null);
102+
assertEquals(result[0].getFailingCase(), PathToEnlightenment
103+
.getPathToEnlightment().iterator().next().getValue().entrySet()
104+
.iterator().next().getKey().getClass());
91105
}
92-
93-
@Test /** Ensures that koans are ready for packaging & distribution */
106+
107+
@Test
108+
/** Ensures that koans are ready for packaging & distribution */
94109
public void testKoanSuiteRunner_allKoansFail() throws Exception {
95-
final KoanSuiteResult[] result = new KoanSuiteResult[]{null};
96-
final SuitePresenter presenter = new SuitePresenter(){
110+
final KoanSuiteResult[] result = new KoanSuiteResult[] { null };
111+
final SuitePresenter presenter = new SuitePresenter() {
97112
public void displayResult(KoanSuiteResult actualAppResult) {
98-
// don't display, capture them so we can analyze and ensure first failure is reported
113+
// don't display, capture them so we can analyze and ensure
114+
// first failure is reported
99115
result[0] = actualAppResult;
100116
}
101117
};
102-
new RunKoans(presenter, PathToEnlightenment.getPathToEnlightment()).run(null);
118+
new RunKoans(presenter, PathToEnlightenment.getPathToEnlightment())
119+
.run(null);
103120
String message = "Not all koans need solving! Each should ship in a failing state.";
104121
assertEquals(message, 0, result[0].getNumberPassing());
105122
// make sure test was actually useful (ie something actually failed)
106123
assertNotNull(result[0].getFailingCase());
107124
}
108-
109-
@Test
125+
126+
@Test
110127
public void testLineExceptionIsThrownAtIsHintedAt() throws Exception {
111128
stubAllKoans(Arrays.asList(new BlowUpOnLineTen()));
112129
new KoanSuiteRunner(new CommandLineArgumentBuilder()).run();
113130
assertSystemOutContains("Line 10");
114131
assertSystemOutDoesntContain("Line 11");
115132
}
116-
117-
@Test
118-
public void testLineExceptionIsThrownAtIsHintedAtEvenIfThrownFromSuperClass() throws Exception {
133+
134+
@Test
135+
public void testLineExceptionIsThrownAtIsHintedAtEvenIfThrownFromSuperClass()
136+
throws Exception {
119137
stubAllKoans(Arrays.asList(new BlowUpOnLineEleven()));
120138
new KoanSuiteRunner(new CommandLineArgumentBuilder()).run();
121139
assertSystemOutContains("Line 11");
122140
assertSystemOutDoesntContain("Line 10");
123141
}
124-
142+
125143
@Test
126144
public void testWarningFromPlacingExpecationOnWrongSide() throws Throwable {
127145
final String[] message = new String[1];
128146
stubAllKoans(Arrays.asList(new WrongExpectationOrderKoan()));
129-
Logger.getLogger(KoanSuiteRunner.class.getSimpleName()).addHandler(new Handler(){
130-
@Override public void close() throws SecurityException {}
131-
@Override public void flush() {}
132-
@Override public void publish(LogRecord arg0) {
133-
message[0] = arg0.getMessage();
134-
}
135-
});
147+
Logger.getLogger(KoanSuiteRunner.class.getSimpleName()).addHandler(
148+
new Handler() {
149+
@Override
150+
public void close() throws SecurityException {
151+
}
152+
153+
@Override
154+
public void flush() {
155+
}
156+
157+
@Override
158+
public void publish(LogRecord arg0) {
159+
message[0] = arg0.getMessage();
160+
}
161+
});
136162
new KoanSuiteRunner(new CommandLineArgumentBuilder()).run();
137-
assertEquals(new StringBuilder(
138-
WrongExpectationOrderKoan.class.getSimpleName()).append(
139-
".expectationOnLeft ").append(
140-
EXPECTATION_LEFT_ARG).toString()
141-
, message[0]);
163+
assertEquals(
164+
new StringBuilder(
165+
WrongExpectationOrderKoan.class.getSimpleName())
166+
.append(".expectationOnLeft ")
167+
.append(EXPECTATION_LEFT_ARG).toString(), message[0]);
142168
}
143-
169+
144170
@Test
145-
public void testNoWarningFromPlacingExpecationOnRightSide() throws Throwable {
171+
public void testNoWarningFromPlacingExpecationOnRightSide()
172+
throws Throwable {
146173
stubAllKoans(Arrays.asList(new OnePassingKoan()));
147-
Logger.getLogger(KoanSuiteRunner.class.getSimpleName()).addHandler(new Handler(){
148-
@Override public void close() throws SecurityException {}
149-
@Override public void flush() {}
150-
@Override public void publish(LogRecord arg0) {
151-
fail("No logging necessary when koan passes, otherwise - logging is new, adjust accordingly.");
152-
}
153-
});
174+
Logger.getLogger(KoanSuiteRunner.class.getSimpleName()).addHandler(
175+
new Handler() {
176+
@Override
177+
public void close() throws SecurityException {
178+
}
179+
180+
@Override
181+
public void flush() {
182+
}
183+
184+
@Override
185+
public void publish(LogRecord arg0) {
186+
fail("No logging necessary when koan passes, otherwise - logging is new, adjust accordingly.");
187+
}
188+
});
154189
new KoanSuiteRunner().run();
155190
}
156-
191+
157192
public static class WrongExpectationOrderKoan {
158-
@Koan
159-
public void expectationOnLeft(){
193+
@Koan
194+
public void expectationOnLeft() {
160195
com.sandwich.util.Assert.assertEquals(__, false);
161196
}
162197
}

koans/src/PathToEnlightment.xml

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -95,17 +95,21 @@
9595
lesson="With AutoBoxing, we can intermix as well" />
9696
<koan name="allPrimativesCanBeAutoboxed" lesson="All primatives can be autoboxed" />
9797
</suite>
98-
<suite class="AboutCollections"/>
99-
<suite class="AboutComparison"/>
100-
<suite class="AboutDates"/>
101-
<suite class="AboutEquality"/>
102-
<suite class="AboutFileIO"/>
103-
<suite class="AboutInnerClasses"/>
104-
<suite class="AboutSerialization"/>
98+
<suite class="AboutFileIO"></suite>
99+
<suite class="AboutInnerClasses"> </suite>
100+
<suite class="AboutSerialization">
101+
<koan name="simpleSerialization" />
102+
<koan name="customObjectSerialization" />
103+
<koan name="customObjectSerializationWithTransientFields" />
104+
<koan name="customSerializationWithUnserializableFields" />
105+
<koan name="serializeWithInteritance" />
106+
<koan name="serializeWithInheritanceWhenParentNotserializable" />
107+
</suite>
105108
</package>
106109
<package pkg="advanced" name="Advanced">
107110
<suite class="AboutMocks">
108-
<koan name="simpleAnonymousMock" lesson="How can this pass without touching the ClassUnderTest?" />
111+
<koan name="simpleAnonymousMock"
112+
lesson="How can this pass without touching the ClassUnderTest?" />
109113
</suite>
110114
</package>
111115
</packages>

koans/src/beginner/AboutAssertions.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,7 @@ public void assertEqualsWithDescriptiveMessage() {
3939
// Generally, when using an assertXXX methods, expectation is on the
4040
// left and it is best practice to use a String for the first arg
4141
// indication what has failed
42-
assertEquals("A message as the first arg in assertEquals " +
43-
"invocations, will appear when the assertion fails.\r",
44-
1, __);
42+
assertEquals("1 should equal 1", 1, __);
4543
}
4644

4745
@Koan()

koans/src/beginner/AboutEnums.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public void basicEnumsAccess() {
2727
}
2828

2929
enum SkatSuits {
30-
Clubs(12), Spades(11), Hearts(10), Diamonds(9);
30+
Clubs(12), Spades(11), Hearts(10), Dimonds(9);
3131
SkatSuits(int v) { value = v; }
3232
private int value;
3333
}

koans/src/intermediate/AboutEquality.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ public void noObjectShouldbeEqualToNull() {
2626
assertEquals(new Object().equals(null), __);
2727
}
2828

29-
@SuppressWarnings("unused")
3029
static class Car {
3130
@SuppressWarnings("unused")
3231
private String name = "";

koans/src/intermediate/AboutInnerClasses.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ class OtherInner extends AboutInnerClasses { }
103103
public void innerClassAndInheritanceOther() {
104104
OtherInner someObject = new OtherInner();
105105
// What do you expect here?
106-
// Compare this result with the last koan. What does that mean?
106+
// Complare this result with the last koan. What does that mean?
107107
assertEquals(someObject instanceof AboutInnerClasses, __);
108108
}
109109

0 commit comments

Comments
 (0)