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
interface Queue { | |
Message read(); | |
void delete(Message message); | |
void deleteAll() default { | |
Message message; | |
while ((message = read()) != null) { | |
delete(message); | |
} | |
} | |
} |
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
interface BatchQueue extends Queue { | |
void setBatchSize(int batchSize); | |
void deleteAll() default { | |
setBatchSize(100); | |
Queue.super.deleteAll(); | |
} | |
} |
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
interface FastQueue extends Queue { | |
void deleteAll(); | |
} |
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
public class BlogAggregatorUnitTest { | |
@Rule public final JUnitRuleMockery context = new JUnitRuleMockery(); | |
private final BlogResource alicesBlogResource = context.mock(BlogResource.class, "Alice's Blog"); | |
private final BlogResource bobsBlogResource = context.mock(BlogResource.class, "Bob's Blog"); | |
@Test public void providesFeedContainingMostRecentArticleFromEachBlog() { | |
context.checking(new Expectations() {{ | |
allowing(alicesBlogResource).get(); will(returnValue(alicesBlog)); | |
allowing(bobsBlogResource).get(); will(returnValue(bobsBlog)); | |
}}); |
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
@Path("/") | |
public interface BlogResource { | |
@GET @Produces(APPLICATION_JSON) Blog get(); | |
} |
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
public class BlogAggregatorIntegrationTest { | |
@Rule public JUnitRuleMockery context = new JUnitRuleMockery() {{ | |
setThreadingPolicy(new Synchroniser()); | |
}}; | |
private final BlogResource alicesBlogResource = context.mock(BlogResource.class, "Alice's Blog"); | |
private final BlogResource bobsBlogResource = context.mock(BlogResource.class, "Bob's Blog"); | |
private final JerseyTest alicesServer = aJerseyTest().withPort(9998) | |
.addResource(alicesBlogResource).build(); | |
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
enum FilterType { ... } | |
interface Filter { | |
Response filter(Request request); | |
} | |
class RoutingFilter { | |
private final Map<FilterType, Filter> routes; | |
public RoutingFilter(Map<FilterType, Filter> routes) { |
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
G 3 --- 2&6 3 --- | ---------------- | 5 (*) ---------- | ---------------- | | |
D ----------- 2++ | 2&6 -- 3 2++ 2&6 | ---------- 2++ - | 5 -------------- | | |
A --------------- | ---------------- | ------ 1&5 --- 3 | ---------------- | | |
E --------------- | ---------------- | ---------------- | ---------------- | | |
All notes harmonics | |
2++: harmonic ~2/3rds between 2nd and 3rd fret | |
x&y: hold fret x, harmonic on fret y | |
(*) alternatively, 2++ on A string |
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
@Configuration public class MyCollaboratorConfig { | |
@Bean public MyCollaborator myCollaborator() { | |
return new MyRealCollaborator(); | |
} | |
} |
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
@Configuration | |
@Import(MyCollaboratorConfig.class) | |
public class MyServiceConfig { | |
@Autowired private MyCollaboratorConfig collaboratorConfig; | |
@Bean public MyService myService() { | |
return new MyRealService(collaboratorConfig.myCollaborator()); | |
} | |
} |