├── .DS_Store ├── .gitignore ├── README ├── address ├── .gitignore ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── captaindebug │ │ │ ├── address │ │ │ ├── Address.java │ │ │ ├── AddressController.java │ │ │ ├── AddressDao.java │ │ │ ├── AddressService.java │ │ │ ├── HomeController.java │ │ │ └── JdbcAddress.java │ │ │ ├── name │ │ │ └── Name.java │ │ │ ├── siteproperties │ │ │ ├── LegacyAddressController.java │ │ │ ├── LegacyAddressService.java │ │ │ ├── PropertiesManager.java │ │ │ ├── SitePropertiesManager.java │ │ │ └── SitePropertiesManagerFactoryBean.java │ │ │ └── whytotest │ │ │ ├── AddressFormatException.java │ │ │ └── AddressService.java │ ├── resources │ │ └── log4j.xml │ ├── sql │ │ └── create.sql │ └── webapp │ │ ├── META-INF │ │ └── MANIFEST.MF │ │ └── WEB-INF │ │ ├── spring │ │ ├── appServlet │ │ │ ├── servlet-context.xml │ │ │ └── spring-datasource.xml │ │ └── root-context.xml │ │ ├── views │ │ ├── address-display.jsp │ │ └── home.jsp │ │ └── web.xml │ └── test │ ├── java │ └── com │ │ └── captaindebug │ │ ├── address │ │ ├── ClassicAddressServiceWithExtendedStubTest.java │ │ ├── ClassicAddressServiceWithStubTest.java │ │ ├── EndToEndAddressServiceTest.java │ │ ├── HomeMadeMockDao.java │ │ ├── MockingAddressServiceWithEasyMockTest.java │ │ ├── MockingAddressServiceWithHomeMadeMockTest.java │ │ ├── StubAddressDao.java │ │ └── StubJdbcAddress.java │ │ ├── name │ │ └── NameTest.java │ │ ├── siteproperties │ │ ├── LegacyAddressServiceUnitTest.java │ │ ├── LegacyAddressServiceUsingInheritanceTest.java │ │ └── StubPropertiesManager.java │ │ └── whytotest │ │ └── WhyToTestAddressServiceTest.java │ └── resources │ ├── com │ └── captaindebug │ │ └── address │ │ └── FindAddress.xml │ ├── db.properties │ ├── log4j.xml │ ├── servlet-context.xml │ ├── spring-datasource.xml │ └── unitils.properties ├── ajax-json ├── .gitignore ├── pom.xml └── src │ ├── html │ └── page1.html │ ├── main │ ├── java │ │ └── com │ │ │ └── captaindebug │ │ │ └── store │ │ │ ├── HomeController.java │ │ │ ├── OrderController.java │ │ │ ├── beans │ │ │ ├── Item.java │ │ │ ├── OrderForm.java │ │ │ └── UserSelections.java │ │ │ ├── dummydao │ │ │ └── Catalogue.java │ │ │ └── monitoring │ │ │ ├── HeapMonitor.java │ │ │ ├── Point.java │ │ │ ├── SingleThreadRunner.java │ │ │ └── TimedList.java │ ├── resources │ │ └── log4j.xml │ └── webapp │ │ ├── WEB-INF │ │ ├── spring │ │ │ ├── appServlet │ │ │ │ └── servlet-context.xml │ │ │ └── root-context.xml │ │ ├── views │ │ │ ├── home.jsp │ │ │ └── shopping.jsp │ │ └── web.xml │ │ └── resources │ │ ├── blueprint │ │ ├── ie.css │ │ ├── plugins │ │ │ ├── buttons │ │ │ │ ├── icons │ │ │ │ │ ├── cross.png │ │ │ │ │ ├── key.png │ │ │ │ │ └── tick.png │ │ │ │ ├── readme.txt │ │ │ │ └── screen.css │ │ │ ├── fancy-type │ │ │ │ ├── readme.txt │ │ │ │ └── screen.css │ │ │ ├── link-icons │ │ │ │ ├── icons │ │ │ │ │ ├── doc.png │ │ │ │ │ ├── email.png │ │ │ │ │ ├── external.png │ │ │ │ │ ├── feed.png │ │ │ │ │ ├── im.png │ │ │ │ │ ├── lock.png │ │ │ │ │ ├── pdf.png │ │ │ │ │ ├── visited.png │ │ │ │ │ └── xls.png │ │ │ │ ├── readme.txt │ │ │ │ └── screen.css │ │ │ └── rtl │ │ │ │ ├── readme.txt │ │ │ │ └── screen.css │ │ ├── print.css │ │ ├── screen.css │ │ └── src │ │ │ ├── forms.css │ │ │ ├── grid.css │ │ │ ├── grid.png │ │ │ ├── ie.css │ │ │ ├── print.css │ │ │ ├── reset.css │ │ │ └── typography.css │ │ ├── jquery-1.9.1.js │ │ ├── shopping.js │ │ └── style.css │ └── test │ ├── java │ └── com │ │ └── captaindebug │ │ └── store │ │ ├── controllers │ │ ├── OrderControllerTest.java │ │ └── mockmvc │ │ │ └── OrderControllerTest.java │ │ ├── dummydao │ │ └── CatalogueTest.java │ │ └── monitoring │ │ └── TimedListTest.java │ └── resources │ └── log4j.xml ├── audit-aspectj ├── .gitignore ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── captaindebug │ │ │ └── audit │ │ │ ├── aspectj │ │ │ ├── Audit.java │ │ │ └── AuditAdvice.java │ │ │ ├── controller │ │ │ ├── HelpController.java │ │ │ └── HomeController.java │ │ │ └── service │ │ │ └── AuditService.java │ ├── resources │ │ └── log4j.xml │ └── webapp │ │ ├── WEB-INF │ │ ├── spring │ │ │ ├── appServlet │ │ │ │ └── servlet-context.xml │ │ │ └── root-context.xml │ │ ├── views │ │ │ ├── help.jsp │ │ │ └── home.jsp │ │ └── web.xml │ │ └── resources │ │ └── images │ │ └── the_beatles_help__movie_image__4_.jpg │ └── test │ └── resources │ └── log4j.xml ├── build-all ├── .gitignore └── pom.xml ├── cargo-cult ├── .gitignore ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── captaindebug │ │ │ └── cargocult │ │ │ ├── HomeController.java │ │ │ ├── User.java │ │ │ ├── brief │ │ │ └── UserAccessor.java │ │ │ └── ntier │ │ │ ├── FindUserRowMapper.java │ │ │ ├── UserController.java │ │ │ ├── UserDao.java │ │ │ ├── UserDaoImpl.java │ │ │ ├── UserService.java │ │ │ └── UserServiceImpl.java │ ├── resources │ │ └── log4j.xml │ └── webapp │ │ └── WEB-INF │ │ ├── spring │ │ ├── appServlet │ │ │ └── servlet-context.xml │ │ ├── root-context.xml │ │ └── spring-datasource.xml │ │ ├── views │ │ ├── home.jsp │ │ └── user.jsp │ │ └── web.xml │ ├── scripts │ └── dbsetup.sql │ └── test │ ├── java │ └── com │ │ └── captaindebug │ │ └── cargocult │ │ ├── brief │ │ └── UserAccessorIntTest.java │ │ └── ntier │ │ ├── UserControllerIntTest.java │ │ ├── UserControllerTest.java │ │ ├── UserDaoTest.java │ │ └── UserServiceTest.java │ └── resources │ ├── db.properties │ ├── log4j.xml │ └── test-datasource.xml ├── database ├── .gitignore ├── pom.xml └── src │ └── main │ └── sql │ └── create.sql ├── deadlocks ├── .gitignore ├── pom.xml └── src │ ├── main │ └── java │ │ └── threads │ │ ├── deadlock │ │ ├── Account.java │ │ ├── AvoidsDeadlockDemo.java │ │ ├── DeadlockDemo.java │ │ └── OverdrawnException.java │ │ └── lock │ │ ├── Account.java │ │ ├── TimeoutTrylockDemo.java │ │ └── TrylockDemo.java │ └── test │ └── java │ └── threads │ └── lock │ ├── AccountTest.java │ └── package-info.java ├── defensive ├── .gitignore ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── captaindebug │ │ │ └── defensive │ │ │ ├── badsample │ │ │ └── BodyMassIndex.java │ │ │ └── goodsample │ │ │ └── BodyMassIndex.java │ └── resources │ │ └── context.xml │ └── test │ └── java │ └── com │ └── captaindebug │ └── defensive │ ├── badsample │ └── BodyMassIndexTest.java │ └── goodsample │ └── BodyMassIndexTest.java ├── dependency-injection-factory ├── .gitignore ├── pom.xml └── src │ ├── main │ └── java │ │ └── dependency_injection_with_annotations │ │ ├── AnnotationChecker.java │ │ ├── DependencyInjectionBeanFactory.java │ │ ├── MyBeanFactory.java │ │ ├── annotations │ │ ├── MyAutoWire.java │ │ └── MyComponent.java │ │ ├── loaders │ │ ├── FileLoader.java │ │ ├── FileSystemClassLoader.java │ │ └── JarLoader.java │ │ └── testclasses │ │ ├── ClassWithAttributes.java │ │ └── InjectedClass.java │ └── test │ └── java │ └── dependency_injection_with_annotations │ ├── AnnotationCheckerTest.java │ └── DependencyInjectionBeanFactoryTest.java ├── error-track ├── .gitignore ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── captaindebug │ │ │ └── errortrack │ │ │ ├── ErrorTrackService.java │ │ │ ├── Formatter.java │ │ │ ├── Main.java │ │ │ ├── Publisher.java │ │ │ ├── Validator.java │ │ │ ├── file │ │ │ └── FileLocator.java │ │ │ ├── package-info.java │ │ │ ├── quartz │ │ │ └── FileLocatorJob.java │ │ │ ├── report │ │ │ ├── EmailPublisher.java │ │ │ ├── HtmlFormatter.java │ │ │ ├── Results.java │ │ │ └── TextFormatter.java │ │ │ └── validator │ │ │ ├── FileAgeValidator.java │ │ │ ├── FileValidator.java │ │ │ └── RegexValidator.java │ └── resources │ │ ├── app.properties │ │ ├── error-track-context.xml │ │ └── log4j.properties │ ├── script │ └── runme.sh │ └── test │ ├── java │ └── com │ │ └── captaindebug │ │ └── errortrack │ │ ├── file │ │ ├── FileLocatorITest.java │ │ └── FileLocatorTest.java │ │ ├── report │ │ ├── EmailPublisherITest.java │ │ ├── ResultsTest.java │ │ └── TextFormatterTest.java │ │ └── validator │ │ ├── FileAgeValidatorTest.java │ │ ├── FileValidatorTest.java │ │ └── RegexValidatorTest.java │ └── resources │ ├── contains-errors.log │ ├── error-free.log │ └── exclude.log ├── exceptions ├── .gitignore ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── captaindebug │ │ │ └── exceptions │ │ │ ├── AnotherExceptionsDemoController.java │ │ │ ├── ExceptionsDemoController.java │ │ │ ├── HomeController.java │ │ │ ├── beans │ │ │ └── User.java │ │ │ └── dao │ │ │ └── UserDao.java │ ├── resources │ │ └── log4j.xml │ └── webapp │ │ ├── META-INF │ │ └── MANIFEST.MF │ │ └── WEB-INF │ │ ├── spring │ │ ├── appServlet │ │ │ └── servlet-context.xml │ │ └── root-context.xml │ │ ├── views │ │ ├── error.jsp │ │ └── home.jsp │ │ └── web.xml │ └── test │ └── resources │ └── log4j.xml ├── facebook ├── .gitignore ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── captaindebug │ │ │ └── social │ │ │ └── facebookposts │ │ │ ├── FacebookConfig.java │ │ │ ├── FacebookPostsController.java │ │ │ └── implementation │ │ │ ├── SocialContext.java │ │ │ └── UserCookieGenerator.java │ ├── resources │ │ └── log4j.xml │ └── webapp │ │ ├── META-INF │ │ └── MANIFEST.MF │ │ └── WEB-INF │ │ ├── spring │ │ ├── appServlet │ │ │ └── servlet-context.xml │ │ ├── data.xml │ │ └── root-context.xml │ │ ├── views │ │ ├── home.jsp │ │ ├── show-posts.jsp │ │ └── signin.jsp │ │ └── web.xml │ └── test │ ├── java │ └── com │ │ └── captaindebug │ │ └── social │ │ └── facebookposts │ │ ├── implementation │ │ └── SocialContextTest.java │ │ ├── mockito │ │ └── FacebookPostsControllerTest.java │ │ └── mockmvc │ │ ├── configfile │ │ └── FacebookPostsControllerTest.java │ │ └── standalone │ │ └── FacebookPostsControllerTest.java │ └── resources │ └── log4j.xml ├── hazelcast ├── .gitignore ├── pom.xml └── src │ ├── main │ └── java │ │ └── com │ │ └── captaindebug │ │ └── hazelcast │ │ ├── gettingstarted │ │ ├── BigWideWorld.java │ │ ├── Main.java │ │ ├── MyApplication.java │ │ ├── User.java │ │ └── Users.java │ │ └── pubsub │ │ ├── Client.java │ │ ├── MarketMaker.java │ │ └── StockPrice.java │ └── test │ └── java │ └── com │ └── captaindebug │ └── hazelcast │ ├── gettingstarted │ └── UsersTest.java │ └── pubsub │ └── MarketMakerTest.java ├── long-poll ├── .gitignore ├── pom.xml └── src │ ├── html │ └── page1.html │ ├── main │ ├── java │ │ └── com │ │ │ └── captaindebug │ │ │ ├── longpoll │ │ │ ├── DeferredMatchUpdateController.java │ │ │ ├── HomeController.java │ │ │ ├── Message.java │ │ │ ├── SimpleMatchUpdateController.java │ │ │ ├── service │ │ │ │ ├── DeferredResultService.java │ │ │ │ └── SimpleMatchUpdateService.java │ │ │ ├── shutdown │ │ │ │ ├── Hook.java │ │ │ │ └── ShutdownService.java │ │ │ └── source │ │ │ │ ├── Match.java │ │ │ │ └── MatchReporter.java │ │ │ └── report │ │ │ └── ApplicationContextReport.java │ ├── resources │ │ └── log4j.xml │ └── webapp │ │ ├── WEB-INF │ │ ├── spring │ │ │ ├── appServlet │ │ │ │ └── servlet-context.xml │ │ │ ├── matches.xml │ │ │ └── root-context.xml │ │ ├── views │ │ │ ├── body.jsp │ │ │ ├── deferredmatchupdate.jsp │ │ │ ├── home.jsp │ │ │ └── simplematchupdate.jsp │ │ └── web.xml │ │ └── resources │ │ ├── blueprint │ │ ├── ie.css │ │ ├── plugins │ │ │ ├── buttons │ │ │ │ ├── icons │ │ │ │ │ ├── cross.png │ │ │ │ │ ├── key.png │ │ │ │ │ └── tick.png │ │ │ │ ├── readme.txt │ │ │ │ └── screen.css │ │ │ ├── fancy-type │ │ │ │ ├── readme.txt │ │ │ │ └── screen.css │ │ │ ├── link-icons │ │ │ │ ├── icons │ │ │ │ │ ├── doc.png │ │ │ │ │ ├── email.png │ │ │ │ │ ├── external.png │ │ │ │ │ ├── feed.png │ │ │ │ │ ├── im.png │ │ │ │ │ ├── lock.png │ │ │ │ │ ├── pdf.png │ │ │ │ │ ├── visited.png │ │ │ │ │ └── xls.png │ │ │ │ ├── readme.txt │ │ │ │ └── screen.css │ │ │ └── rtl │ │ │ │ ├── readme.txt │ │ │ │ └── screen.css │ │ ├── print.css │ │ ├── screen.css │ │ └── src │ │ │ ├── forms.css │ │ │ ├── grid.css │ │ │ ├── grid.png │ │ │ ├── ie.css │ │ │ ├── print.css │ │ │ ├── reset.css │ │ │ └── typography.css │ │ ├── images │ │ ├── Stoke_City_1972.jpg │ │ └── classic.png │ │ ├── jquery-1.9.1.js │ │ ├── mystyle.css │ │ ├── polling.js │ │ └── style.css │ └── test │ ├── java │ └── com │ │ └── captaindebug │ │ ├── longpoll │ │ └── shutdown │ │ │ ├── HookTest.java │ │ │ ├── ShutdownServiceIntTest.java │ │ │ └── ShutdownServiceTest.java │ │ └── report │ │ └── ApplicationContextReportTest.java │ └── resources │ └── log4j.xml ├── pool ├── .factorypath ├── pom.xml └── src │ ├── main │ └── java │ │ └── com │ │ └── captaindebug │ │ └── stormpot │ │ ├── BufferAllocator.java │ │ ├── PoolableBuffer.java │ │ └── StormPot.java │ └── readme.txt ├── powermock-tips ├── .gitignore ├── pom.xml └── src │ ├── main │ └── java │ │ └── com │ │ └── captaindebug │ │ ├── AnchorTag.java │ │ ├── AnyOldClass.java │ │ ├── GameStatistics.java │ │ ├── UsesNewToInstantiateClass.java │ │ └── UsesResourceBundle.java │ └── test │ └── java │ └── com │ └── captaindebug │ ├── AccessPrivatePartsTest.java │ ├── MockConstructorTest.java │ ├── PrivateMethodTest.java │ └── UsesResourceBundleTest.java ├── producer-consumer ├── .gitignore ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── captaindebug │ │ │ └── producerconsumer │ │ │ ├── Match.java │ │ │ ├── MatchReporter.java │ │ │ ├── Message.java │ │ │ ├── PrintHead.java │ │ │ ├── interruptible │ │ │ ├── Main.java │ │ │ └── Teletype.java │ │ │ ├── original │ │ │ ├── Main.java │ │ │ └── Teletype.java │ │ │ ├── poisonpill │ │ │ ├── Main.java │ │ │ └── Teletype.java │ │ │ └── problem │ │ │ ├── Main.java │ │ │ ├── Order.java │ │ │ ├── OrderFeed.java │ │ │ ├── OrderQueueMonitor.java │ │ │ └── OrderRecord.java │ └── resources │ │ ├── context.xml │ │ ├── context2.xml │ │ ├── context3.xml │ │ ├── matches-poisonpill.xml │ │ ├── matches.xml │ │ └── problem-context.xml │ ├── readme.txt │ └── test │ └── java │ └── com │ └── captaindebug │ └── producerconsumer │ ├── MatchReporterTest.java │ ├── MatchTest.java │ ├── interruptible │ └── TeletypeTest.java │ ├── original │ └── TeletypeTest.java │ └── poisonpill │ └── TeletypeTest.java ├── sim-map-exc-res ├── .gitignore ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── captaindebug │ │ │ ├── exceptions │ │ │ ├── ExceptionsDemoController.java │ │ │ ├── HomeController.java │ │ │ ├── ImageLoaderController.java │ │ │ └── SampleExceptionHandler.java │ │ │ └── temp │ │ │ └── ByteArrayInputStream.java │ ├── resources │ │ └── log4j.xml │ └── webapp │ │ ├── META-INF │ │ └── MANIFEST.MF │ │ ├── WEB-INF │ │ ├── spring │ │ │ ├── appServlet │ │ │ │ └── servlet-context.xml │ │ │ └── root-context.xml │ │ ├── views │ │ │ ├── generic-error.jsp │ │ │ ├── home.jsp │ │ │ └── io-exception.jsp │ │ └── web.xml │ │ └── resources │ │ └── images │ │ └── sea.jpg │ └── test │ ├── java │ └── com │ │ └── captaindebug │ │ └── temp │ │ └── ByteArrayInputStreamTest.java │ └── resources │ └── log4j.xml ├── social ├── .gitignore ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── captaindebug │ │ │ └── social │ │ │ └── twittertimeline │ │ │ ├── SimpleTwitterConfig.java │ │ │ └── TwitterTimeLineController.java │ ├── resources │ │ └── log4j.xml │ └── webapp │ │ ├── META-INF │ │ └── MANIFEST.MF │ │ └── WEB-INF │ │ ├── spring │ │ ├── appServlet │ │ │ └── servlet-context.xml │ │ └── root-context.xml │ │ ├── views │ │ ├── home.jsp │ │ └── timeline.jsp │ │ └── web.xml │ └── test │ └── resources │ └── log4j.xml ├── spring-3.2 ├── .gitignore ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── captaindebug │ │ │ └── spring_3_2 │ │ │ ├── HomeController.java │ │ │ ├── controleradvice │ │ │ ├── MyControllerAdviceDemo.java │ │ │ ├── UserAddressController.java │ │ │ ├── UserCreditCardController.java │ │ │ ├── beans │ │ │ │ └── User.java │ │ │ └── dao │ │ │ │ └── UserDao.java │ │ │ └── matrix_variables │ │ │ └── MatrixVariableController.java │ ├── resources │ │ └── log4j.xml │ └── webapp │ │ ├── WEB-INF │ │ ├── spring │ │ │ ├── appServlet │ │ │ │ └── servlet-context.xml │ │ │ └── root-context.xml │ │ ├── views │ │ │ ├── error.jsp │ │ │ ├── home.jsp │ │ │ └── stocks.jsp │ │ └── web.xml │ │ └── resources │ │ └── blueprint │ │ ├── ie.css │ │ ├── plugins │ │ ├── buttons │ │ │ ├── icons │ │ │ │ ├── cross.png │ │ │ │ ├── key.png │ │ │ │ └── tick.png │ │ │ ├── readme.txt │ │ │ └── screen.css │ │ ├── fancy-type │ │ │ ├── readme.txt │ │ │ └── screen.css │ │ ├── link-icons │ │ │ ├── icons │ │ │ │ ├── doc.png │ │ │ │ ├── email.png │ │ │ │ ├── external.png │ │ │ │ ├── feed.png │ │ │ │ ├── im.png │ │ │ │ ├── lock.png │ │ │ │ ├── pdf.png │ │ │ │ ├── visited.png │ │ │ │ └── xls.png │ │ │ ├── readme.txt │ │ │ └── screen.css │ │ └── rtl │ │ │ ├── readme.txt │ │ │ └── screen.css │ │ ├── print.css │ │ ├── screen.css │ │ └── src │ │ ├── forms.css │ │ ├── grid.css │ │ ├── grid.png │ │ ├── ie.css │ │ ├── print.css │ │ ├── reset.css │ │ └── typography.css │ └── test │ └── resources │ └── log4j.xml ├── spring-security └── tomcat-ssl │ ├── .gitignore │ ├── pom.xml │ └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── captaindebug │ │ │ └── security │ │ │ └── HomeController.java │ ├── resources │ │ └── log4j.xml │ └── webapp │ │ └── WEB-INF │ │ ├── spring │ │ ├── appServlet │ │ │ ├── application-security.xml │ │ │ └── servlet-context.xml │ │ └── root-context.xml │ │ ├── views │ │ └── home.jsp │ │ └── web.xml │ └── test │ └── resources │ └── log4j.xml ├── state-machine ├── .gitignore ├── pom.xml └── src │ ├── main │ └── java │ │ ├── META-INF │ │ └── MANIFEST.MF │ │ └── com │ │ └── captaindebug │ │ └── statemachine │ │ ├── AbstractAction.java │ │ ├── StateMachine.java │ │ ├── StateMachineException.java │ │ ├── tweettohtml │ │ ├── CaptureTag.java │ │ ├── CheckHttpAction.java │ │ ├── DefaultAction.java │ │ ├── OutputStrategy.java │ │ ├── ReadyAction.java │ │ ├── TweetState.java │ │ └── strategy │ │ │ ├── HashTagStrategy.java │ │ │ ├── UrlStrategy.java │ │ │ └── UserNameStrategy.java │ │ └── unpackxml │ │ ├── CaptureStartTag.java │ │ ├── DefaultAction.java │ │ ├── Uncompress.java │ │ ├── XMLState.java │ │ └── package.html │ └── test │ ├── java │ └── com │ │ └── captaindebug │ │ └── statemachine │ │ ├── tweettohtml │ │ ├── CaptureTagTest.java │ │ ├── TweetToHtmlTest.java │ │ └── strategy │ │ │ ├── HashTagStrategyTest.java │ │ │ ├── UrlStrategyTest.java │ │ │ └── UserNameStrategyTest.java │ │ └── unpackxml │ │ └── XMLParserTest.java │ └── resources │ └── compressed.xml ├── telldontask-integration ├── .classpath ├── .gitignore ├── .settings │ └── .gitignore └── pom.xml ├── telldontask ├── .gitignore ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── captaindebug │ │ │ ├── bridge │ │ │ └── ShoppingCart.java │ │ │ ├── payment │ │ │ ├── MasterCard.java │ │ │ ├── PaymentMethod.java │ │ │ └── Visa.java │ │ │ ├── strategy │ │ │ └── SpringShoppingCart.java │ │ │ └── telldontask │ │ │ ├── HomeController.java │ │ │ ├── Item.java │ │ │ └── ShoppingCart.java │ ├── resources │ │ └── log4j.xml │ └── webapp │ │ ├── META-INF │ │ └── MANIFEST.MF │ │ └── WEB-INF │ │ ├── spring │ │ ├── appServlet │ │ │ └── servlet-context.xml │ │ └── root-context.xml │ │ ├── views │ │ └── home.jsp │ │ └── web.xml │ └── test │ ├── java │ └── com │ │ └── captaindebug │ │ ├── bridge │ │ └── ShoppingCartTest.java │ │ ├── strategy │ │ └── SpringShoppingCartTest.java │ │ └── telldontask │ │ └── ShoppingCartTest.java │ └── resources │ └── log4j.xml ├── tmp ├── DebugConnectionRespository.java ├── DebugConnectionSignup.java ├── DebugUsersConnectionRepository.java └── readme.txt ├── unit-testing-threads ├── .gitignore ├── pom.xml └── src │ ├── main │ └── java │ │ └── com │ │ └── captaindebug │ │ └── threading │ │ ├── bad_example │ │ └── ThreadWrapper.java │ │ ├── future │ │ └── ThreadWrapper.java │ │ ├── good_example │ │ └── ThreadWrapper.java │ │ ├── good_example2 │ │ └── ThreadWrapper.java │ │ ├── joinexample │ │ └── ThreadWrapper.java │ │ ├── semaphore │ │ └── ThreadWrapper.java │ │ └── strategy │ │ ├── DatabaseJob.java │ │ ├── ThreadWrapper.java │ │ └── package-info.java │ └── test │ └── java │ └── com │ └── captaindebug │ └── threading │ ├── bad_example │ └── ThreadWrapperTest.java │ ├── future │ └── ThreadWrapperTest.java │ ├── good_example │ └── ThreadWrapperTest.java │ ├── good_example2 │ └── ThreadWrapperTest.java │ ├── joinexample │ └── ThreadWrapperTest.java │ ├── semaphore │ └── ThreadWrapperTest.java │ └── strategy │ └── ThreadWrapperTest.java ├── xml-tips-blog ├── .gitignore ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── captaindebug │ │ │ └── xml │ │ │ ├── as_string │ │ │ └── OrderPizza.java │ │ │ └── sax │ │ │ └── PizzaParser.java │ └── resources │ │ └── pizza-order1.xml │ └── test │ ├── java │ └── com │ │ └── captaindebug │ │ └── xml │ │ ├── as_string │ │ └── OrderPizzaTest.java │ │ ├── jaxb │ │ └── PizzaJaxbTest.java │ │ ├── sax │ │ └── PizzaParserTest.java │ │ └── xmlbeans │ │ └── PizzaXmlBeansTest.java │ └── resources │ ├── customer.xsd │ ├── pizza-order.xsd │ ├── pizza1.xml │ ├── pizza2.xml │ ├── pizza3.xml │ ├── sitemap1.xml │ ├── sitemap2.xml │ └── sitemap3.xml ├── xml-tips-jaxb ├── .gitignore ├── pom.xml └── src │ └── main │ ├── java │ └── META-INF │ │ └── MANIFEST.MF │ └── resources │ ├── customer.xsd │ └── pizza-order.xsd └── xml-tips-xmlbeans ├── .gitignore ├── pom.xml └── src └── main ├── java └── META-INF │ └── MANIFEST.MF └── resources ├── customer.xsd └── pizza-order.xsd /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roghughe/captaindebug/54e4a55ee8347e0ff0354ea1f12ee69a00fa5831/.DS_Store -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /.project 2 | /.settings 3 | /target 4 | /.classpath 5 | /.DS_Store 6 | -------------------------------------------------------------------------------- /address/.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | /.settings 3 | /.classpath 4 | /.project 5 | -------------------------------------------------------------------------------- /address/src/main/java/com/captaindebug/address/AddressDao.java: -------------------------------------------------------------------------------- 1 | package com.captaindebug.address; 2 | 3 | /** 4 | * Address Data Access Object Interface 5 | * 6 | * @author RogerHughes 7 | * 8 | */ 9 | public interface AddressDao { 10 | 11 | public Address findAddress(int id); 12 | 13 | } -------------------------------------------------------------------------------- /address/src/main/java/com/captaindebug/address/HomeController.java: -------------------------------------------------------------------------------- 1 | package com.captaindebug.address; 2 | 3 | import java.text.DateFormat; 4 | import java.util.Date; 5 | import java.util.Locale; 6 | 7 | import org.slf4j.Logger; 8 | import org.slf4j.LoggerFactory; 9 | import org.springframework.stereotype.Controller; 10 | import org.springframework.ui.Model; 11 | import org.springframework.web.bind.annotation.RequestMapping; 12 | import org.springframework.web.bind.annotation.RequestMethod; 13 | 14 | /** 15 | * Handles requests for the application home page. 16 | */ 17 | @Controller 18 | public class HomeController { 19 | 20 | private static final Logger logger = LoggerFactory.getLogger(HomeController.class); 21 | 22 | /** 23 | * Simply selects the home view to render by returning its name. 24 | */ 25 | @RequestMapping(value = "/", method = RequestMethod.GET) 26 | public String home(Locale locale, Model model) { 27 | logger.info("Welcome home! the client locale is "+ locale.toString()); 28 | 29 | Date date = new Date(); 30 | DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG, locale); 31 | 32 | String formattedDate = dateFormat.format(date); 33 | 34 | model.addAttribute("serverTime", formattedDate ); 35 | 36 | return "home"; 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /address/src/main/java/com/captaindebug/name/Name.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package com.captaindebug.name; 5 | 6 | /** 7 | * Simple immutable name bean 8 | * 9 | * @author Roger 10 | * 11 | * Created 7:59:37 PM Nov 14, 2011 12 | * 13 | */ 14 | public class Name { 15 | 16 | private final String firstName; 17 | private final String middleName; 18 | private final String surname; 19 | 20 | public Name(String christianName, String middleName, String surname) { 21 | this.firstName = christianName; 22 | this.middleName = middleName; 23 | this.surname = surname; 24 | } 25 | 26 | public String getFirstName() { 27 | return firstName; 28 | } 29 | 30 | public String getMiddleName() { 31 | return middleName; 32 | } 33 | 34 | public String getSurname() { 35 | return surname; 36 | } 37 | 38 | public String getFullName() { 39 | 40 | if (isValidString(firstName) && isValidString(middleName) && isValidString(surname)) { 41 | return firstName + " " + middleName + " " + surname; 42 | } else { 43 | throw new RuntimeException("Invalid Name Values"); 44 | } 45 | } 46 | 47 | private boolean isValidString(String str) { 48 | return isNotNull(str) && str.length() > 0; 49 | } 50 | 51 | private boolean isNotNull(Object obj) { 52 | return obj != null; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /address/src/main/java/com/captaindebug/siteproperties/PropertiesManager.java: -------------------------------------------------------------------------------- 1 | package com.captaindebug.siteproperties; 2 | 3 | import java.util.List; 4 | 5 | public interface PropertiesManager { 6 | 7 | public abstract String findProperty(String propertyName); 8 | 9 | public abstract String findProperty(String propertyName, String locale); 10 | 11 | public abstract List findListProperty(String propertyName); 12 | 13 | public abstract List findListProperty(String propertyName, String locale); 14 | 15 | public abstract int findIntProperty(String propertyName); 16 | 17 | public abstract int findIntProperty(String propertyName, String locale); 18 | 19 | } -------------------------------------------------------------------------------- /address/src/main/java/com/captaindebug/siteproperties/SitePropertiesManagerFactoryBean.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2011 Marin Solutions 3 | */ 4 | package com.captaindebug.siteproperties; 5 | 6 | import org.springframework.beans.factory.FactoryBean; 7 | import org.springframework.stereotype.Component; 8 | 9 | /** 10 | * This is our Factory Object - creates a instance of SiteProperties that can be 11 | * picked up by Spring. 12 | */ 13 | @Component 14 | public class SitePropertiesManagerFactoryBean implements FactoryBean { 15 | 16 | private static SitePropertiesManager propsManager; 17 | 18 | public SitePropertiesManagerFactoryBean() { 19 | propsManager = SitePropertiesManager.getInstance(); 20 | propsManager.setUrl("jdbc:mysql://localhost/junit"); 21 | propsManager.setUsername("root"); 22 | propsManager.setPassword("experience"); 23 | propsManager.init(); 24 | } 25 | 26 | @Override 27 | public SitePropertiesManager getObject() throws Exception { 28 | 29 | return propsManager; 30 | } 31 | 32 | @Override 33 | public Class getObjectType() { 34 | 35 | return SitePropertiesManager.class; 36 | } 37 | 38 | @Override 39 | public boolean isSingleton() { 40 | 41 | return true; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /address/src/main/java/com/captaindebug/whytotest/AddressFormatException.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2011 Marin Solutions 3 | */ 4 | package com.captaindebug.whytotest; 5 | 6 | /** 7 | * @author Roger 8 | * 9 | */ 10 | public class AddressFormatException extends Exception { 11 | 12 | private static final long serialVersionUID = 1L; 13 | 14 | public AddressFormatException() { 15 | // TODO Auto-generated constructor stub 16 | } 17 | 18 | public AddressFormatException(String arg0) { 19 | super(arg0); 20 | } 21 | 22 | public AddressFormatException(Throwable arg0) { 23 | super(arg0); 24 | } 25 | 26 | public AddressFormatException(String arg0, Throwable arg1) { 27 | super(arg0, arg1); 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /address/src/main/resources/log4j.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /address/src/main/webapp/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | Class-Path: 3 | 4 | -------------------------------------------------------------------------------- /address/src/main/webapp/WEB-INF/spring/appServlet/spring-datasource.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /address/src/main/webapp/WEB-INF/spring/root-context.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /address/src/main/webapp/WEB-INF/views/address-display.jsp: -------------------------------------------------------------------------------- 1 | <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> 2 | <%@ page session="false" %> 3 | 4 | 5 | Home 6 | 7 | 8 |

Simple Address App

9 |

These are the Results of your Search

10 |

11 | Address id:
12 | Street:
13 | Town:
14 | Post Code:
15 | Country:
16 |

17 |
18 | Search Again with Address with ID 9 19 | 20 | 21 | -------------------------------------------------------------------------------- /address/src/main/webapp/WEB-INF/views/home.jsp: -------------------------------------------------------------------------------- 1 | <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> 2 | <%@ page session="false" %> 3 | 4 | 5 | Home 6 | 7 | 8 |

Simple Address App

9 |
10 | Select Address with ID 9 11 |
12 |
13 | Select Address with ID 9 with site props 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /address/src/test/java/com/captaindebug/address/StubAddressDao.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package com.captaindebug.address; 5 | 6 | /** 7 | * @author RogerHughes 8 | * 9 | */ 10 | public class StubAddressDao implements AddressDao { 11 | 12 | private final Address address; 13 | 14 | public StubAddressDao(Address address) { 15 | this.address = address; 16 | } 17 | 18 | /** 19 | * @see com.captaindebug.address.AddressDao#findAddress(int) 20 | */ 21 | @Override 22 | public Address findAddress(int id) { 23 | return address; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /address/src/test/java/com/captaindebug/address/StubJdbcAddress.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2011 Marin Solutions 3 | */ 4 | package com.captaindebug.address; 5 | 6 | /** 7 | * In the case where JdbcAddress doesn't implement an interface, one method of 8 | * creating a stub is to use inheritance. 9 | * 10 | * @author Roger 11 | * 12 | */ 13 | public class StubJdbcAddress extends JdbcAddress { 14 | 15 | private final Address address; 16 | 17 | public StubJdbcAddress(Address address) { 18 | this.address = address; 19 | } 20 | 21 | /** 22 | * @see com.captaindebug.address.JdbcAddress#findAddress(int) 23 | */ 24 | @Override 25 | public Address findAddress(int id) { 26 | return address; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /address/src/test/resources/com/captaindebug/address/FindAddress.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /address/src/test/resources/db.properties: -------------------------------------------------------------------------------- 1 | # Database connection properties 2 | database.driver=com.mysql.jdbc.Driver 3 | database.uri=jdbc:mysql://localhost/junit 4 | database.user=root 5 | database.password=experience 6 | 7 | -------------------------------------------------------------------------------- /address/src/test/resources/log4j.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /address/src/test/resources/unitils.properties: -------------------------------------------------------------------------------- 1 | # Properties for the PropertiesDataSourceFactory 2 | database.driverClassName=com.mysql.jdbc.Driver 3 | # add this host name to both Windows and macs for testing 4 | database.url=jdbc:mysql://localhost/junit 5 | database.dialect=mysql 6 | database.userName=root 7 | database.password=experience 8 | database.schemaNames=junit -------------------------------------------------------------------------------- /ajax-json/.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | /.settings 3 | /.classpath 4 | /.project 5 | -------------------------------------------------------------------------------- /ajax-json/src/main/java/com/captaindebug/store/HomeController.java: -------------------------------------------------------------------------------- 1 | package com.captaindebug.store; 2 | 3 | import java.text.DateFormat; 4 | import java.util.Date; 5 | import java.util.Locale; 6 | 7 | import org.slf4j.Logger; 8 | import org.slf4j.LoggerFactory; 9 | import org.springframework.stereotype.Controller; 10 | import org.springframework.ui.Model; 11 | import org.springframework.web.bind.annotation.RequestMapping; 12 | import org.springframework.web.bind.annotation.RequestMethod; 13 | 14 | /** 15 | * Handles requests for the application home page. 16 | */ 17 | @Controller 18 | public class HomeController { 19 | 20 | private static final Logger logger = LoggerFactory.getLogger(HomeController.class); 21 | 22 | /** 23 | * Simply selects the home view to render by returning its name. 24 | */ 25 | @RequestMapping(value = "/", method = RequestMethod.GET) 26 | public String home(Locale locale, Model model) { 27 | logger.info("Welcome home! The client locale is {}.", locale); 28 | 29 | Date date = new Date(); 30 | DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG, locale); 31 | 32 | String formattedDate = dateFormat.format(date); 33 | 34 | model.addAttribute("serverTime", formattedDate ); 35 | 36 | return "home"; 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /ajax-json/src/main/java/com/captaindebug/store/beans/Item.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2011 Marin Solutions Ltd 3 | */ 4 | package com.captaindebug.store.beans; 5 | 6 | import java.math.BigDecimal; 7 | 8 | /** 9 | * 10 | * This models an item from the shop's catalogue... 11 | * 12 | * @author Roger 13 | * 14 | */ 15 | public class Item { 16 | 17 | private final int id; 18 | 19 | private final String description; 20 | 21 | private final String name; 22 | 23 | private final BigDecimal price; 24 | 25 | private Item(int id, String name, String description, BigDecimal price) { 26 | this.id = id; 27 | this.name = name; 28 | this.description = description; 29 | this.price = price; 30 | } 31 | 32 | public final BigDecimal getPrice() { 33 | 34 | return price; 35 | } 36 | 37 | public final int getId() { 38 | 39 | return id; 40 | } 41 | 42 | public final String getDescription() { 43 | 44 | return description; 45 | } 46 | 47 | public final String getName() { 48 | 49 | return name; 50 | } 51 | 52 | public static Item getInstance(int id, String name, String description, BigDecimal price) { 53 | 54 | Item item = new Item(id, name, description, price); 55 | return item; 56 | } 57 | 58 | } 59 | -------------------------------------------------------------------------------- /ajax-json/src/main/java/com/captaindebug/store/beans/OrderForm.java: -------------------------------------------------------------------------------- 1 | package com.captaindebug.store.beans; 2 | 3 | import java.util.List; 4 | 5 | /** 6 | * Model an order form. This is a list of items and a unique purchase id. 7 | * 8 | * @author Roger 9 | * 10 | * Created 07:33:18 21 Apr 2013 11 | * 12 | */ 13 | public class OrderForm { 14 | 15 | private final List items; 16 | 17 | private final String purchaseId; 18 | 19 | public OrderForm(List items, String purchaseId) { 20 | super(); 21 | this.items = items; 22 | this.purchaseId = purchaseId; 23 | } 24 | 25 | public List getItems() { 26 | return items; 27 | } 28 | 29 | public String getPurchaseId() { 30 | return purchaseId; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /ajax-json/src/main/java/com/captaindebug/store/beans/UserSelections.java: -------------------------------------------------------------------------------- 1 | package com.captaindebug.store.beans; 2 | 3 | import java.util.Collections; 4 | import java.util.List; 5 | 6 | /** 7 | * Models the user's selections - data returned by the form. 8 | * 9 | * @author Roger 10 | * 11 | * Created 07:33:38 21 Apr 2013 12 | * 13 | */ 14 | public class UserSelections { 15 | 16 | private List selection = Collections.emptyList(); 17 | 18 | public List getSelection() { 19 | return selection; 20 | } 21 | 22 | public void setSelection(List selection) { 23 | this.selection = selection; 24 | } 25 | 26 | @Override 27 | public String toString() { 28 | 29 | StringBuilder sb = new StringBuilder("Selections are: "); 30 | 31 | for (String str : selection) { 32 | sb.append(str); 33 | sb.append(", "); 34 | } 35 | 36 | return sb.toString(); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /ajax-json/src/main/resources/log4j.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /ajax-json/src/main/webapp/WEB-INF/spring/root-context.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /ajax-json/src/main/webapp/WEB-INF/views/home.jsp: -------------------------------------------------------------------------------- 1 | <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> 2 | <%@ page session="false" %> 3 | 4 | 5 | Home 6 | 7 | 8 |

9 | Shopping AJAX JSON Example 10 |

11 | 12 |

The time on the server is ${serverTime}.

13 | 14 | Shopping Page 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /ajax-json/src/main/webapp/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | contextConfigLocation 9 | /WEB-INF/spring/root-context.xml 10 | 11 | 12 | 13 | 14 | org.springframework.web.context.ContextLoaderListener 15 | 16 | 17 | 18 | 19 | appServlet 20 | org.springframework.web.servlet.DispatcherServlet 21 | 22 | contextConfigLocation 23 | /WEB-INF/spring/appServlet/servlet-context.xml 24 | 25 | 1 26 | 27 | 28 | 29 | appServlet 30 | / 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /ajax-json/src/main/webapp/resources/blueprint/plugins/buttons/icons/cross.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roghughe/captaindebug/54e4a55ee8347e0ff0354ea1f12ee69a00fa5831/ajax-json/src/main/webapp/resources/blueprint/plugins/buttons/icons/cross.png -------------------------------------------------------------------------------- /ajax-json/src/main/webapp/resources/blueprint/plugins/buttons/icons/key.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roghughe/captaindebug/54e4a55ee8347e0ff0354ea1f12ee69a00fa5831/ajax-json/src/main/webapp/resources/blueprint/plugins/buttons/icons/key.png -------------------------------------------------------------------------------- /ajax-json/src/main/webapp/resources/blueprint/plugins/buttons/icons/tick.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roghughe/captaindebug/54e4a55ee8347e0ff0354ea1f12ee69a00fa5831/ajax-json/src/main/webapp/resources/blueprint/plugins/buttons/icons/tick.png -------------------------------------------------------------------------------- /ajax-json/src/main/webapp/resources/blueprint/plugins/buttons/readme.txt: -------------------------------------------------------------------------------- 1 | Buttons 2 | 3 | * Gives you great looking CSS buttons, for both and 25 | 26 | 27 | Change Password 28 | 29 | 30 | 31 | Cancel 32 | 33 | -------------------------------------------------------------------------------- /ajax-json/src/main/webapp/resources/blueprint/plugins/fancy-type/readme.txt: -------------------------------------------------------------------------------- 1 | Fancy Type 2 | 3 | * Gives you classes to use if you'd like some 4 | extra fancy typography. 5 | 6 | Credits and instructions are specified above each class 7 | in the fancy-type.css file in this directory. 8 | 9 | 10 | Usage 11 | ---------------------------------------------------------------- 12 | 13 | 1) Add this plugin to lib/settings.yml. 14 | See compress.rb for instructions. 15 | -------------------------------------------------------------------------------- /ajax-json/src/main/webapp/resources/blueprint/plugins/link-icons/icons/doc.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roghughe/captaindebug/54e4a55ee8347e0ff0354ea1f12ee69a00fa5831/ajax-json/src/main/webapp/resources/blueprint/plugins/link-icons/icons/doc.png -------------------------------------------------------------------------------- /ajax-json/src/main/webapp/resources/blueprint/plugins/link-icons/icons/email.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roghughe/captaindebug/54e4a55ee8347e0ff0354ea1f12ee69a00fa5831/ajax-json/src/main/webapp/resources/blueprint/plugins/link-icons/icons/email.png -------------------------------------------------------------------------------- /ajax-json/src/main/webapp/resources/blueprint/plugins/link-icons/icons/external.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roghughe/captaindebug/54e4a55ee8347e0ff0354ea1f12ee69a00fa5831/ajax-json/src/main/webapp/resources/blueprint/plugins/link-icons/icons/external.png -------------------------------------------------------------------------------- /ajax-json/src/main/webapp/resources/blueprint/plugins/link-icons/icons/feed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roghughe/captaindebug/54e4a55ee8347e0ff0354ea1f12ee69a00fa5831/ajax-json/src/main/webapp/resources/blueprint/plugins/link-icons/icons/feed.png -------------------------------------------------------------------------------- /ajax-json/src/main/webapp/resources/blueprint/plugins/link-icons/icons/im.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roghughe/captaindebug/54e4a55ee8347e0ff0354ea1f12ee69a00fa5831/ajax-json/src/main/webapp/resources/blueprint/plugins/link-icons/icons/im.png -------------------------------------------------------------------------------- /ajax-json/src/main/webapp/resources/blueprint/plugins/link-icons/icons/lock.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roghughe/captaindebug/54e4a55ee8347e0ff0354ea1f12ee69a00fa5831/ajax-json/src/main/webapp/resources/blueprint/plugins/link-icons/icons/lock.png -------------------------------------------------------------------------------- /ajax-json/src/main/webapp/resources/blueprint/plugins/link-icons/icons/pdf.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roghughe/captaindebug/54e4a55ee8347e0ff0354ea1f12ee69a00fa5831/ajax-json/src/main/webapp/resources/blueprint/plugins/link-icons/icons/pdf.png -------------------------------------------------------------------------------- /ajax-json/src/main/webapp/resources/blueprint/plugins/link-icons/icons/visited.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roghughe/captaindebug/54e4a55ee8347e0ff0354ea1f12ee69a00fa5831/ajax-json/src/main/webapp/resources/blueprint/plugins/link-icons/icons/visited.png -------------------------------------------------------------------------------- /ajax-json/src/main/webapp/resources/blueprint/plugins/link-icons/icons/xls.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roghughe/captaindebug/54e4a55ee8347e0ff0354ea1f12ee69a00fa5831/ajax-json/src/main/webapp/resources/blueprint/plugins/link-icons/icons/xls.png -------------------------------------------------------------------------------- /ajax-json/src/main/webapp/resources/blueprint/plugins/link-icons/readme.txt: -------------------------------------------------------------------------------- 1 | Link Icons 2 | * Icons for links based on protocol or file type. 3 | 4 | This is not supported in IE versions < 7. 5 | 6 | 7 | Credits 8 | ---------------------------------------------------------------- 9 | 10 | * Marc Morgan 11 | * Olav Bjorkoy [bjorkoy.com] 12 | 13 | 14 | Usage 15 | ---------------------------------------------------------------- 16 | 17 | 1) Add this line to your HTML: 18 | 19 | -------------------------------------------------------------------------------- /ajax-json/src/main/webapp/resources/blueprint/plugins/rtl/readme.txt: -------------------------------------------------------------------------------- 1 | RTL 2 | * Mirrors Blueprint, so it can be used with Right-to-Left languages. 3 | 4 | By Ran Yaniv Hartstein, ranh.co.il 5 | 6 | Usage 7 | ---------------------------------------------------------------- 8 | 9 | 1) Add this line to your HTML: 10 | 11 | -------------------------------------------------------------------------------- /ajax-json/src/main/webapp/resources/blueprint/src/grid.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roghughe/captaindebug/54e4a55ee8347e0ff0354ea1f12ee69a00fa5831/ajax-json/src/main/webapp/resources/blueprint/src/grid.png -------------------------------------------------------------------------------- /ajax-json/src/main/webapp/resources/style.css: -------------------------------------------------------------------------------- 1 | #mask { 2 | height: 100%; 3 | width: 100%; 4 | background: #000000; 5 | position: absolute; 6 | top: 0; 7 | -moz-opacity:0.75; 8 | -khtml-opacity: 0.75; 9 | opacity: 0.75; 10 | filter: alpha(opacity=75); 11 | } 12 | 13 | #popup { 14 | margin: 0 auto; 15 | border: 1px solid #000000; 16 | background: #ffffff; 17 | position: absolute; 18 | top: 200px; 19 | width:470px; 20 | height: 500px; 21 | left: 25%; 22 | } -------------------------------------------------------------------------------- /ajax-json/src/test/java/com/captaindebug/store/dummydao/CatalogueTest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2011 Marin Solutions Ltd 3 | */ 4 | package com.captaindebug.store.dummydao; 5 | 6 | import static org.junit.Assert.assertEquals; 7 | import static org.junit.Assert.assertNotNull; 8 | 9 | import java.util.List; 10 | 11 | import org.junit.Before; 12 | import org.junit.Test; 13 | 14 | import com.captaindebug.store.beans.Item; 15 | 16 | /** 17 | * @author Roger 18 | * 19 | */ 20 | public class CatalogueTest { 21 | 22 | private Catalogue instance; 23 | 24 | /** 25 | * @throws java.lang.Exception 26 | */ 27 | @Before 28 | public void setUp() throws Exception { 29 | 30 | instance = new Catalogue(); 31 | } 32 | 33 | /** 34 | * Test method for {@link marin.ajaxshoppingcart.dummydao.Catalogue#read()}. 35 | */ 36 | @Test 37 | public void testRead() { 38 | 39 | List items = instance.read(); 40 | assertEquals(5, items.size()); 41 | } 42 | 43 | @Test 44 | public void testFindItem() { 45 | 46 | Item item = instance.findItem(1); 47 | assertNotNull(item); 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /ajax-json/src/test/resources/log4j.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /audit-aspectj/.gitignore: -------------------------------------------------------------------------------- 1 | /.project 2 | /.settings 3 | /.classpath 4 | /target 5 | /.springBeans 6 | -------------------------------------------------------------------------------- /audit-aspectj/src/main/java/com/captaindebug/audit/aspectj/Audit.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013 Marin Solutions 3 | */ 4 | package com.captaindebug.audit.aspectj; 5 | 6 | import java.lang.annotation.ElementType; 7 | import java.lang.annotation.Retention; 8 | import java.lang.annotation.RetentionPolicy; 9 | import java.lang.annotation.Target; 10 | 11 | /** 12 | * Annotation which indicates that a controller needs auditing 13 | * 14 | * @author Roger 15 | * 16 | */ 17 | @Retention(RetentionPolicy.RUNTIME) 18 | @Target(ElementType.METHOD) 19 | public @interface Audit { 20 | 21 | String value(); 22 | } 23 | -------------------------------------------------------------------------------- /audit-aspectj/src/main/java/com/captaindebug/audit/aspectj/AuditAdvice.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013 Marin Solutions 3 | */ 4 | package com.captaindebug.audit.aspectj; 5 | 6 | import org.aspectj.lang.annotation.Aspect; 7 | import org.aspectj.lang.annotation.Before; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | 10 | import com.captaindebug.audit.service.AuditService; 11 | 12 | /** 13 | * @author Roger 14 | * 15 | */ 16 | @Aspect 17 | public class AuditAdvice { 18 | 19 | @Autowired 20 | private AuditService auditService; 21 | 22 | /** 23 | * Advice for auditing a user's visit to a page. The rule is that the Before annotation 24 | * applies to any method in any class in the com.captaindebug.audit.controller package 25 | * where the class name ends in 'Controller' and the method is annotated by @Audit. 26 | * 27 | * @param auditAnnotation 28 | * Audit annotation holds the name of the screen we're auditing. 29 | */ 30 | @Before("execution(public String com.captaindebug.audit.controller.*Controller.*(..)) && @annotation(auditAnnotation) ") 31 | public void auditScreen(Audit auditAnnotation) { 32 | 33 | auditService.audit(auditAnnotation.value()); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /audit-aspectj/src/main/java/com/captaindebug/audit/controller/HelpController.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013 Marin Solutions 3 | */ 4 | package com.captaindebug.audit.controller; 5 | 6 | import org.springframework.stereotype.Controller; 7 | import org.springframework.ui.Model; 8 | import org.springframework.web.bind.annotation.RequestMapping; 9 | import org.springframework.web.bind.annotation.RequestMethod; 10 | import org.springframework.web.bind.annotation.RequestParam; 11 | 12 | import com.captaindebug.audit.aspectj.Audit; 13 | 14 | /** 15 | * Help Controller, displays some help... 16 | * 17 | * @author Roger 18 | * 19 | */ 20 | @Controller() 21 | public class HelpController { 22 | 23 | @Audit("Help") // User has visited the help page 24 | @RequestMapping(value = "/help", method = RequestMethod.GET) 25 | public String showHelp(@RequestParam int pageId, Model model) { 26 | 27 | String help = getHelpPage(pageId); 28 | 29 | model.addAttribute("helpText", help); 30 | return "help"; 31 | } 32 | 33 | private String getHelpPage(int pageId) { 34 | return "This is the help text - The Beetles are in Stereo"; 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /audit-aspectj/src/main/java/com/captaindebug/audit/service/AuditService.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013 Marin Solutions 3 | */ 4 | package com.captaindebug.audit.service; 5 | 6 | import org.slf4j.Logger; 7 | import org.slf4j.LoggerFactory; 8 | import org.springframework.stereotype.Service; 9 | 10 | /** 11 | * A Dummy audit service 12 | * 13 | * @author Roger 14 | * 15 | */ 16 | @Service 17 | public class AuditService { 18 | 19 | private static Logger logger = LoggerFactory.getLogger(AuditService.class); 20 | 21 | /** 22 | * Audit this screen against the current user name 23 | * 24 | * It's more useful to put this info into a database so that that you can count visits to 25 | * pages and figure out how often they're used. That way, you can focus your design on the 26 | * popular parts of your application. The logger is just for demo purposes. 27 | */ 28 | public void audit(String screenName) { 29 | 30 | String userName = getCurrentUser(); 31 | 32 | logger.info("Audit: {} - {}", userName, screenName); 33 | 34 | } 35 | 36 | /** 37 | * Get the current logged on user name by whatever mechanism available 38 | */ 39 | private String getCurrentUser() { 40 | return "Fred"; 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /audit-aspectj/src/main/resources/log4j.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /audit-aspectj/src/main/webapp/WEB-INF/spring/root-context.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /audit-aspectj/src/main/webapp/WEB-INF/views/help.jsp: -------------------------------------------------------------------------------- 1 | <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> 2 | <%@ page session="false" %> 3 | 4 | 5 | Help 6 | 7 | 8 |

9 | HELP! 10 |

11 | 12 |

This is the help you requested: ${helpText}

13 |

14 | 15 |

16 | 17 | 18 | -------------------------------------------------------------------------------- /audit-aspectj/src/main/webapp/WEB-INF/views/home.jsp: -------------------------------------------------------------------------------- 1 | <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> 2 | <%@ page session="false" %> 3 | 4 | 5 | Home 6 | 7 | 8 |

9 | Hello world! 10 |

11 | 12 |

The time on the server is ${serverTime}.

13 |

14 | Display help for this page 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /audit-aspectj/src/main/webapp/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | contextConfigLocation 9 | /WEB-INF/spring/root-context.xml 10 | 11 | 12 | 13 | 14 | org.springframework.web.context.ContextLoaderListener 15 | 16 | 17 | 18 | 19 | appServlet 20 | org.springframework.web.servlet.DispatcherServlet 21 | 22 | contextConfigLocation 23 | /WEB-INF/spring/appServlet/servlet-context.xml 24 | 25 | 1 26 | 27 | 28 | 29 | appServlet 30 | / 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /audit-aspectj/src/main/webapp/resources/images/the_beatles_help__movie_image__4_.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roghughe/captaindebug/54e4a55ee8347e0ff0354ea1f12ee69a00fa5831/audit-aspectj/src/main/webapp/resources/images/the_beatles_help__movie_image__4_.jpg -------------------------------------------------------------------------------- /audit-aspectj/src/test/resources/log4j.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /build-all/.gitignore: -------------------------------------------------------------------------------- 1 | /.settings 2 | /.project 3 | -------------------------------------------------------------------------------- /cargo-cult/.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | /.settings 3 | /.classpath 4 | /.project 5 | -------------------------------------------------------------------------------- /cargo-cult/src/main/java/com/captaindebug/cargocult/HomeController.java: -------------------------------------------------------------------------------- 1 | package com.captaindebug.cargocult; 2 | 3 | import java.text.DateFormat; 4 | import java.util.Date; 5 | import java.util.Locale; 6 | 7 | import org.slf4j.Logger; 8 | import org.slf4j.LoggerFactory; 9 | import org.springframework.stereotype.Controller; 10 | import org.springframework.ui.Model; 11 | import org.springframework.web.bind.annotation.RequestMapping; 12 | import org.springframework.web.bind.annotation.RequestMethod; 13 | 14 | /** 15 | * Handles requests for the application home page. 16 | */ 17 | @Controller 18 | public class HomeController { 19 | 20 | private static final Logger logger = LoggerFactory.getLogger(HomeController.class); 21 | 22 | /** 23 | * Simply selects the home view to render by returning its name. 24 | */ 25 | @RequestMapping(value = "/", method = RequestMethod.GET) 26 | public String home(Locale locale, Model model) { 27 | logger.info("Welcome home! The client locale is {}.", locale); 28 | 29 | Date date = new Date(); 30 | DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG, locale); 31 | 32 | String formattedDate = dateFormat.format(date); 33 | 34 | model.addAttribute("serverTime", formattedDate ); 35 | 36 | return "home"; 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /cargo-cult/src/main/java/com/captaindebug/cargocult/User.java: -------------------------------------------------------------------------------- 1 | package com.captaindebug.cargocult; 2 | 3 | import java.util.Date; 4 | 5 | /** 6 | * Model a simple 7 | * 8 | * @author Roger 9 | * 10 | * Created 18:20:57 25 May 2014 11 | * 12 | */ 13 | public class User { 14 | 15 | public static User NULL_USER = new User(-1, "Not Available", "", new Date()); 16 | 17 | private final long id; 18 | 19 | private final String name; 20 | 21 | private final String email; 22 | 23 | private final Date createDate; 24 | 25 | public User(long id, String name, String email, Date createDate) { 26 | this.id = id; 27 | this.name = name; 28 | this.email = email; 29 | this.createDate = createDate; 30 | } 31 | 32 | public long getId() { 33 | return id; 34 | } 35 | 36 | public String getName() { 37 | return name; 38 | } 39 | 40 | public String getEmail() { 41 | return email; 42 | } 43 | 44 | public Date getCreateDate() { 45 | return createDate; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /cargo-cult/src/main/java/com/captaindebug/cargocult/ntier/FindUserRowMapper.java: -------------------------------------------------------------------------------- 1 | package com.captaindebug.cargocult.ntier; 2 | 3 | import java.io.Serializable; 4 | import java.sql.ResultSet; 5 | import java.sql.SQLException; 6 | 7 | import org.springframework.jdbc.core.RowMapper; 8 | 9 | import com.captaindebug.cargocult.User; 10 | 11 | class FindUserMapper implements RowMapper, Serializable { 12 | 13 | private static final long serialVersionUID = 1L; 14 | 15 | @Override 16 | public User mapRow(ResultSet rs, int rowNum) throws SQLException { 17 | 18 | User user = new User(rs.getLong("id"), // 19 | rs.getString("name"), // 20 | rs.getString("email"), // 21 | rs.getDate("createdDate")); 22 | return user; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /cargo-cult/src/main/java/com/captaindebug/cargocult/ntier/UserController.java: -------------------------------------------------------------------------------- 1 | package com.captaindebug.cargocult.ntier; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.stereotype.Controller; 5 | import org.springframework.ui.Model; 6 | import org.springframework.web.bind.annotation.RequestMapping; 7 | import org.springframework.web.bind.annotation.RequestParam; 8 | 9 | import com.captaindebug.cargocult.User; 10 | 11 | @Controller 12 | public class UserController { 13 | 14 | @Autowired 15 | private UserService userService; 16 | 17 | @RequestMapping("/find1") 18 | public String findUser(@RequestParam("user") String name, Model model) { 19 | 20 | User user = userService.findUser(name); 21 | model.addAttribute("user", user); 22 | return "user"; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /cargo-cult/src/main/java/com/captaindebug/cargocult/ntier/UserDao.java: -------------------------------------------------------------------------------- 1 | package com.captaindebug.cargocult.ntier; 2 | 3 | import com.captaindebug.cargocult.User; 4 | 5 | public interface UserDao { 6 | 7 | public abstract User findUser(String name); 8 | 9 | } -------------------------------------------------------------------------------- /cargo-cult/src/main/java/com/captaindebug/cargocult/ntier/UserDaoImpl.java: -------------------------------------------------------------------------------- 1 | package com.captaindebug.cargocult.ntier; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.dao.EmptyResultDataAccessException; 5 | import org.springframework.jdbc.core.JdbcTemplate; 6 | import org.springframework.stereotype.Repository; 7 | 8 | import com.captaindebug.cargocult.User; 9 | 10 | @Repository 11 | public class UserDaoImpl implements UserDao { 12 | 13 | private static final String FIND_USER_BY_NAME = "SELECT id, name,email,createdDate FROM Users WHERE name=?"; 14 | 15 | @Autowired 16 | private JdbcTemplate jdbcTemplate; 17 | 18 | /** 19 | * @see com.captaindebug.cargocult.ntier.UserDao#findUser(java.lang.String) 20 | */ 21 | @Override 22 | public User findUser(String name) { 23 | 24 | User user; 25 | try { 26 | FindUserMapper rowMapper = new FindUserMapper(); 27 | user = jdbcTemplate.queryForObject(FIND_USER_BY_NAME, rowMapper, name); 28 | } catch (EmptyResultDataAccessException e) { 29 | user = User.NULL_USER; 30 | } 31 | return user; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /cargo-cult/src/main/java/com/captaindebug/cargocult/ntier/UserService.java: -------------------------------------------------------------------------------- 1 | package com.captaindebug.cargocult.ntier; 2 | 3 | import com.captaindebug.cargocult.User; 4 | 5 | public interface UserService { 6 | 7 | public abstract User findUser(String name); 8 | 9 | } 10 | -------------------------------------------------------------------------------- /cargo-cult/src/main/java/com/captaindebug/cargocult/ntier/UserServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.captaindebug.cargocult.ntier; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.stereotype.Service; 5 | 6 | import com.captaindebug.cargocult.User; 7 | 8 | @Service 9 | public class UserServiceImpl implements UserService { 10 | 11 | @Autowired 12 | private UserDao userDao; 13 | 14 | /** 15 | * @see com.captaindebug.cargocult.ntier.UserService#findUser(java.lang.String) 16 | */ 17 | @Override 18 | public User findUser(String name) { 19 | return userDao.findUser(name); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /cargo-cult/src/main/resources/log4j.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /cargo-cult/src/main/webapp/WEB-INF/spring/root-context.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /cargo-cult/src/main/webapp/WEB-INF/spring/spring-datasource.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /cargo-cult/src/main/webapp/WEB-INF/views/home.jsp: -------------------------------------------------------------------------------- 1 | <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> 2 | <%@ page session="false" %> 3 | 4 | 5 | Home 6 | 7 | 8 |

Find a User

9 | 10 |

The time on the server is ${serverTime}.

11 |

12 | Find user Tom using 'N' Tier
13 | Find empty using 'N' Tier

14 | Find user Tom using accessor model 15 |

16 | 17 | 18 | -------------------------------------------------------------------------------- /cargo-cult/src/main/webapp/WEB-INF/views/user.jsp: -------------------------------------------------------------------------------- 1 | <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> 2 | <%@ page session="false" %> 3 | 4 | 5 | Home 6 | 7 | 8 |

Found User

9 | 10 |

Name: ${user.name}
11 | Email: ${user.email}
12 |

13 | 14 | 15 | -------------------------------------------------------------------------------- /cargo-cult/src/scripts/dbsetup.sql: -------------------------------------------------------------------------------- 1 | drop table users; 2 | 3 | CREATE TABLE IF NOT EXISTS users ( 4 | id integer UNIQUE, 5 | name varchar(50), 6 | email varchar(50), 7 | createdDate TIMESTAMP DEFAULT CURRENT_TIMESTAMP 8 | ); 9 | 10 | 11 | INSERT INTO users (id,name,email) 12 | VALUES( 13 | 1,'Tom', 'tom@gmail.com' 14 | ); 15 | 16 | INSERT INTO users (id,name,email) 17 | VALUES( 18 | 2,'Dick', 'dick@gmail.com' 19 | ); 20 | 21 | INSERT INTO users (id,name,email) 22 | VALUES( 23 | 3,'Harry', 'harry@gmail.com' 24 | ); 25 | 26 | -------------------------------------------------------------------------------- /cargo-cult/src/test/resources/db.properties: -------------------------------------------------------------------------------- 1 | # Database connection properties 2 | database.driver=com.mysql.jdbc.Driver 3 | database.uri=jdbc:mysql://localhost/junit 4 | database.user=root 5 | database.password=experience 6 | 7 | -------------------------------------------------------------------------------- /cargo-cult/src/test/resources/log4j.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /database/.gitignore: -------------------------------------------------------------------------------- 1 | /.project 2 | /.settings 3 | /.classpath 4 | /target 5 | -------------------------------------------------------------------------------- /deadlocks/.gitignore: -------------------------------------------------------------------------------- 1 | <<<<<<< HEAD 2 | /.project 3 | /.settings 4 | /target 5 | /.classpath 6 | /.gitignore 7 | ======= 8 | /target 9 | /.settings 10 | /.classpath 11 | /.project 12 | >>>>>>> refs/remotes/origin/master 13 | -------------------------------------------------------------------------------- /deadlocks/src/main/java/threads/deadlock/Account.java: -------------------------------------------------------------------------------- 1 | package threads.deadlock; 2 | 3 | public class Account { 4 | 5 | private final int number; 6 | 7 | private int balance; 8 | 9 | public Account(int number, int openingBalance) { 10 | this.number = number; 11 | this.balance = openingBalance; 12 | } 13 | 14 | public void withDrawAmount(int amount) throws OverdrawnException { 15 | 16 | if (amount > balance) { 17 | throw new OverdrawnException(); 18 | } 19 | 20 | balance -= amount; 21 | } 22 | 23 | public void deposit(int amount) { 24 | 25 | balance += amount; 26 | } 27 | 28 | public int getNumber() { 29 | return number; 30 | } 31 | 32 | public int getBalance() { 33 | return balance; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /deadlocks/src/main/java/threads/deadlock/OverdrawnException.java: -------------------------------------------------------------------------------- 1 | package threads.deadlock; 2 | 3 | public class OverdrawnException extends Exception { 4 | 5 | private static final long serialVersionUID = 1L; 6 | 7 | } 8 | -------------------------------------------------------------------------------- /deadlocks/src/test/java/threads/lock/AccountTest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package threads.lock; 5 | 6 | import static org.junit.Assert.assertTrue; 7 | 8 | import org.junit.After; 9 | import org.junit.Before; 10 | import org.junit.Test; 11 | 12 | /** 13 | * @author Roger 14 | * 15 | * Created 19:19:26 1 Nov 2012 16 | * 17 | */ 18 | public class AccountTest { 19 | 20 | private Account instance; 21 | 22 | @Before 23 | public void setUp() throws Exception { 24 | instance = new Account(1, 100); 25 | } 26 | 27 | /** 28 | * In using Lock / ReenterantLock implementation it's your responsibility to 29 | * unlock at the end of use. 30 | */ 31 | @After 32 | public void tearDown() throws Exception { 33 | instance.unlock(); 34 | } 35 | 36 | @Test 37 | public void testTryLockAndLock() { 38 | 39 | assertTrue(instance.tryLock()); 40 | } 41 | 42 | /** 43 | * Will pass because it's the same thread 44 | */ 45 | @Test 46 | public void testTryLockAndRelockAndPass() { 47 | 48 | instance.lock(); 49 | 50 | assertTrue(instance.tryLock()); 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /deadlocks/src/test/java/threads/lock/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | /** 5 | * @author Roger 6 | * 7 | * Created 19:18:29 1 Nov 2012 8 | * 9 | */ 10 | package threads.lock; -------------------------------------------------------------------------------- /defensive/.gitignore: -------------------------------------------------------------------------------- 1 | /.project 2 | /.settings 3 | /.classpath 4 | /target 5 | -------------------------------------------------------------------------------- /defensive/src/main/java/com/captaindebug/defensive/badsample/BodyMassIndex.java: -------------------------------------------------------------------------------- 1 | package com.captaindebug.defensive.badsample; 2 | 3 | import java.math.BigDecimal; 4 | import java.math.MathContext; 5 | 6 | public class BodyMassIndex { 7 | 8 | /** 9 | * Calculate the BMI using Weight(kg) / height(m)2 10 | * 11 | * @return Returns the BMI to four significant figures eg nn.nn 12 | */ 13 | public Double calculate(Double weight, Double height) { 14 | 15 | Double result = null; 16 | 17 | if ((weight != null) && (height != null) && (weight > 0.0) && (height > 0.0)) { 18 | 19 | Double tmp = weight / (height * height); 20 | 21 | BigDecimal bd = new BigDecimal(tmp); 22 | MathContext mathContext = new MathContext(4); 23 | bd = bd.round(mathContext); 24 | result = bd.doubleValue(); 25 | } 26 | 27 | return result; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /defensive/src/main/java/com/captaindebug/defensive/goodsample/BodyMassIndex.java: -------------------------------------------------------------------------------- 1 | package com.captaindebug.defensive.goodsample; 2 | 3 | import java.math.BigDecimal; 4 | import java.math.MathContext; 5 | 6 | import org.apache.commons.lang3.Validate; 7 | 8 | public class BodyMassIndex { 9 | 10 | /** 11 | * Calculate the BMI using Weight(kg) / height(m)2 12 | * 13 | * @return Returns the BMI to four significant figures eg nn.nn 14 | */ 15 | public Double calculate(Double weight, Double height) { 16 | 17 | Validate.notNull(weight, "Your weight cannot be null"); 18 | Validate.notNull(height, "Your height cannot be null"); 19 | 20 | Validate.validState(weight.doubleValue() > 0, "Your weight cannot be zero"); 21 | Validate.validState(height.doubleValue() > 0, "Your height cannot be zero"); 22 | 23 | Double tmp = weight / (height * height); 24 | 25 | BigDecimal result = new BigDecimal(tmp); 26 | MathContext mathContext = new MathContext(4); 27 | result = result.round(mathContext); 28 | 29 | return result.doubleValue(); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /defensive/src/test/java/com/captaindebug/defensive/goodsample/BodyMassIndexTest.java: -------------------------------------------------------------------------------- 1 | package com.captaindebug.defensive.goodsample; 2 | 3 | import static org.junit.Assert.assertEquals; 4 | 5 | import org.junit.Before; 6 | import org.junit.Test; 7 | 8 | public class BodyMassIndexTest { 9 | 10 | private BodyMassIndex instance; 11 | 12 | @Before 13 | public void setUp() throws Exception { 14 | instance = new BodyMassIndex(); 15 | } 16 | 17 | @Test 18 | public void test_valid_inputs() { 19 | 20 | final Double expectedResult = 26.23; 21 | 22 | Double result = instance.calculate(85.0, 1.8); 23 | assertEquals(expectedResult, result); 24 | } 25 | 26 | @Test(expected = NullPointerException.class) 27 | public void test_null_weight_input() { 28 | 29 | instance.calculate(null, 1.8); 30 | } 31 | 32 | @Test(expected = NullPointerException.class) 33 | public void test_null_height_input() { 34 | 35 | instance.calculate(75.0, null); 36 | } 37 | 38 | @Test(expected = IllegalStateException.class) 39 | public void test_zero_height_input() { 40 | 41 | instance.calculate(75.0, 0.0); 42 | } 43 | 44 | @Test(expected = IllegalStateException.class) 45 | public void test_zero_weight_input() { 46 | 47 | instance.calculate(0.0, 1.8); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /dependency-injection-factory/.gitignore: -------------------------------------------------------------------------------- 1 | /.project 2 | /.settings 3 | /target 4 | /.classpath 5 | -------------------------------------------------------------------------------- /dependency-injection-factory/src/main/java/dependency_injection_with_annotations/MyBeanFactory.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2011 Marin Solutions 3 | */ 4 | package dependency_injection_with_annotations; 5 | 6 | /** 7 | * @author Roger 8 | * 9 | */ 10 | public interface MyBeanFactory { 11 | 12 | /** 13 | * Method that returns a bean instance given a type 14 | */ 15 | public T getBean(Class clazz); 16 | 17 | } 18 | -------------------------------------------------------------------------------- /dependency-injection-factory/src/main/java/dependency_injection_with_annotations/annotations/MyAutoWire.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2011 Marin Solutions 3 | */ 4 | package dependency_injection_with_annotations.annotations; 5 | 6 | import java.lang.annotation.Documented; 7 | import java.lang.annotation.ElementType; 8 | import java.lang.annotation.Retention; 9 | import java.lang.annotation.RetentionPolicy; 10 | import java.lang.annotation.Target; 11 | 12 | /** 13 | * @author Roger 14 | * 15 | */ 16 | @Documented 17 | @Retention(RetentionPolicy.RUNTIME) 18 | @Target({ ElementType.METHOD, ElementType.FIELD }) 19 | public @interface MyAutoWire { 20 | 21 | } 22 | -------------------------------------------------------------------------------- /dependency-injection-factory/src/main/java/dependency_injection_with_annotations/annotations/MyComponent.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2011 Marin Solutions 3 | */ 4 | package dependency_injection_with_annotations.annotations; 5 | 6 | import java.lang.annotation.Documented; 7 | import java.lang.annotation.ElementType; 8 | import java.lang.annotation.Retention; 9 | import java.lang.annotation.RetentionPolicy; 10 | import java.lang.annotation.Target; 11 | 12 | /** 13 | * Simple attribute that can only be applied at class level 14 | * 15 | * @author Roger 16 | * 17 | */ 18 | @Documented 19 | @Retention(RetentionPolicy.RUNTIME) 20 | @Target({ ElementType.TYPE, ElementType.ANNOTATION_TYPE }) 21 | public @interface MyComponent { 22 | 23 | } 24 | -------------------------------------------------------------------------------- /dependency-injection-factory/src/main/java/dependency_injection_with_annotations/testclasses/ClassWithAttributes.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2011 Marin Solutions 3 | */ 4 | package dependency_injection_with_annotations.testclasses; 5 | 6 | import dependency_injection_with_annotations.annotations.MyAutoWire; 7 | import dependency_injection_with_annotations.annotations.MyComponent; 8 | 9 | /** 10 | * @author Roger 11 | * 12 | */ 13 | @MyComponent 14 | public class ClassWithAttributes { 15 | 16 | private String str1; 17 | 18 | private int value1; 19 | 20 | @MyAutoWire 21 | private InjectedClass injectedClass; 22 | 23 | @MyAutoWire 24 | public void setValue1(int value1) { 25 | this.value1 = value1; 26 | } 27 | 28 | public String getStr1() { 29 | return str1; 30 | } 31 | 32 | public void setStr1(String str1) { 33 | this.str1 = str1; 34 | } 35 | 36 | public InjectedClass getInjectedClass() { 37 | return injectedClass; 38 | } 39 | 40 | public void setInjectedClass(InjectedClass injectedClass) { 41 | this.injectedClass = injectedClass; 42 | } 43 | 44 | public int getValue1() { 45 | return value1; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /dependency-injection-factory/src/main/java/dependency_injection_with_annotations/testclasses/InjectedClass.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2011 Marin Solutions 3 | */ 4 | package dependency_injection_with_annotations.testclasses; 5 | 6 | import dependency_injection_with_annotations.annotations.MyComponent; 7 | 8 | /** 9 | * This is just any class 10 | * 11 | * @author Roger 12 | * 13 | */ 14 | @MyComponent 15 | public class InjectedClass { 16 | // Blank 17 | } 18 | -------------------------------------------------------------------------------- /error-track/.gitignore: -------------------------------------------------------------------------------- 1 | /.project 2 | /.settings 3 | /.classpath 4 | /target 5 | -------------------------------------------------------------------------------- /error-track/src/main/java/com/captaindebug/errortrack/ErrorTrackService.java: -------------------------------------------------------------------------------- 1 | package com.captaindebug.errortrack; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.beans.factory.annotation.Qualifier; 5 | import org.springframework.stereotype.Service; 6 | 7 | import com.captaindebug.errortrack.file.FileLocator; 8 | import com.captaindebug.errortrack.report.Results; 9 | 10 | @Service 11 | public class ErrorTrackService { 12 | 13 | @Autowired 14 | private FileLocator fileLocator; 15 | 16 | @Autowired 17 | private Results results; 18 | 19 | @Autowired 20 | @Qualifier("textFormatter") 21 | private Formatter formatter; 22 | 23 | @Autowired 24 | @Qualifier("emailPublisher") 25 | private Publisher publisher; 26 | 27 | public void trackErrors() { 28 | 29 | fileLocator.findFile(); 30 | results.generate(formatter, publisher); 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /error-track/src/main/java/com/captaindebug/errortrack/Formatter.java: -------------------------------------------------------------------------------- 1 | package com.captaindebug.errortrack; 2 | 3 | import com.captaindebug.errortrack.report.Results; 4 | 5 | 6 | /** 7 | * Classes implementing this interface can format reports into whatever type of 8 | * Object they like... 9 | * 10 | * @author Roger 11 | * 12 | * Created 09:48:32 23 Feb 2014 13 | * 14 | */ 15 | public interface Formatter { 16 | 17 | public T format(Results report); 18 | } 19 | -------------------------------------------------------------------------------- /error-track/src/main/java/com/captaindebug/errortrack/Main.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2014 Marin Solutions 3 | */ 4 | package com.captaindebug.errortrack; 5 | 6 | import org.springframework.context.support.ClassPathXmlApplicationContext; 7 | 8 | /** 9 | * Create an application context that loads the Spring application context. 10 | * 11 | * Note: DON'T close the context, as we want it to keep going after the main thread exits. Use 12 | * the @SuppressWarnings annotation instead. 13 | * 14 | * @author Roger 15 | * 16 | */ 17 | public class Main { 18 | 19 | @SuppressWarnings("resource") 20 | public static void main(String[] arg) { 21 | 22 | new ClassPathXmlApplicationContext("error-track-context.xml"); 23 | 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /error-track/src/main/java/com/captaindebug/errortrack/Publisher.java: -------------------------------------------------------------------------------- 1 | package com.captaindebug.errortrack; 2 | 3 | /** 4 | * Publish a report using whatever mechanism is defined in the implementation(s) 5 | * of this interface... 6 | * 7 | * @author Roger 8 | * 9 | * Created 09:57:02 23 Feb 2014 10 | * 11 | */ 12 | public interface Publisher { 13 | 14 | public boolean publish(T report); 15 | } 16 | -------------------------------------------------------------------------------- /error-track/src/main/java/com/captaindebug/errortrack/Validator.java: -------------------------------------------------------------------------------- 1 | package com.captaindebug.errortrack; 2 | 3 | /** 4 | * Simple Validator interface 5 | * 6 | * @author Roger 7 | * 8 | * Created 17:01:43 15 Feb 2014 9 | * 10 | */ 11 | public interface Validator { 12 | 13 | /** The validation method */ 14 | public boolean validate(T obj); 15 | 16 | } 17 | -------------------------------------------------------------------------------- /error-track/src/main/java/com/captaindebug/errortrack/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2014 Marin Solutions 3 | */ 4 | /** 5 | * @author Roger 6 | * 7 | */ 8 | package com.captaindebug.errortrack; -------------------------------------------------------------------------------- /error-track/src/main/java/com/captaindebug/errortrack/report/EmailPublisher.java: -------------------------------------------------------------------------------- 1 | package com.captaindebug.errortrack.report; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.mail.MailSender; 7 | import org.springframework.mail.SimpleMailMessage; 8 | import org.springframework.stereotype.Service; 9 | 10 | import com.captaindebug.errortrack.Publisher; 11 | 12 | @Service 13 | public class EmailPublisher implements Publisher { 14 | 15 | private static final Logger logger = LoggerFactory.getLogger(EmailPublisher.class); 16 | 17 | @Autowired 18 | private MailSender mailSender; 19 | 20 | @Autowired 21 | private SimpleMailMessage mailMessage; 22 | 23 | @Override 24 | public boolean publish(T report) { 25 | 26 | logger.debug("Sending report by email..."); 27 | boolean retVal = false; 28 | try { 29 | String message = (String) report; 30 | mailMessage.setText(message); 31 | mailSender.send(mailMessage); 32 | logger.debug("Email sent..."); 33 | retVal = true; 34 | } catch (Exception e) { 35 | logger.error("Can't send email... " + e.getMessage(), e); 36 | } 37 | 38 | return retVal; 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /error-track/src/main/java/com/captaindebug/errortrack/report/HtmlFormatter.java: -------------------------------------------------------------------------------- 1 | package com.captaindebug.errortrack.report; 2 | 3 | import org.springframework.stereotype.Service; 4 | 5 | import com.captaindebug.errortrack.Formatter; 6 | 7 | @Service 8 | public class HtmlFormatter implements Formatter { 9 | 10 | @Override 11 | public T format(Results report) { 12 | // TODO Add this some other day... 13 | return null; 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /error-track/src/main/java/com/captaindebug/errortrack/validator/RegexValidator.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2014 Marin Solutions 3 | */ 4 | package com.captaindebug.errortrack.validator; 5 | 6 | import java.util.regex.Matcher; 7 | import java.util.regex.Pattern; 8 | 9 | import org.slf4j.Logger; 10 | import org.slf4j.LoggerFactory; 11 | 12 | import com.captaindebug.errortrack.Validator; 13 | 14 | /** 15 | * A Regular expression validator. 16 | * 17 | * @author Roger 18 | * 19 | */ 20 | public class RegexValidator implements Validator { 21 | 22 | private static final Logger logger = LoggerFactory.getLogger(RegexValidator.class); 23 | 24 | private final Pattern pattern; 25 | 26 | public RegexValidator(String regex) { 27 | pattern = Pattern.compile(regex); 28 | logger.info("loaded regex: {}", regex); 29 | } 30 | 31 | @Override 32 | public boolean validate(T string) { 33 | 34 | boolean retVal = false; 35 | Matcher matcher = pattern.matcher((String) string); 36 | retVal = matcher.matches(); 37 | if (retVal && logger.isDebugEnabled()) { 38 | logger.debug("Found error line: {}", string); 39 | } 40 | 41 | return retVal; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /error-track/src/main/resources/app.properties: -------------------------------------------------------------------------------- 1 | # The path to the log file directory to scan for errors 2 | scan.in=/Library/Tomcat/logs 3 | # A regex defining what to look for - or what not to include 4 | scan.for=^.*Exception.* 5 | exclude=^.*IllegalStateException.* 6 | # The number of following lines to add to the report 7 | following.lines=10 8 | # Where to email the report 9 | email.to=info@captaindebug.com 10 | # The max age of a file in days 11 | max.days=1000 12 | 13 | # TODO YOUR EMAIL CONFIG GOES HERE 14 | mail.smtp.host=smtp.ntlworld.com 15 | mail.to=info@captaindebug.com 16 | mail.from=tracking@captaindebug.com 17 | mail.subject=Error Tracking Report 18 | 19 | # run every morning at 2 AM 20 | cron.expression=0 0 2 * * ? 21 | 22 | # Use this to test the app (every minute) 23 | #cron.expression=0 0/1 * * * ? 24 | -------------------------------------------------------------------------------- /error-track/src/main/resources/log4j.properties: -------------------------------------------------------------------------------- 1 | ### direct log messages to stdout ### 2 | log4j.appender.stdout=org.apache.log4j.ConsoleAppender 3 | log4j.appender.stdout.Target=System.out 4 | log4j.appender.stdout.layout=org.apache.log4j.PatternLayout 5 | log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n 6 | 7 | ### set log levels - for more verbose logging change 'info' to 'debug' ### 8 | 9 | log4j.rootLogger=trace, stdout 10 | 11 | 12 | -------------------------------------------------------------------------------- /error-track/src/script/runme.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo Running Error Tracking... 4 | java -verbose -jar error-track-1.0-SNAPSHOT.jar com.captaindebug.errortrack.Main 5 | -------------------------------------------------------------------------------- /error-track/src/test/java/com/captaindebug/errortrack/report/EmailPublisherITest.java: -------------------------------------------------------------------------------- 1 | package com.captaindebug.errortrack.report; 2 | 3 | import static org.junit.Assert.assertTrue; 4 | 5 | import org.junit.Test; 6 | import org.junit.runner.RunWith; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.test.context.ContextConfiguration; 9 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; 10 | 11 | @RunWith(SpringJUnit4ClassRunner.class) 12 | @ContextConfiguration({ "classpath:error-track-context.xml" }) 13 | public class EmailPublisherITest { 14 | 15 | @Autowired 16 | private EmailPublisher instance; 17 | 18 | @Test 19 | public void testEmailSend() { 20 | 21 | assertTrue(instance.publish("This is a Test Report")); 22 | 23 | System.out.println("Now check your email"); 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /error-track/src/test/resources/error-free.log: -------------------------------------------------------------------------------- 1 | INFO : com.captaindebug.longpoll.source.MatchReporter - Add message to queue: Full time The referee blows his whistle to end the game. 2 | INFO : com.captaindebug.longpoll.source.MatchReporter - Add message to queue: Final Score Arsenal 1 - 0 Stoke 3 | -------------------------------------------------------------------------------- /exceptions/.gitignore: -------------------------------------------------------------------------------- 1 | /.project 2 | /.settings 3 | /.classpath 4 | /target 5 | -------------------------------------------------------------------------------- /exceptions/src/main/java/com/captaindebug/exceptions/AnotherExceptionsDemoController.java: -------------------------------------------------------------------------------- 1 | package com.captaindebug.exceptions; 2 | 3 | import java.io.IOException; 4 | import java.util.Locale; 5 | 6 | import org.slf4j.Logger; 7 | import org.slf4j.LoggerFactory; 8 | import org.springframework.stereotype.Controller; 9 | import org.springframework.ui.Model; 10 | import org.springframework.web.bind.annotation.RequestMapping; 11 | import org.springframework.web.bind.annotation.RequestMethod; 12 | 13 | /** 14 | * Handles requests for the application home page. 15 | */ 16 | @Controller 17 | public class AnotherExceptionsDemoController { 18 | 19 | private static final Logger logger = LoggerFactory.getLogger(AnotherExceptionsDemoController.class); 20 | 21 | /** 22 | * Simply selects the home view to render by returning its name. 23 | * 24 | * @throws IOException 25 | */ 26 | @RequestMapping(value = "/anotherioexception", method = RequestMethod.GET) 27 | public String throwIoException(Locale locale, Model model) throws IOException { 28 | 29 | logger.info("This will throw an IOExceptiom for another controller"); 30 | 31 | boolean throwException = true; 32 | 33 | if (throwException) { 34 | throw new IOException("This is my IOException"); 35 | } 36 | 37 | return "home"; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /exceptions/src/main/java/com/captaindebug/exceptions/HomeController.java: -------------------------------------------------------------------------------- 1 | package com.captaindebug.exceptions; 2 | 3 | import java.util.Locale; 4 | 5 | import org.slf4j.Logger; 6 | import org.slf4j.LoggerFactory; 7 | import org.springframework.stereotype.Controller; 8 | import org.springframework.ui.Model; 9 | import org.springframework.web.bind.annotation.RequestMapping; 10 | import org.springframework.web.bind.annotation.RequestMethod; 11 | 12 | /** 13 | * Handles requests for the application home page. 14 | */ 15 | @Controller 16 | public class HomeController { 17 | 18 | private static final Logger logger = LoggerFactory.getLogger(HomeController.class); 19 | 20 | /** 21 | * Simply selects the home view to render by returning its name. 22 | */ 23 | @RequestMapping(value = "/", method = RequestMethod.GET) 24 | public String home(Locale locale, Model model) { 25 | 26 | logger.info("displaying the home page"); 27 | 28 | return "home"; 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /exceptions/src/main/java/com/captaindebug/exceptions/beans/User.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2012 Marin Solutions 3 | */ 4 | package com.captaindebug.exceptions.beans; 5 | 6 | /** 7 | * User Bean 8 | */ 9 | public class User { 10 | 11 | private final String firstName; 12 | private final String surname; 13 | 14 | public User(String firstName, String surname) { 15 | super(); 16 | this.firstName = firstName; 17 | this.surname = surname; 18 | } 19 | 20 | public String getFirstName() { 21 | return firstName; 22 | } 23 | 24 | public String getSurname() { 25 | return surname; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /exceptions/src/main/java/com/captaindebug/exceptions/dao/UserDao.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2012 Marin Solutions 3 | */ 4 | package com.captaindebug.exceptions.dao; 5 | 6 | import org.springframework.stereotype.Component; 7 | 8 | import com.captaindebug.exceptions.beans.User; 9 | 10 | /** 11 | * @author Roger 12 | * 13 | */ 14 | @Component 15 | public class UserDao { 16 | 17 | public User readUserName() { 18 | return new User("Joe", "Black"); 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /exceptions/src/main/resources/log4j.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /exceptions/src/main/webapp/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | Class-Path: 3 | 4 | -------------------------------------------------------------------------------- /exceptions/src/main/webapp/WEB-INF/spring/root-context.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /exceptions/src/main/webapp/WEB-INF/views/error.jsp: -------------------------------------------------------------------------------- 1 | <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> 2 | <%@ page session="false" %> 3 | 4 | 5 | Home 6 | 7 | 8 |

9 | Some Exceptional Exceptions 10 |

11 | 12 |

Well , there seems to have been an and 13 | we've lost all your important details. Hard luck, please try again.

14 |

Not , please log out...

15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /exceptions/src/main/webapp/WEB-INF/views/home.jsp: -------------------------------------------------------------------------------- 1 | <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> 2 | <%@ page session="false" %> 3 | 4 | 5 | Home 6 | 7 | 8 |

9 | Some Exceptional Code 10 |

11 | 12 |

Simple IOException Using Single Exception Handler

13 | 14 |

Exception Handler for an Array of Exception Classes

15 |

404 Not found

16 |

Throw a NullPointerException

17 | 18 |

Exception Thrown by a different controller

19 |

Throw another IOException using a different controller

20 | 21 |

Change the ResponseStatus

22 |

Throw a DataFormatException...

23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /exceptions/src/main/webapp/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | contextConfigLocation 9 | /WEB-INF/spring/root-context.xml 10 | 11 | 12 | 13 | 14 | org.springframework.web.context.ContextLoaderListener 15 | 16 | 17 | 18 | 19 | appServlet 20 | org.springframework.web.servlet.DispatcherServlet 21 | 22 | contextConfigLocation 23 | /WEB-INF/spring/appServlet/servlet-context.xml 24 | 25 | 1 26 | 27 | 28 | 29 | appServlet 30 | / 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /exceptions/src/test/resources/log4j.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /facebook/.gitignore: -------------------------------------------------------------------------------- 1 | /.project 2 | /.settings 3 | /.classpath 4 | /target 5 | -------------------------------------------------------------------------------- /facebook/src/main/resources/log4j.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /facebook/src/main/webapp/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | Class-Path: 3 | 4 | -------------------------------------------------------------------------------- /facebook/src/main/webapp/WEB-INF/spring/root-context.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /facebook/src/main/webapp/WEB-INF/views/home.jsp: -------------------------------------------------------------------------------- 1 | <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> 2 | <%@ page session="false" %> 3 | 4 | 5 | Home 6 | 7 | 8 |

Captain Debug's Facebook Social Sample

9 | 10 |

11 | Display your posts
12 | 13 | 14 |

15 | 16 | 17 | -------------------------------------------------------------------------------- /facebook/src/main/webapp/WEB-INF/views/show-posts.jsp: -------------------------------------------------------------------------------- 1 | <%@ page language="java" contentType="text/html; charset=ISO-8859-1" 2 | pageEncoding="ISO-8859-1"%> 3 | <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> 4 | 5 | 6 | 7 | 8 | 9 | My Facebook Home Feed 10 | 11 | 12 |

Some of my Facebook Posts

13 |
    14 | 15 |

  • 16 | Reference Name:
    17 | Reference ID:
    18 | ID:
    19 | Message:
    20 |
    21 | 22 |
    Likes: 23 |
    Post Link
    24 |
    Description: 25 |
    26 |
  • 27 |
    28 |
29 | 30 | -------------------------------------------------------------------------------- /facebook/src/main/webapp/WEB-INF/views/signin.jsp: -------------------------------------------------------------------------------- 1 | <%@ page session="false" %> 2 | <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> 3 | 4 | 5 | Sign In 6 | 7 | 8 |

This application requires you to sign in to Facebook

9 |
" method="POST"> 10 | 11 | 12 |
13 | 14 | 15 | -------------------------------------------------------------------------------- /facebook/src/main/webapp/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | contextConfigLocation 5 | /WEB-INF/spring/root-context.xml 6 | 7 | 8 | org.springframework.web.context.ContextLoaderListener 9 | 10 | 11 | appServlet 12 | org.springframework.web.servlet.DispatcherServlet 13 | 14 | contextConfigLocation 15 | /WEB-INF/spring/appServlet/servlet-context.xml 16 | 17 | 1 18 | 19 | 20 | appServlet 21 | / 22 | 23 | -------------------------------------------------------------------------------- /facebook/src/test/resources/log4j.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /hazelcast/.gitignore: -------------------------------------------------------------------------------- 1 | /.project 2 | /.settings 3 | /.classpath 4 | /target 5 | -------------------------------------------------------------------------------- /hazelcast/src/main/java/com/captaindebug/hazelcast/gettingstarted/BigWideWorld.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013 Marin Solutions 3 | */ 4 | package com.captaindebug.hazelcast.gettingstarted; 5 | 6 | import java.util.Random; 7 | 8 | /** 9 | * @author Roger 10 | * 11 | */ 12 | public class BigWideWorld { 13 | 14 | private static Random rand = new Random(System.currentTimeMillis()); 15 | 16 | private final Users users = new Users(); 17 | 18 | private final int totalNumUsers = users.size(); 19 | 20 | public String nextUser() { 21 | 22 | User user = users.get(rand.nextInt(totalNumUsers)); 23 | String name = user.getUsername(); 24 | 25 | return name; 26 | 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /hazelcast/src/main/java/com/captaindebug/hazelcast/gettingstarted/Main.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013 Marin Solutions 3 | */ 4 | package com.captaindebug.hazelcast.gettingstarted; 5 | 6 | import java.util.concurrent.TimeUnit; 7 | 8 | /** 9 | * @author Roger 10 | * 11 | */ 12 | public class Main { 13 | 14 | public static void main(String[] args) throws InterruptedException { 15 | 16 | BigWideWorld theWorld = new BigWideWorld(); 17 | 18 | MyApplication application = new MyApplication(); 19 | 20 | while (true) { 21 | 22 | String username = theWorld.nextUser(); 23 | 24 | if (application.isLoggedOn(username)) { 25 | application.logout(username); 26 | } else { 27 | application.logon(username); 28 | } 29 | 30 | application.displayUsers(); 31 | TimeUnit.SECONDS.sleep(2); 32 | } 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /hazelcast/src/main/java/com/captaindebug/hazelcast/pubsub/Client.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013 Marin Solutions 3 | */ 4 | package com.captaindebug.hazelcast.pubsub; 5 | 6 | import com.hazelcast.core.Hazelcast; 7 | import com.hazelcast.core.HazelcastInstance; 8 | import com.hazelcast.core.ITopic; 9 | import com.hazelcast.core.Message; 10 | import com.hazelcast.core.MessageListener; 11 | 12 | /** 13 | * @author Roger 14 | * 15 | */ 16 | public class Client implements MessageListener { 17 | 18 | public Client(String topicName) { 19 | HazelcastInstance hzInstance = Hazelcast.newHazelcastInstance(); 20 | ITopic topic = hzInstance.getTopic(topicName); 21 | topic.addMessageListener(this); 22 | } 23 | 24 | /** 25 | * @see com.hazelcast.core.MessageListener#onMessage(com.hazelcast.core.Message) 26 | */ 27 | @Override 28 | public void onMessage(Message arg0) { 29 | System.out.println("Received: " + arg0.getMessageObject().toString()); 30 | } 31 | 32 | public static void main(String[] args) { 33 | 34 | new Client("STOCKS"); 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /hazelcast/src/test/java/com/captaindebug/hazelcast/gettingstarted/UsersTest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013 Marin Solutions 3 | */ 4 | package com.captaindebug.hazelcast.gettingstarted; 5 | 6 | import java.util.Random; 7 | import java.util.Set; 8 | 9 | import org.junit.Test; 10 | 11 | /** 12 | * @author Roger 13 | * 14 | */ 15 | public class UsersTest { 16 | 17 | private static Random rand; 18 | 19 | @Test 20 | public void testDisplayLoggedOnUsers() { 21 | 22 | MyApplication application = new MyApplication(); 23 | Users users = new Users(); 24 | 25 | Set usernames = users.getUserNames(); 26 | for (String username : usernames) { 27 | application.logon(username); 28 | } 29 | 30 | application.displayUsers(); 31 | } 32 | 33 | @Test 34 | public void testLoginScenario() throws InterruptedException { 35 | 36 | MyApplication application = new MyApplication(); 37 | Users users = new Users(); 38 | 39 | rand = new Random(System.currentTimeMillis()); 40 | 41 | int totalNumUsers = users.size(); 42 | int logInUsers = rand.nextInt(totalNumUsers); 43 | 44 | for (int i = 0; i < logInUsers; i++) { 45 | 46 | User nextUser = users.get(rand.nextInt(totalNumUsers)); 47 | application.logon(nextUser.getUsername()); 48 | } 49 | 50 | application.displayUsers(); 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /long-poll/.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | /.settings 3 | /.classpath 4 | /.project 5 | -------------------------------------------------------------------------------- /long-poll/src/html/page1.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Match Report 4 | 5 | 6 | 9 | 10 | 11 | 20 | 21 | 23 | 24 | 25 |
26 |
27 |

Match Updates

28 |
29 |
30 |
31 |

Latest Update:

32 |
33 |
34 |

35 |
36 |
37 | 38 | 39 | -------------------------------------------------------------------------------- /long-poll/src/main/java/com/captaindebug/longpoll/HomeController.java: -------------------------------------------------------------------------------- 1 | package com.captaindebug.longpoll; 2 | 3 | import java.text.DateFormat; 4 | import java.util.Date; 5 | import java.util.Locale; 6 | 7 | import org.slf4j.Logger; 8 | import org.slf4j.LoggerFactory; 9 | import org.springframework.stereotype.Controller; 10 | import org.springframework.ui.Model; 11 | import org.springframework.web.bind.annotation.RequestMapping; 12 | import org.springframework.web.bind.annotation.RequestMethod; 13 | 14 | /** 15 | * Handles requests for the application home page. 16 | */ 17 | @Controller 18 | public class HomeController { 19 | 20 | private static final Logger logger = LoggerFactory.getLogger(HomeController.class); 21 | 22 | /** 23 | * Simply selects the home view to render by returning its name. 24 | */ 25 | @RequestMapping(value = "/", method = RequestMethod.GET) 26 | public String home(Locale locale, Model model) { 27 | logger.info("Welcome home! The client locale is {}.", locale); 28 | 29 | Date date = new Date(); 30 | DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG, locale); 31 | 32 | String formattedDate = dateFormat.format(date); 33 | 34 | model.addAttribute("serverTime", formattedDate); 35 | 36 | return "home"; 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /long-poll/src/main/resources/log4j.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /long-poll/src/main/webapp/WEB-INF/spring/root-context.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /long-poll/src/main/webapp/WEB-INF/views/body.jsp: -------------------------------------------------------------------------------- 1 | 2 |
3 |
4 |
5 |
6 |

Match Updates

7 |
8 |
9 |
10 | <%-- Place updates in here --%> 11 |
12 |

Time:

13 |
14 |
15 |

16 |
17 |
18 |

The game has not yet started

19 |
20 |
21 | 22 | -------------------------------------------------------------------------------- /long-poll/src/main/webapp/WEB-INF/views/home.jsp: -------------------------------------------------------------------------------- 1 | <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> 2 | <%@ page session="false" %> 3 | 4 | 5 | Home 6 | 7 | 8 |

9 | Live Match Updates 10 |

11 | 12 |

The time on the server is ${serverTime}.

13 | 14 | Stoke City vs Arsenal - Using the a simple (don't do this) technique
15 | Stoke City vs Arsenal - Using the DeferredRequest technique 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /long-poll/src/main/webapp/resources/blueprint/plugins/buttons/icons/cross.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roghughe/captaindebug/54e4a55ee8347e0ff0354ea1f12ee69a00fa5831/long-poll/src/main/webapp/resources/blueprint/plugins/buttons/icons/cross.png -------------------------------------------------------------------------------- /long-poll/src/main/webapp/resources/blueprint/plugins/buttons/icons/key.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roghughe/captaindebug/54e4a55ee8347e0ff0354ea1f12ee69a00fa5831/long-poll/src/main/webapp/resources/blueprint/plugins/buttons/icons/key.png -------------------------------------------------------------------------------- /long-poll/src/main/webapp/resources/blueprint/plugins/buttons/icons/tick.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roghughe/captaindebug/54e4a55ee8347e0ff0354ea1f12ee69a00fa5831/long-poll/src/main/webapp/resources/blueprint/plugins/buttons/icons/tick.png -------------------------------------------------------------------------------- /long-poll/src/main/webapp/resources/blueprint/plugins/buttons/readme.txt: -------------------------------------------------------------------------------- 1 | Buttons 2 | 3 | * Gives you great looking CSS buttons, for both and 25 | 26 | 27 | Change Password 28 | 29 | 30 | 31 | Cancel 32 | 33 | -------------------------------------------------------------------------------- /long-poll/src/main/webapp/resources/blueprint/plugins/fancy-type/readme.txt: -------------------------------------------------------------------------------- 1 | Fancy Type 2 | 3 | * Gives you classes to use if you'd like some 4 | extra fancy typography. 5 | 6 | Credits and instructions are specified above each class 7 | in the fancy-type.css file in this directory. 8 | 9 | 10 | Usage 11 | ---------------------------------------------------------------- 12 | 13 | 1) Add this plugin to lib/settings.yml. 14 | See compress.rb for instructions. 15 | -------------------------------------------------------------------------------- /long-poll/src/main/webapp/resources/blueprint/plugins/link-icons/icons/doc.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roghughe/captaindebug/54e4a55ee8347e0ff0354ea1f12ee69a00fa5831/long-poll/src/main/webapp/resources/blueprint/plugins/link-icons/icons/doc.png -------------------------------------------------------------------------------- /long-poll/src/main/webapp/resources/blueprint/plugins/link-icons/icons/email.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roghughe/captaindebug/54e4a55ee8347e0ff0354ea1f12ee69a00fa5831/long-poll/src/main/webapp/resources/blueprint/plugins/link-icons/icons/email.png -------------------------------------------------------------------------------- /long-poll/src/main/webapp/resources/blueprint/plugins/link-icons/icons/external.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roghughe/captaindebug/54e4a55ee8347e0ff0354ea1f12ee69a00fa5831/long-poll/src/main/webapp/resources/blueprint/plugins/link-icons/icons/external.png -------------------------------------------------------------------------------- /long-poll/src/main/webapp/resources/blueprint/plugins/link-icons/icons/feed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roghughe/captaindebug/54e4a55ee8347e0ff0354ea1f12ee69a00fa5831/long-poll/src/main/webapp/resources/blueprint/plugins/link-icons/icons/feed.png -------------------------------------------------------------------------------- /long-poll/src/main/webapp/resources/blueprint/plugins/link-icons/icons/im.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roghughe/captaindebug/54e4a55ee8347e0ff0354ea1f12ee69a00fa5831/long-poll/src/main/webapp/resources/blueprint/plugins/link-icons/icons/im.png -------------------------------------------------------------------------------- /long-poll/src/main/webapp/resources/blueprint/plugins/link-icons/icons/lock.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roghughe/captaindebug/54e4a55ee8347e0ff0354ea1f12ee69a00fa5831/long-poll/src/main/webapp/resources/blueprint/plugins/link-icons/icons/lock.png -------------------------------------------------------------------------------- /long-poll/src/main/webapp/resources/blueprint/plugins/link-icons/icons/pdf.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roghughe/captaindebug/54e4a55ee8347e0ff0354ea1f12ee69a00fa5831/long-poll/src/main/webapp/resources/blueprint/plugins/link-icons/icons/pdf.png -------------------------------------------------------------------------------- /long-poll/src/main/webapp/resources/blueprint/plugins/link-icons/icons/visited.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roghughe/captaindebug/54e4a55ee8347e0ff0354ea1f12ee69a00fa5831/long-poll/src/main/webapp/resources/blueprint/plugins/link-icons/icons/visited.png -------------------------------------------------------------------------------- /long-poll/src/main/webapp/resources/blueprint/plugins/link-icons/icons/xls.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roghughe/captaindebug/54e4a55ee8347e0ff0354ea1f12ee69a00fa5831/long-poll/src/main/webapp/resources/blueprint/plugins/link-icons/icons/xls.png -------------------------------------------------------------------------------- /long-poll/src/main/webapp/resources/blueprint/plugins/link-icons/readme.txt: -------------------------------------------------------------------------------- 1 | Link Icons 2 | * Icons for links based on protocol or file type. 3 | 4 | This is not supported in IE versions < 7. 5 | 6 | 7 | Credits 8 | ---------------------------------------------------------------- 9 | 10 | * Marc Morgan 11 | * Olav Bjorkoy [bjorkoy.com] 12 | 13 | 14 | Usage 15 | ---------------------------------------------------------------- 16 | 17 | 1) Add this line to your HTML: 18 | 19 | -------------------------------------------------------------------------------- /long-poll/src/main/webapp/resources/blueprint/plugins/rtl/readme.txt: -------------------------------------------------------------------------------- 1 | RTL 2 | * Mirrors Blueprint, so it can be used with Right-to-Left languages. 3 | 4 | By Ran Yaniv Hartstein, ranh.co.il 5 | 6 | Usage 7 | ---------------------------------------------------------------- 8 | 9 | 1) Add this line to your HTML: 10 | 11 | -------------------------------------------------------------------------------- /long-poll/src/main/webapp/resources/blueprint/src/grid.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roghughe/captaindebug/54e4a55ee8347e0ff0354ea1f12ee69a00fa5831/long-poll/src/main/webapp/resources/blueprint/src/grid.png -------------------------------------------------------------------------------- /long-poll/src/main/webapp/resources/images/Stoke_City_1972.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roghughe/captaindebug/54e4a55ee8347e0ff0354ea1f12ee69a00fa5831/long-poll/src/main/webapp/resources/images/Stoke_City_1972.jpg -------------------------------------------------------------------------------- /long-poll/src/main/webapp/resources/images/classic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roghughe/captaindebug/54e4a55ee8347e0ff0354ea1f12ee69a00fa5831/long-poll/src/main/webapp/resources/images/classic.png -------------------------------------------------------------------------------- /long-poll/src/main/webapp/resources/mystyle.css: -------------------------------------------------------------------------------- 1 | body { 2 | background-color: #cccccc; 3 | } 4 | 5 | .update { 6 | color: #BD6464; 7 | } 8 | 9 | 10 | -------------------------------------------------------------------------------- /long-poll/src/main/webapp/resources/style.css: -------------------------------------------------------------------------------- 1 | #mask { 2 | height: 100%; 3 | width: 100%; 4 | background: #000000; 5 | position: absolute; 6 | top: 0; 7 | -moz-opacity:0.75; 8 | -khtml-opacity: 0.75; 9 | opacity: 0.75; 10 | filter: alpha(opacity=75); 11 | } 12 | 13 | #popup { 14 | margin: 0 auto; 15 | border: 1px solid #000000; 16 | background: #ffffff; 17 | position: absolute; 18 | top: 200px; 19 | width:470px; 20 | height: 500px; 21 | left: 25%; 22 | } -------------------------------------------------------------------------------- /long-poll/src/test/java/com/captaindebug/longpoll/shutdown/HookTest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013 Marin Solutions 3 | */ 4 | package com.captaindebug.longpoll.shutdown; 5 | 6 | import static org.junit.Assert.assertFalse; 7 | import static org.junit.Assert.assertTrue; 8 | 9 | import org.junit.Before; 10 | import org.junit.Test; 11 | 12 | /** 13 | * @author Roger 14 | * 15 | */ 16 | public class HookTest { 17 | 18 | private Hook instance; 19 | 20 | private Thread thread; 21 | 22 | /** 23 | * @throws java.lang.Exception 24 | */ 25 | @Before 26 | public void setUp() throws Exception { 27 | 28 | thread = new Thread(); 29 | instance = new Hook(thread); 30 | } 31 | 32 | /** 33 | * Test method for {@link com.captaindebug.longpoll.shutdown.Hook#shutdown()}. 34 | */ 35 | @Test 36 | public void testShutdown() throws InterruptedException { 37 | 38 | assertTrue(instance.keepRunning()); 39 | 40 | instance.shutdown(); 41 | 42 | assertFalse(instance.keepRunning()); 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /long-poll/src/test/java/com/captaindebug/report/ApplicationContextReportTest.java: -------------------------------------------------------------------------------- 1 | package com.captaindebug.report; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.test.context.ContextConfiguration; 7 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; 8 | import org.springframework.test.context.web.WebAppConfiguration; 9 | 10 | @RunWith(SpringJUnit4ClassRunner.class) 11 | @WebAppConfiguration 12 | @ContextConfiguration({ "file:src/main/webapp/WEB-INF/spring/appServlet/servlet-context.xml" }) 13 | public class ApplicationContextReportTest { 14 | 15 | @Autowired 16 | private ApplicationContextReport instance; 17 | 18 | @Test 19 | public void testReport() { 20 | 21 | System.out.println("The report should now be in /tmp"); 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /pool/src/main/java/com/captaindebug/stormpot/BufferAllocator.java: -------------------------------------------------------------------------------- 1 | package com.captaindebug.stormpot; 2 | 3 | import stormpot.Allocator; 4 | import stormpot.Slot; 5 | 6 | public class BufferAllocator implements Allocator { 7 | 8 | public PoolableBuffer allocate(Slot slot) throws Exception { 9 | return new PoolableBuffer(slot); 10 | } 11 | 12 | public void deallocate(PoolableBuffer poolable) throws Exception { 13 | // Nothing to do here 14 | // But it's a perfect place to close sockets, files, etc. 15 | } 16 | 17 | } -------------------------------------------------------------------------------- /pool/src/main/java/com/captaindebug/stormpot/PoolableBuffer.java: -------------------------------------------------------------------------------- 1 | package com.captaindebug.stormpot; 2 | 3 | import stormpot.Poolable; 4 | import stormpot.Slot; 5 | 6 | public class PoolableBuffer implements Poolable { 7 | 8 | private final Slot slot; 9 | 10 | public PoolableBuffer(Slot slot) { 11 | this.slot = slot; 12 | } 13 | 14 | @Override 15 | public void release() { 16 | slot.release(this); 17 | } 18 | 19 | // Implement the ByeBuffer methods 20 | } 21 | -------------------------------------------------------------------------------- /pool/src/main/java/com/captaindebug/stormpot/StormPot.java: -------------------------------------------------------------------------------- 1 | package com.captaindebug.stormpot; 2 | 3 | public class StormPot { 4 | 5 | 6 | 7 | public static void main(String[] args) { 8 | 9 | System.out.println("Hello World"); 10 | 11 | } 12 | 13 | 14 | } 15 | -------------------------------------------------------------------------------- /pool/src/readme.txt: -------------------------------------------------------------------------------- 1 | README.txt 2 | 3 | Use a command line something like this to run the demo code... 4 | 5 | 6 | java -cp /path-to/spring-beans-3.2.3.RELEASE.jar:/path-to/spring-context-3.2.3.RELEASE.jar:/path-to/spring-core-3.2.3.RELEASE.jar:/path-to/commons-logging-1.1.1.jar:/path-to/spring-expression-3.2.3.RELEASE.jar:. com.captaindebug.producerconsumer.problem.Main 7 | 8 | 9 | 10 | 11 | java -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=9010 -Dcom.sun.management.jmxremote.local.only=false -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -cp /Users/Roger/tmp/problem-queue/spring-beans-3.2.3.RELEASE.jar:/Users/Roger/tmp/problem-queue/spring-context-3.2.3.RELEASE.jar:/Users/Roger/tmp/problem-queue/spring-core-3.2.3.RELEASE.jar:/Users/Roger/tmp/problem-queue/commons-logging-1.1.1.jar:/Users/Roger/tmp/problem-queue/spring-expression-3.2.3.RELEASE.jar:. com.captaindebug.producerconsumer.problem.Main 12 | 13 | 14 | 15 | -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=9010 -Dcom.sun.management.jmxremote.local.only=false -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -------------------------------------------------------------------------------- /powermock-tips/.gitignore: -------------------------------------------------------------------------------- 1 | /.project 2 | /.settings 3 | /.classpath 4 | /target 5 | -------------------------------------------------------------------------------- /powermock-tips/src/main/java/com/captaindebug/AnyOldClass.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package com.captaindebug; 5 | 6 | /** 7 | * This is just any old class that is instantiated using new... 8 | * 9 | * @author RogerHughes 10 | * 11 | */ 12 | public class AnyOldClass { 13 | 14 | public String someMethod() { 15 | return "someMethod"; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /powermock-tips/src/main/java/com/captaindebug/GameStatistics.java: -------------------------------------------------------------------------------- 1 | package com.captaindebug; 2 | 3 | import java.util.concurrent.TimeUnit; 4 | 5 | /** 6 | * Dummy class that pretends to work out some statistics for a sports game. 7 | * 8 | * @author Roger 9 | * 10 | * Created 9:18:44 AM Oct 2, 2011 11 | * 12 | */ 13 | public class GameStatistics { 14 | 15 | private final boolean noStatsAvailable = true; 16 | 17 | /** 18 | * A public method 19 | * 20 | * @throws InterruptedException 21 | */ 22 | public String calculateStats() throws InterruptedException { 23 | 24 | if (noStatsAvailable) { 25 | crunchNumbers(); 26 | } 27 | 28 | return getStatsFromCache(); 29 | } 30 | 31 | /** 32 | * Calculate some statistic taking a long time. 33 | */ 34 | private boolean crunchNumbers() throws InterruptedException { 35 | 36 | TimeUnit.SECONDS.sleep(60); 37 | return true; 38 | } 39 | 40 | private String getStatsFromCache() { 41 | return "100%"; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /powermock-tips/src/main/java/com/captaindebug/UsesNewToInstantiateClass.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package com.captaindebug; 5 | 6 | /** 7 | * @author RogerHughes 8 | * 9 | */ 10 | public class UsesNewToInstantiateClass { 11 | 12 | public String createThing() { 13 | 14 | AnyOldClass myclass = new AnyOldClass(); 15 | 16 | String returnValue = myclass.someMethod(); 17 | return returnValue; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /powermock-tips/src/test/java/com/captaindebug/MockConstructorTest.java: -------------------------------------------------------------------------------- 1 | package com.captaindebug; 2 | 3 | import static org.easymock.EasyMock.expect; 4 | import static org.junit.Assert.assertEquals; 5 | import static org.powermock.api.easymock.PowerMock.expectNew; 6 | import static org.powermock.api.easymock.PowerMock.replay; 7 | import static org.powermock.api.easymock.PowerMock.verify; 8 | 9 | import org.junit.Test; 10 | import org.junit.runner.RunWith; 11 | import org.powermock.api.easymock.annotation.Mock; 12 | import org.powermock.core.classloader.annotations.PrepareForTest; 13 | import org.powermock.modules.junit4.PowerMockRunner; 14 | 15 | @RunWith(PowerMockRunner.class) 16 | @PrepareForTest(UsesNewToInstantiateClass.class) 17 | public class MockConstructorTest { 18 | 19 | @Mock 20 | private AnyOldClass anyClass; 21 | 22 | private UsesNewToInstantiateClass instance; 23 | 24 | @Test 25 | public final void testMockConstructor() throws Exception { 26 | 27 | instance = new UsesNewToInstantiateClass(); 28 | 29 | expectNew(AnyOldClass.class).andReturn(anyClass); 30 | 31 | final String expected = "MY_OTHER_RESULT"; 32 | expect(anyClass.someMethod()).andReturn(expected); 33 | 34 | replay(AnyOldClass.class, anyClass); 35 | String result = instance.createThing(); 36 | verify(AnyOldClass.class, anyClass); 37 | assertEquals(expected, result); 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /producer-consumer/.gitignore: -------------------------------------------------------------------------------- 1 | /.project 2 | /.settings 3 | /.classpath 4 | /target 5 | -------------------------------------------------------------------------------- /producer-consumer/src/main/java/com/captaindebug/producerconsumer/PrintHead.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013 Marin Solutions 3 | */ 4 | package com.captaindebug.producerconsumer; 5 | 6 | /** 7 | * Model the printhead. Primarily a class to simplfy testing. 8 | * 9 | * @author Roger 10 | * 11 | */ 12 | public class PrintHead { 13 | 14 | /** 15 | * Print a message 16 | */ 17 | public void print(String msg) { 18 | System.out.println(msg); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /producer-consumer/src/main/java/com/captaindebug/producerconsumer/interruptible/Main.java: -------------------------------------------------------------------------------- 1 | package com.captaindebug.producerconsumer.interruptible; 2 | 3 | import org.springframework.context.support.ClassPathXmlApplicationContext; 4 | 5 | public class Main { 6 | 7 | public static void main(String[] args) throws InterruptedException { 8 | 9 | System.out.println("Producer Consumer Demo Code..."); 10 | ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("context2.xml"); 11 | 12 | // Wait until all matches are over. 13 | Thread.sleep(98000); 14 | 15 | ctx.close(); 16 | System.out.println("Games Over"); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /producer-consumer/src/main/java/com/captaindebug/producerconsumer/original/Main.java: -------------------------------------------------------------------------------- 1 | package com.captaindebug.producerconsumer.original; 2 | 3 | import org.springframework.context.support.ClassPathXmlApplicationContext; 4 | 5 | public class Main { 6 | 7 | @SuppressWarnings("resource") 8 | public static void main(String[] args) { 9 | 10 | System.out.println("Producer Consumer Demo Code..."); 11 | new ClassPathXmlApplicationContext("context.xml"); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /producer-consumer/src/main/java/com/captaindebug/producerconsumer/poisonpill/Main.java: -------------------------------------------------------------------------------- 1 | package com.captaindebug.producerconsumer.poisonpill; 2 | 3 | import org.springframework.context.support.ClassPathXmlApplicationContext; 4 | 5 | public class Main { 6 | 7 | @SuppressWarnings("resource") 8 | public static void main(String[] args) throws InterruptedException { 9 | 10 | System.out.println("Producer Consumer Demo Code..."); 11 | new ClassPathXmlApplicationContext("context3.xml"); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /producer-consumer/src/main/java/com/captaindebug/producerconsumer/problem/Main.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013 Marin Solutions 3 | */ 4 | package com.captaindebug.producerconsumer.problem; 5 | 6 | import org.springframework.context.support.ClassPathXmlApplicationContext; 7 | 8 | /** 9 | * @author Roger 10 | * 11 | */ 12 | public class Main { 13 | 14 | @SuppressWarnings("resource") 15 | public static void main(String[] args) throws InterruptedException { 16 | 17 | System.out.println("Producer Consumer Problem Code..."); 18 | new ClassPathXmlApplicationContext("problem-context.xml"); 19 | System.out.println("Main Ending..."); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /producer-consumer/src/main/java/com/captaindebug/producerconsumer/problem/OrderQueueMonitor.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013 Marin Solutions 3 | */ 4 | package com.captaindebug.producerconsumer.problem; 5 | 6 | import java.util.concurrent.BlockingQueue; 7 | import java.util.concurrent.TimeUnit; 8 | 9 | /** 10 | * Monitor the size of the queue 11 | * 12 | * @author Roger 13 | * 14 | */ 15 | public class OrderQueueMonitor implements Runnable { 16 | 17 | private final BlockingQueue orderQueue; 18 | 19 | public OrderQueueMonitor(BlockingQueue orderQueue) { 20 | this.orderQueue = orderQueue; 21 | } 22 | 23 | public void start() { 24 | 25 | Thread thread = new Thread(this, "Order Queue Monitor"); 26 | thread.start(); 27 | } 28 | 29 | @Override 30 | public void run() { 31 | 32 | while (true) { 33 | 34 | try { 35 | TimeUnit.SECONDS.sleep(2); 36 | int size = orderQueue.size(); 37 | System.out.println("Queue size is:" + size); 38 | } catch (InterruptedException e) { 39 | e.printStackTrace(); 40 | } 41 | } 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /producer-consumer/src/main/java/com/captaindebug/producerconsumer/problem/OrderRecord.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013 Marin Solutions 3 | */ 4 | package com.captaindebug.producerconsumer.problem; 5 | 6 | import java.util.concurrent.BlockingQueue; 7 | import java.util.concurrent.TimeUnit; 8 | 9 | /** 10 | * Record the order in the database 11 | * 12 | * @author Roger 13 | * 14 | */ 15 | public class OrderRecord implements Runnable { 16 | 17 | private final BlockingQueue orderQueue; 18 | 19 | public OrderRecord(BlockingQueue orderQueue) { 20 | this.orderQueue = orderQueue; 21 | } 22 | 23 | public void start() { 24 | 25 | Thread thread = new Thread(this, "Order Recorder"); 26 | thread.start(); 27 | } 28 | 29 | @Override 30 | public void run() { 31 | 32 | while (true) { 33 | 34 | try { 35 | Order order = orderQueue.take(); 36 | recordOrder(order); 37 | } catch (InterruptedException e) { 38 | e.printStackTrace(); 39 | } 40 | } 41 | 42 | } 43 | 44 | /** 45 | * Record the order in the database 46 | * 47 | * This is a dummy method 48 | * 49 | * @param order 50 | * The order 51 | * @throws InterruptedException 52 | */ 53 | public void recordOrder(Order order) throws InterruptedException { 54 | TimeUnit.SECONDS.sleep(1); 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /producer-consumer/src/main/resources/problem-context.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /producer-consumer/src/readme.txt: -------------------------------------------------------------------------------- 1 | README.txt 2 | 3 | Use a command line something like this to run the demo code... 4 | 5 | 6 | java -cp /path-to/spring-beans-3.2.3.RELEASE.jar:/path-to/spring-context-3.2.3.RELEASE.jar:/path-to/spring-core-3.2.3.RELEASE.jar:/path-to/commons-logging-1.1.1.jar:/path-to/spring-expression-3.2.3.RELEASE.jar:. com.captaindebug.producerconsumer.problem.Main 7 | 8 | 9 | 10 | 11 | java -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=9010 -Dcom.sun.management.jmxremote.local.only=false -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -cp /Users/Roger/tmp/problem-queue/spring-beans-3.2.3.RELEASE.jar:/Users/Roger/tmp/problem-queue/spring-context-3.2.3.RELEASE.jar:/Users/Roger/tmp/problem-queue/spring-core-3.2.3.RELEASE.jar:/Users/Roger/tmp/problem-queue/commons-logging-1.1.1.jar:/Users/Roger/tmp/problem-queue/spring-expression-3.2.3.RELEASE.jar:. com.captaindebug.producerconsumer.problem.Main 12 | 13 | 14 | 15 | -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=9010 -Dcom.sun.management.jmxremote.local.only=false -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -------------------------------------------------------------------------------- /sim-map-exc-res/.gitignore: -------------------------------------------------------------------------------- 1 | /.project 2 | /.settings 3 | /.classpath 4 | /target 5 | -------------------------------------------------------------------------------- /sim-map-exc-res/src/main/java/com/captaindebug/exceptions/HomeController.java: -------------------------------------------------------------------------------- 1 | package com.captaindebug.exceptions; 2 | 3 | import java.util.Locale; 4 | 5 | import org.slf4j.Logger; 6 | import org.slf4j.LoggerFactory; 7 | import org.springframework.stereotype.Controller; 8 | import org.springframework.ui.Model; 9 | import org.springframework.web.bind.annotation.RequestMapping; 10 | import org.springframework.web.bind.annotation.RequestMethod; 11 | 12 | /** 13 | * Handles requests for the application home page. 14 | */ 15 | @Controller 16 | public class HomeController { 17 | 18 | private static final Logger logger = LoggerFactory.getLogger(HomeController.class); 19 | 20 | /** 21 | * Simply selects the home view to render by returning its name. 22 | */ 23 | @RequestMapping(value = "/", method = RequestMethod.GET) 24 | public String home(Locale locale, Model model) { 25 | logger.info("Welcome home! - display home page"); 26 | 27 | return "home"; 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /sim-map-exc-res/src/main/java/com/captaindebug/exceptions/SampleExceptionHandler.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2012 Marin Solutions 3 | */ 4 | package com.captaindebug.exceptions; 5 | 6 | import javax.servlet.http.HttpServletRequest; 7 | import javax.servlet.http.HttpServletResponse; 8 | 9 | import org.slf4j.Logger; 10 | import org.slf4j.LoggerFactory; 11 | import org.springframework.web.servlet.ModelAndView; 12 | import org.springframework.web.servlet.handler.SimpleMappingExceptionResolver; 13 | 14 | /** 15 | * @author Roger 16 | * 17 | */ 18 | public class SampleExceptionHandler extends SimpleMappingExceptionResolver { 19 | 20 | private static final Logger logger = LoggerFactory.getLogger(SampleExceptionHandler.class); 21 | 22 | /** 23 | * Log the exception. 24 | * 25 | * @see org.springframework.web.servlet.handler.SimpleMappingExceptionResolver#doResolveException(javax.servlet.http.HttpServletRequest, 26 | * javax.servlet.http.HttpServletResponse, java.lang.Object, 27 | * java.lang.Exception) 28 | */ 29 | @Override 30 | protected ModelAndView doResolveException(HttpServletRequest request, HttpServletResponse response, Object handler, 31 | Exception ex) { 32 | logger.error("A " + ex.getClass().getSimpleName() + " has occured in the application", ex); 33 | 34 | return super.doResolveException(request, response, handler, ex); 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /sim-map-exc-res/src/main/resources/log4j.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /sim-map-exc-res/src/main/webapp/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | Class-Path: 3 | 4 | -------------------------------------------------------------------------------- /sim-map-exc-res/src/main/webapp/WEB-INF/spring/root-context.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /sim-map-exc-res/src/main/webapp/WEB-INF/views/generic-error.jsp: -------------------------------------------------------------------------------- 1 | <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> 2 | <%@ page session="false" %> 3 | 4 | 5 | Home 6 | 7 | 8 |

9 | Generic Error 10 |

11 | 12 |

Well something has gone wrong, but we're not sure what it is. We're looking in to it, but don't build your hopes up'

13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /sim-map-exc-res/src/main/webapp/WEB-INF/views/home.jsp: -------------------------------------------------------------------------------- 1 | <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> 2 | <%@ page session="false" %> 3 | 4 | 5 | Home 6 | 7 | 8 |

9 | Some Exceptional Code 10 |

11 | 12 |

Simple IOException using SimpleMappingExceptionResolver

13 |

Simple FileNotFoundException using SimpleMappingExceptionResolver

14 |

Simple Exception Using using SimpleMappingExceptionResolver

15 | 16 |

Load an Image

17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /sim-map-exc-res/src/main/webapp/WEB-INF/views/io-exception.jsp: -------------------------------------------------------------------------------- 1 | <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> 2 | <%@ page session="false" %> 3 | 4 | 5 | Home 6 | 7 | 8 |

9 | IO Exception Has Occurred.... 10 |

11 | 12 |

Well something has gone wrong, but we're not sure what it is. We're looking in to it, but don't build your hopes up'

13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /sim-map-exc-res/src/main/webapp/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | contextConfigLocation 9 | /WEB-INF/spring/root-context.xml 10 | 11 | 12 | 13 | 14 | org.springframework.web.context.ContextLoaderListener 15 | 16 | 17 | 18 | 19 | appServlet 20 | org.springframework.web.servlet.DispatcherServlet 21 | 22 | contextConfigLocation 23 | /WEB-INF/spring/appServlet/servlet-context.xml 24 | 25 | 1 26 | 27 | 28 | 29 | appServlet 30 | / 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /sim-map-exc-res/src/main/webapp/resources/images/sea.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roghughe/captaindebug/54e4a55ee8347e0ff0354ea1f12ee69a00fa5831/sim-map-exc-res/src/main/webapp/resources/images/sea.jpg -------------------------------------------------------------------------------- /sim-map-exc-res/src/test/resources/log4j.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /social/.gitignore: -------------------------------------------------------------------------------- 1 | /.project 2 | /.settings 3 | /.classpath 4 | /target 5 | -------------------------------------------------------------------------------- /social/src/main/resources/log4j.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /social/src/main/webapp/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | Class-Path: 3 | 4 | -------------------------------------------------------------------------------- /social/src/main/webapp/WEB-INF/spring/root-context.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /social/src/main/webapp/WEB-INF/views/home.jsp: -------------------------------------------------------------------------------- 1 | <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> 2 | <%@ page session="false" %> 3 | 4 | 5 | Home 6 | 7 | 8 |

Captain Debug's Social Samples

9 | 10 |

11 | Grab Twitter User Time Line for @BBCBreaking
12 | Grab Twitter User Time Line for @BentleyMotors
13 | Grab Twitter User Time Line for @roghughe
14 | 15 | 16 |

17 | 18 | 19 | -------------------------------------------------------------------------------- /social/src/main/webapp/WEB-INF/views/timeline.jsp: -------------------------------------------------------------------------------- 1 | <%@ page language="java" contentType="text/html; charset=ISO-8859-1" 2 | pageEncoding="ISO-8859-1"%> 3 | <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> 4 | 5 | 6 | 7 | 8 | 9 | Twitter Time Line 10 | 11 | 12 |

Twitter Time Line for

13 |
    14 | 15 |

  • 16 |
    17 |
18 | 19 | 20 | -------------------------------------------------------------------------------- /social/src/main/webapp/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | contextConfigLocation 5 | /WEB-INF/spring/root-context.xml 6 | 7 | 8 | org.springframework.web.context.ContextLoaderListener 9 | 10 | 11 | appServlet 12 | org.springframework.web.servlet.DispatcherServlet 13 | 14 | contextConfigLocation 15 | /WEB-INF/spring/appServlet/servlet-context.xml 16 | 17 | 1 18 | 19 | 20 | appServlet 21 | / 22 | 23 | -------------------------------------------------------------------------------- /social/src/test/resources/log4j.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /spring-3.2/.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | /.settings 3 | /.classpath 4 | /.project 5 | /.springBeans 6 | -------------------------------------------------------------------------------- /spring-3.2/src/main/java/com/captaindebug/spring_3_2/HomeController.java: -------------------------------------------------------------------------------- 1 | package com.captaindebug.spring_3_2; 2 | 3 | import java.text.DateFormat; 4 | import java.util.Date; 5 | import java.util.Locale; 6 | 7 | import org.slf4j.Logger; 8 | import org.slf4j.LoggerFactory; 9 | import org.springframework.stereotype.Controller; 10 | import org.springframework.ui.Model; 11 | import org.springframework.web.bind.annotation.RequestMapping; 12 | import org.springframework.web.bind.annotation.RequestMethod; 13 | 14 | /** 15 | * Handles requests for the application home page. 16 | */ 17 | @Controller 18 | public class HomeController { 19 | 20 | private static final Logger logger = LoggerFactory.getLogger(HomeController.class); 21 | 22 | /** 23 | * Simply selects the home view to render by returning its name. 24 | */ 25 | @RequestMapping(value = "/", method = RequestMethod.GET) 26 | public String home(Locale locale, Model model) { 27 | logger.info("Welcome home! The client locale is {}.", locale); 28 | 29 | Date date = new Date(); 30 | DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG, locale); 31 | 32 | String formattedDate = dateFormat.format(date); 33 | 34 | model.addAttribute("serverTime", formattedDate ); 35 | 36 | return "home"; 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /spring-3.2/src/main/java/com/captaindebug/spring_3_2/controleradvice/UserAddressController.java: -------------------------------------------------------------------------------- 1 | package com.captaindebug.spring_3_2.controleradvice; 2 | 3 | import java.io.IOException; 4 | 5 | import org.slf4j.Logger; 6 | import org.slf4j.LoggerFactory; 7 | import org.springframework.stereotype.Controller; 8 | import org.springframework.ui.Model; 9 | import org.springframework.web.bind.annotation.RequestMapping; 10 | import org.springframework.web.bind.annotation.RequestMethod; 11 | 12 | /** 13 | * Handles requests for user address 14 | */ 15 | @Controller 16 | public class UserAddressController { 17 | 18 | private static final Logger logger = LoggerFactory.getLogger(UserAddressController.class); 19 | 20 | /** 21 | * Whoops, throw an IOException 22 | */ 23 | @RequestMapping(value = "useraddress", method = RequestMethod.GET) 24 | public String getUserAddress(Model model) throws IOException { 25 | 26 | logger.info("This will throw an IOException"); 27 | 28 | boolean throwException = true; 29 | 30 | if (throwException) { 31 | throw new IOException("This is my IOException"); 32 | } 33 | 34 | return "home"; 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /spring-3.2/src/main/java/com/captaindebug/spring_3_2/controleradvice/UserCreditCardController.java: -------------------------------------------------------------------------------- 1 | package com.captaindebug.spring_3_2.controleradvice; 2 | 3 | import java.io.IOException; 4 | 5 | import org.slf4j.Logger; 6 | import org.slf4j.LoggerFactory; 7 | import org.springframework.stereotype.Controller; 8 | import org.springframework.ui.Model; 9 | import org.springframework.web.bind.annotation.RequestMapping; 10 | import org.springframework.web.bind.annotation.RequestMethod; 11 | 12 | /** 13 | * Handles requests for user credit card details 14 | */ 15 | @Controller 16 | public class UserCreditCardController { 17 | 18 | private static final Logger logger = LoggerFactory.getLogger(UserCreditCardController.class); 19 | 20 | /** 21 | * Whoops, throw an IOException 22 | */ 23 | @RequestMapping(value = "userdetails", method = RequestMethod.GET) 24 | public String getCardDetails(Model model) throws IOException { 25 | 26 | logger.info("This will throw an IOException"); 27 | 28 | boolean throwException = true; 29 | 30 | if (throwException) { 31 | throw new IOException("This is my IOException"); 32 | } 33 | 34 | return "home"; 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /spring-3.2/src/main/java/com/captaindebug/spring_3_2/controleradvice/beans/User.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2012 Marin Solutions 3 | */ 4 | package com.captaindebug.spring_3_2.controleradvice.beans; 5 | 6 | /** 7 | * User Bean 8 | */ 9 | public class User { 10 | 11 | private final String firstName; 12 | private final String surname; 13 | 14 | public User(String firstName, String surname) { 15 | super(); 16 | this.firstName = firstName; 17 | this.surname = surname; 18 | } 19 | 20 | public String getFirstName() { 21 | return firstName; 22 | } 23 | 24 | public String getSurname() { 25 | return surname; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /spring-3.2/src/main/java/com/captaindebug/spring_3_2/controleradvice/dao/UserDao.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2012 Marin Solutions 3 | */ 4 | package com.captaindebug.spring_3_2.controleradvice.dao; 5 | 6 | import org.springframework.stereotype.Component; 7 | 8 | import com.captaindebug.spring_3_2.controleradvice.beans.User; 9 | 10 | /** 11 | * @author Roger 12 | * 13 | */ 14 | @Component 15 | public class UserDao { 16 | 17 | public User readUserName() { 18 | return new User("Joe", "Black"); 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /spring-3.2/src/main/resources/log4j.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /spring-3.2/src/main/webapp/WEB-INF/spring/root-context.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /spring-3.2/src/main/webapp/WEB-INF/views/error.jsp: -------------------------------------------------------------------------------- 1 | <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> 2 | <%@ page session="false" %> 3 | 4 | 5 | Home 6 | 7 | 8 |

9 | Some Exceptional Exceptions 10 |

11 | 12 |

Well , there seems to have been an and 13 | we've lost all your important details. Hard luck, please try again.

14 |

Not , please log out...

15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /spring-3.2/src/main/webapp/WEB-INF/views/home.jsp: -------------------------------------------------------------------------------- 1 | <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> 2 | <%@ page session="false" %> 3 | 4 | 5 | Home 6 | 7 | 8 |

9 | Spring 3.2 Demo Home Page 10 |

11 | 12 |

The time on the server is ${serverTime}.

13 | 14 |

@ControlerAdvice

15 | 19 | 20 |

Matrix Variables

21 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /spring-3.2/src/main/webapp/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | contextConfigLocation 9 | /WEB-INF/spring/root-context.xml 10 | 11 | 12 | 13 | 14 | org.springframework.web.context.ContextLoaderListener 15 | 16 | 17 | 18 | 19 | appServlet 20 | org.springframework.web.servlet.DispatcherServlet 21 | 22 | contextConfigLocation 23 | /WEB-INF/spring/appServlet/servlet-context.xml 24 | 25 | 1 26 | 27 | 28 | 29 | appServlet 30 | / 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /spring-3.2/src/main/webapp/resources/blueprint/plugins/buttons/icons/cross.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roghughe/captaindebug/54e4a55ee8347e0ff0354ea1f12ee69a00fa5831/spring-3.2/src/main/webapp/resources/blueprint/plugins/buttons/icons/cross.png -------------------------------------------------------------------------------- /spring-3.2/src/main/webapp/resources/blueprint/plugins/buttons/icons/key.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roghughe/captaindebug/54e4a55ee8347e0ff0354ea1f12ee69a00fa5831/spring-3.2/src/main/webapp/resources/blueprint/plugins/buttons/icons/key.png -------------------------------------------------------------------------------- /spring-3.2/src/main/webapp/resources/blueprint/plugins/buttons/icons/tick.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roghughe/captaindebug/54e4a55ee8347e0ff0354ea1f12ee69a00fa5831/spring-3.2/src/main/webapp/resources/blueprint/plugins/buttons/icons/tick.png -------------------------------------------------------------------------------- /spring-3.2/src/main/webapp/resources/blueprint/plugins/buttons/readme.txt: -------------------------------------------------------------------------------- 1 | Buttons 2 | 3 | * Gives you great looking CSS buttons, for both and 25 | 26 | 27 | Change Password 28 | 29 | 30 | 31 | Cancel 32 | 33 | -------------------------------------------------------------------------------- /spring-3.2/src/main/webapp/resources/blueprint/plugins/fancy-type/readme.txt: -------------------------------------------------------------------------------- 1 | Fancy Type 2 | 3 | * Gives you classes to use if you'd like some 4 | extra fancy typography. 5 | 6 | Credits and instructions are specified above each class 7 | in the fancy-type.css file in this directory. 8 | 9 | 10 | Usage 11 | ---------------------------------------------------------------- 12 | 13 | 1) Add this plugin to lib/settings.yml. 14 | See compress.rb for instructions. 15 | -------------------------------------------------------------------------------- /spring-3.2/src/main/webapp/resources/blueprint/plugins/link-icons/icons/doc.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roghughe/captaindebug/54e4a55ee8347e0ff0354ea1f12ee69a00fa5831/spring-3.2/src/main/webapp/resources/blueprint/plugins/link-icons/icons/doc.png -------------------------------------------------------------------------------- /spring-3.2/src/main/webapp/resources/blueprint/plugins/link-icons/icons/email.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roghughe/captaindebug/54e4a55ee8347e0ff0354ea1f12ee69a00fa5831/spring-3.2/src/main/webapp/resources/blueprint/plugins/link-icons/icons/email.png -------------------------------------------------------------------------------- /spring-3.2/src/main/webapp/resources/blueprint/plugins/link-icons/icons/external.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roghughe/captaindebug/54e4a55ee8347e0ff0354ea1f12ee69a00fa5831/spring-3.2/src/main/webapp/resources/blueprint/plugins/link-icons/icons/external.png -------------------------------------------------------------------------------- /spring-3.2/src/main/webapp/resources/blueprint/plugins/link-icons/icons/feed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roghughe/captaindebug/54e4a55ee8347e0ff0354ea1f12ee69a00fa5831/spring-3.2/src/main/webapp/resources/blueprint/plugins/link-icons/icons/feed.png -------------------------------------------------------------------------------- /spring-3.2/src/main/webapp/resources/blueprint/plugins/link-icons/icons/im.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roghughe/captaindebug/54e4a55ee8347e0ff0354ea1f12ee69a00fa5831/spring-3.2/src/main/webapp/resources/blueprint/plugins/link-icons/icons/im.png -------------------------------------------------------------------------------- /spring-3.2/src/main/webapp/resources/blueprint/plugins/link-icons/icons/lock.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roghughe/captaindebug/54e4a55ee8347e0ff0354ea1f12ee69a00fa5831/spring-3.2/src/main/webapp/resources/blueprint/plugins/link-icons/icons/lock.png -------------------------------------------------------------------------------- /spring-3.2/src/main/webapp/resources/blueprint/plugins/link-icons/icons/pdf.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roghughe/captaindebug/54e4a55ee8347e0ff0354ea1f12ee69a00fa5831/spring-3.2/src/main/webapp/resources/blueprint/plugins/link-icons/icons/pdf.png -------------------------------------------------------------------------------- /spring-3.2/src/main/webapp/resources/blueprint/plugins/link-icons/icons/visited.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roghughe/captaindebug/54e4a55ee8347e0ff0354ea1f12ee69a00fa5831/spring-3.2/src/main/webapp/resources/blueprint/plugins/link-icons/icons/visited.png -------------------------------------------------------------------------------- /spring-3.2/src/main/webapp/resources/blueprint/plugins/link-icons/icons/xls.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roghughe/captaindebug/54e4a55ee8347e0ff0354ea1f12ee69a00fa5831/spring-3.2/src/main/webapp/resources/blueprint/plugins/link-icons/icons/xls.png -------------------------------------------------------------------------------- /spring-3.2/src/main/webapp/resources/blueprint/plugins/link-icons/readme.txt: -------------------------------------------------------------------------------- 1 | Link Icons 2 | * Icons for links based on protocol or file type. 3 | 4 | This is not supported in IE versions < 7. 5 | 6 | 7 | Credits 8 | ---------------------------------------------------------------- 9 | 10 | * Marc Morgan 11 | * Olav Bjorkoy [bjorkoy.com] 12 | 13 | 14 | Usage 15 | ---------------------------------------------------------------- 16 | 17 | 1) Add this line to your HTML: 18 | 19 | -------------------------------------------------------------------------------- /spring-3.2/src/main/webapp/resources/blueprint/plugins/rtl/readme.txt: -------------------------------------------------------------------------------- 1 | RTL 2 | * Mirrors Blueprint, so it can be used with Right-to-Left languages. 3 | 4 | By Ran Yaniv Hartstein, ranh.co.il 5 | 6 | Usage 7 | ---------------------------------------------------------------- 8 | 9 | 1) Add this line to your HTML: 10 | 11 | -------------------------------------------------------------------------------- /spring-3.2/src/main/webapp/resources/blueprint/src/grid.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roghughe/captaindebug/54e4a55ee8347e0ff0354ea1f12ee69a00fa5831/spring-3.2/src/main/webapp/resources/blueprint/src/grid.png -------------------------------------------------------------------------------- /spring-3.2/src/test/resources/log4j.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /spring-security/tomcat-ssl/.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | /.settings 3 | /.classpath 4 | /.project 5 | -------------------------------------------------------------------------------- /spring-security/tomcat-ssl/src/main/java/com/captaindebug/security/HomeController.java: -------------------------------------------------------------------------------- 1 | package com.captaindebug.security; 2 | 3 | import java.text.DateFormat; 4 | import java.util.Date; 5 | import java.util.Locale; 6 | 7 | import org.slf4j.Logger; 8 | import org.slf4j.LoggerFactory; 9 | import org.springframework.stereotype.Controller; 10 | import org.springframework.ui.Model; 11 | import org.springframework.web.bind.annotation.RequestMapping; 12 | import org.springframework.web.bind.annotation.RequestMethod; 13 | 14 | /** 15 | * Handles requests for the application home page. 16 | */ 17 | @Controller 18 | public class HomeController { 19 | 20 | private static final Logger logger = LoggerFactory.getLogger(HomeController.class); 21 | 22 | /** 23 | * Simply selects the home view to render by returning its name. 24 | */ 25 | @RequestMapping(value = "/", method = RequestMethod.GET) 26 | public String home(Locale locale, Model model) { 27 | logger.info("Welcome home! the client locale is "+ locale.toString()); 28 | 29 | Date date = new Date(); 30 | DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG, locale); 31 | 32 | String formattedDate = dateFormat.format(date); 33 | 34 | model.addAttribute("serverTime", formattedDate ); 35 | 36 | return "home"; 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /spring-security/tomcat-ssl/src/main/resources/log4j.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /spring-security/tomcat-ssl/src/main/webapp/WEB-INF/spring/appServlet/application-security.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /spring-security/tomcat-ssl/src/main/webapp/WEB-INF/spring/root-context.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /spring-security/tomcat-ssl/src/main/webapp/WEB-INF/views/home.jsp: -------------------------------------------------------------------------------- 1 | <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> 2 | <%@ page session="false" %> 3 | 4 | 5 | Home 6 | 7 | 8 |

9 | Hello world! 10 |

11 | 12 |

The time on the server is ${serverTime}.

13 | 14 | 15 | -------------------------------------------------------------------------------- /spring-security/tomcat-ssl/src/test/resources/log4j.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /state-machine/.gitignore: -------------------------------------------------------------------------------- 1 | /.project 2 | /.settings 3 | /.classpath 4 | /target 5 | -------------------------------------------------------------------------------- /state-machine/src/main/java/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | Class-Path: 3 | 4 | -------------------------------------------------------------------------------- /state-machine/src/main/java/com/captaindebug/statemachine/tweettohtml/OutputStrategy.java: -------------------------------------------------------------------------------- 1 | package com.captaindebug.statemachine.tweettohtml; 2 | 3 | import java.io.IOException; 4 | import java.io.OutputStream; 5 | 6 | public interface OutputStrategy { 7 | 8 | /** 9 | * Implement this method to define how to build some output. 10 | * 11 | * @throws IOException 12 | */ 13 | public void build(String tag, OutputStream os) throws IOException; 14 | } 15 | -------------------------------------------------------------------------------- /state-machine/src/main/java/com/captaindebug/statemachine/tweettohtml/TweetState.java: -------------------------------------------------------------------------------- 1 | package com.captaindebug.statemachine.tweettohtml; 2 | 3 | public enum TweetState { 4 | 5 | OFF("Off - not yet running"), // 6 | RUNNING("Running - happily processing any old byte bytes"), // 7 | READY("Ready - found a space, so there's maybe soemthing to do, but that depends upon the next byte"), // 8 | HASHTAG("#HashTag has been found - process it"), // 9 | NAMETAG("@Name has been found - process it"), // 10 | HTTPCHECK("Checking for a URL starting with http://"), // 11 | URL("http:// has been found so capture the rest of the URL"); 12 | 13 | private final String description; 14 | 15 | TweetState(String description) { 16 | this.description = description; 17 | } 18 | 19 | @Override 20 | public String toString() { 21 | 22 | return "TweetState: " + description; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /state-machine/src/main/java/com/captaindebug/statemachine/tweettohtml/strategy/HashTagStrategy.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package com.captaindebug.statemachine.tweettohtml.strategy; 5 | 6 | import java.io.IOException; 7 | import java.io.OutputStream; 8 | 9 | import com.captaindebug.statemachine.tweettohtml.OutputStrategy; 10 | 11 | /** 12 | * @author Roger 13 | * 14 | * @UserName -> https://twitter.com/#!/BentleyMotors #HashTag -> 15 | * https://twitter.com/#!/search/%23hashtag eg 16 | * https://twitter.com/#!/search/%23youhadtobethere 17 | * 18 | * 19 | * Created 5:24:10 PM Apr 9, 2012 20 | * 21 | */ 22 | public class HashTagStrategy implements OutputStrategy { 23 | 24 | /** 25 | * @see state_machine.tweettohtml.OutputStrategy#build(java.lang.String, 26 | * java.io.OutputStream) 27 | */ 28 | @Override 29 | public void build(String tag, OutputStream os) throws IOException { 30 | 31 | String url = "#" + tag + ""; 32 | os.write(url.getBytes()); 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /state-machine/src/main/java/com/captaindebug/statemachine/unpackxml/package.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Package Level Comment 6 | 7 | 8 | 9 |

10 | This package contains all the actions associated to our state machine. 11 | All implement the StateAction interface. 12 |

13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /state-machine/src/test/java/com/captaindebug/statemachine/tweettohtml/strategy/HashTagStrategyTest.java: -------------------------------------------------------------------------------- 1 | package com.captaindebug.statemachine.tweettohtml.strategy; 2 | 3 | import static org.junit.Assert.assertEquals; 4 | 5 | import java.io.ByteArrayOutputStream; 6 | import java.io.IOException; 7 | 8 | import org.junit.Before; 9 | import org.junit.Test; 10 | 11 | public class HashTagStrategyTest { 12 | 13 | private HashTagStrategy instance; 14 | 15 | private ByteArrayOutputStream out; 16 | 17 | @Before 18 | public void setUp() throws Exception { 19 | 20 | out = new ByteArrayOutputStream(); 21 | instance = new HashTagStrategy(); 22 | } 23 | 24 | @Test 25 | public void testURLConstruction() throws IOException { 26 | 27 | instance.build("hashTag", out); 28 | 29 | String result = out.toString(); 30 | assertEquals( 31 | "#hashTag", 32 | result); 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /state-machine/src/test/java/com/captaindebug/statemachine/tweettohtml/strategy/UrlStrategyTest.java: -------------------------------------------------------------------------------- 1 | package com.captaindebug.statemachine.tweettohtml.strategy; 2 | 3 | import static org.junit.Assert.assertEquals; 4 | 5 | import java.io.ByteArrayOutputStream; 6 | import java.io.IOException; 7 | 8 | import org.junit.Before; 9 | import org.junit.Test; 10 | 11 | public class UrlStrategyTest { 12 | 13 | private UrlStrategy instance; 14 | 15 | private ByteArrayOutputStream out; 16 | 17 | @Before 18 | public void setUp() throws Exception { 19 | 20 | out = new ByteArrayOutputStream(); 21 | instance = new UrlStrategy(); 22 | } 23 | 24 | @Test 25 | public void testUrlStrategy() throws IOException { 26 | 27 | instance.build("www.google.co.uk", out); 28 | 29 | String result = out.toString(); 30 | assertEquals("www.google.co.uk", result); 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /state-machine/src/test/java/com/captaindebug/statemachine/tweettohtml/strategy/UserNameStrategyTest.java: -------------------------------------------------------------------------------- 1 | package com.captaindebug.statemachine.tweettohtml.strategy; 2 | 3 | import static org.junit.Assert.assertEquals; 4 | 5 | import java.io.ByteArrayOutputStream; 6 | import java.io.IOException; 7 | 8 | import org.junit.Before; 9 | import org.junit.Test; 10 | 11 | public class UserNameStrategyTest { 12 | 13 | private UserNameStrategy instance; 14 | 15 | private ByteArrayOutputStream out; 16 | 17 | @Before 18 | public void setUp() throws Exception { 19 | 20 | out = new ByteArrayOutputStream(); 21 | instance = new UserNameStrategy(); 22 | } 23 | 24 | @Test 25 | public void testURLConstruction() throws IOException { 26 | 27 | instance.build("BentleyMotors", out); 28 | 29 | String result = out.toString(); 30 | assertEquals( 31 | "@BentleyMotors", 32 | result); 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /telldontask-integration/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /telldontask-integration/.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | /.project 3 | -------------------------------------------------------------------------------- /telldontask-integration/.settings/.gitignore: -------------------------------------------------------------------------------- 1 | /org.eclipse.jdt.apt.core.prefs 2 | /org.eclipse.jdt.core.prefs 3 | /org.eclipse.m2e.core.prefs 4 | -------------------------------------------------------------------------------- /telldontask/.gitignore: -------------------------------------------------------------------------------- 1 | /.project 2 | /.settings 3 | /.classpath 4 | /target 5 | -------------------------------------------------------------------------------- /telldontask/src/main/java/com/captaindebug/bridge/ShoppingCart.java: -------------------------------------------------------------------------------- 1 | package com.captaindebug.bridge; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import com.captaindebug.payment.PaymentMethod; 7 | import com.captaindebug.telldontask.Item; 8 | 9 | /** 10 | * Example of the strategy pattern. 11 | * 12 | * @author Roger 13 | * 14 | */ 15 | public class ShoppingCart { 16 | 17 | private final List items; 18 | 19 | public ShoppingCart() { 20 | items = new ArrayList(); 21 | } 22 | 23 | public void addItem(Item item) { 24 | 25 | items.add(item); 26 | } 27 | 28 | public double calcTotalCost() { 29 | 30 | double total = 0.0; 31 | for (Item item : items) { 32 | total += item.getPrice(); 33 | } 34 | 35 | return total; 36 | } 37 | 38 | public boolean pay(PaymentMethod method) { 39 | 40 | double totalCost = calcTotalCost(); 41 | return method.pay(totalCost); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /telldontask/src/main/java/com/captaindebug/payment/MasterCard.java: -------------------------------------------------------------------------------- 1 | package com.captaindebug.payment; 2 | 3 | import java.util.Date; 4 | 5 | public class MasterCard implements PaymentMethod { 6 | 7 | private final String name; 8 | private final String cardNumber; 9 | private final Date expires; 10 | 11 | public MasterCard(String name, String cardNumber, Date expires) { 12 | super(); 13 | this.name = name; 14 | this.cardNumber = cardNumber; 15 | this.expires = expires; 16 | } 17 | 18 | @Override 19 | public boolean pay(double amount) { 20 | 21 | // Open Comms to Mastercard 22 | // Verify connection 23 | // Paybill using these details 24 | return true; // if payment goes through 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /telldontask/src/main/java/com/captaindebug/payment/PaymentMethod.java: -------------------------------------------------------------------------------- 1 | package com.captaindebug.payment; 2 | 3 | public interface PaymentMethod { 4 | 5 | public boolean pay(double amount); 6 | 7 | } 8 | -------------------------------------------------------------------------------- /telldontask/src/main/java/com/captaindebug/payment/Visa.java: -------------------------------------------------------------------------------- 1 | package com.captaindebug.payment; 2 | 3 | import java.util.Date; 4 | 5 | import org.springframework.stereotype.Component; 6 | 7 | @Component("calculator") 8 | public class Visa implements PaymentMethod { 9 | 10 | private final String name; 11 | private final String cardNumber; 12 | private final Date expires; 13 | 14 | public Visa(String name, String cardNumber, Date expires) { 15 | super(); 16 | this.name = name; 17 | this.cardNumber = cardNumber; 18 | this.expires = expires; 19 | } 20 | 21 | @Override 22 | public boolean pay(double amount) { 23 | 24 | // Open Comms to Visa 25 | // Verify connection 26 | // Paybill using these details 27 | return true; // if payment goes through 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /telldontask/src/main/java/com/captaindebug/strategy/SpringShoppingCart.java: -------------------------------------------------------------------------------- 1 | package com.captaindebug.strategy; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.beans.factory.annotation.Qualifier; 8 | import org.springframework.stereotype.Component; 9 | 10 | import com.captaindebug.payment.PaymentMethod; 11 | import com.captaindebug.telldontask.Item; 12 | 13 | /** 14 | * Example of the strategy pattern. 15 | * 16 | * @author Roger 17 | * 18 | */ 19 | @Component 20 | public class SpringShoppingCart { 21 | 22 | private final List items; 23 | 24 | @Autowired 25 | @Qualifier("Visa") 26 | private PaymentMethod method; 27 | 28 | public SpringShoppingCart() { 29 | items = new ArrayList(); 30 | } 31 | 32 | public void addItem(Item item) { 33 | 34 | items.add(item); 35 | } 36 | 37 | public double calcTotalCost() { 38 | 39 | double total = 0.0; 40 | for (Item item : items) { 41 | total += item.getPrice(); 42 | } 43 | 44 | return total; 45 | } 46 | 47 | public boolean pay() { 48 | 49 | double totalCost = calcTotalCost(); 50 | return method.pay(totalCost); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /telldontask/src/main/java/com/captaindebug/telldontask/Item.java: -------------------------------------------------------------------------------- 1 | package com.captaindebug.telldontask; 2 | 3 | /** 4 | * Model a simple shopping cart item 5 | * 6 | * @author Roger 7 | * 8 | * Created 9:27:45 AM Mar 3, 2012 9 | * 10 | */ 11 | public class Item { 12 | 13 | private final String code; 14 | private final Double price; 15 | 16 | public Item(String code, Double price) { 17 | this.code = code; 18 | this.price = price; 19 | } 20 | 21 | public String getCode() { 22 | return code; 23 | } 24 | 25 | public Double getPrice() { 26 | return price; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /telldontask/src/main/resources/log4j.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /telldontask/src/main/webapp/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | Class-Path: 3 | 4 | -------------------------------------------------------------------------------- /telldontask/src/main/webapp/WEB-INF/spring/root-context.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /telldontask/src/main/webapp/WEB-INF/views/home.jsp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roghughe/captaindebug/54e4a55ee8347e0ff0354ea1f12ee69a00fa5831/telldontask/src/main/webapp/WEB-INF/views/home.jsp -------------------------------------------------------------------------------- /telldontask/src/main/webapp/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | contextConfigLocation 9 | /WEB-INF/spring/root-context.xml 10 | 11 | 12 | 13 | 14 | org.springframework.web.context.ContextLoaderListener 15 | 16 | 17 | 18 | 19 | appServlet 20 | org.springframework.web.servlet.DispatcherServlet 21 | 22 | contextConfigLocation 23 | /WEB-INF/spring/appServlet/servlet-context.xml 24 | 25 | 1 26 | 27 | 28 | 29 | appServlet 30 | / 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /telldontask/src/test/java/com/captaindebug/bridge/ShoppingCartTest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package com.captaindebug.bridge; 5 | 6 | import static org.junit.Assert.assertTrue; 7 | 8 | import java.util.Calendar; 9 | import java.util.Date; 10 | 11 | import org.junit.Test; 12 | 13 | import com.captaindebug.bridge.ShoppingCart; 14 | import com.captaindebug.payment.PaymentMethod; 15 | import com.captaindebug.payment.Visa; 16 | import com.captaindebug.telldontask.Item; 17 | 18 | /** 19 | * @author Roger 20 | * 21 | */ 22 | public class ShoppingCartTest { 23 | 24 | /** 25 | * Demonstrate the strategy pattern using the ShoppingCart example 26 | */ 27 | @Test 28 | public void payBillUsingVisa() { 29 | 30 | ShoppingCart instance = new ShoppingCart(); 31 | 32 | Item a = new Item("gloves", 23.43); 33 | instance.addItem(a); 34 | 35 | Item b = new Item("hat", 10.99); 36 | instance.addItem(b); 37 | 38 | Date expiryDate = getCardExpireyDate(); 39 | PaymentMethod visa = new Visa("CaptainDebug", "1234234534564567", expiryDate); 40 | 41 | boolean result = instance.pay(visa); 42 | assertTrue(result); 43 | 44 | } 45 | 46 | private Date getCardExpireyDate() { 47 | Calendar cal = Calendar.getInstance(); 48 | cal.clear(); 49 | cal.set(2015, Calendar.JANUARY, 21); 50 | return cal.getTime(); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /telldontask/src/test/java/com/captaindebug/strategy/SpringShoppingCartTest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package com.captaindebug.strategy; 5 | 6 | import static org.junit.Assert.assertTrue; 7 | 8 | import java.util.Calendar; 9 | import java.util.Date; 10 | 11 | import org.junit.Test; 12 | 13 | import com.captaindebug.bridge.ShoppingCart; 14 | import com.captaindebug.payment.PaymentMethod; 15 | import com.captaindebug.payment.Visa; 16 | import com.captaindebug.telldontask.Item; 17 | 18 | /** 19 | * @author Roger 20 | * 21 | */ 22 | public class SpringShoppingCartTest { 23 | 24 | /** 25 | * Demonstrate the strategy pattern using the ShoppingCart example 26 | */ 27 | @Test 28 | public void payBillUsingVisa() { 29 | 30 | ShoppingCart instance = new ShoppingCart(); 31 | 32 | Item a = new Item("gloves", 23.43); 33 | instance.addItem(a); 34 | 35 | Item b = new Item("hat", 10.99); 36 | instance.addItem(b); 37 | 38 | Date expiryDate = getCardExpireyDate(); 39 | PaymentMethod visa = new Visa("CaptainDebug", "1234234534564567", expiryDate); 40 | 41 | boolean result = instance.pay(visa); 42 | assertTrue(result); 43 | 44 | } 45 | 46 | private Date getCardExpireyDate() { 47 | Calendar cal = Calendar.getInstance(); 48 | cal.clear(); 49 | cal.set(2015, Calendar.JANUARY, 21); 50 | return cal.getTime(); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /telldontask/src/test/java/com/captaindebug/telldontask/ShoppingCartTest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package com.captaindebug.telldontask; 5 | 6 | import static org.junit.Assert.assertEquals; 7 | 8 | import org.junit.Test; 9 | 10 | /** 11 | * @author Roger 12 | * 13 | * Created 9:33:31 AM Mar 3, 2012 14 | * 15 | */ 16 | public class ShoppingCartTest { 17 | 18 | /** 19 | * Test method for {@link tell_dont_ask.ask.ShoppingCart#getAllItems()}. 20 | */ 21 | @Test 22 | public void calculateTotalCost() { 23 | 24 | ShoppingCart instance = new ShoppingCart(); 25 | 26 | Item a = new Item("gloves", 23.43); 27 | instance.addItem(a); 28 | 29 | Item b = new Item("hat", 10.99); 30 | instance.addItem(b); 31 | 32 | Item c = new Item("scarf", 5.99); 33 | instance.addItem(c); 34 | 35 | double totalCost = instance.calcTotalCost(); 36 | assertEquals(40.41, totalCost, 0.0001); 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /telldontask/src/test/resources/log4j.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /tmp/DebugConnectionSignup.java: -------------------------------------------------------------------------------- 1 | package com.captaindebug.social.facebookposts.implementation; 2 | 3 | import java.util.concurrent.atomic.AtomicLong; 4 | 5 | import org.slf4j.Logger; 6 | import org.slf4j.LoggerFactory; 7 | import org.springframework.social.connect.Connection; 8 | import org.springframework.social.connect.ConnectionSignUp; 9 | 10 | public class DebugConnectionSignup implements ConnectionSignUp { 11 | 12 | private static final Logger logger = LoggerFactory.getLogger(DebugConnectionSignup.class); 13 | 14 | private final AtomicLong userIdSequence = new AtomicLong(); 15 | 16 | @Override 17 | public String execute(Connection connection) { 18 | 19 | Long seq = userIdSequence.incrementAndGet(); 20 | logger.info("executing sign up with sequence: " + seq); 21 | return Long.toString(seq); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /tmp/readme.txt: -------------------------------------------------------------------------------- 1 | This directory contains files that I want to keep around but don't yet belong to a project 2 | " -------------------------------------------------------------------------------- /unit-testing-threads/.gitignore: -------------------------------------------------------------------------------- 1 | /.project 2 | /.settings 3 | /.classpath 4 | /target 5 | -------------------------------------------------------------------------------- /unit-testing-threads/src/main/java/com/captaindebug/threading/bad_example/ThreadWrapper.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package com.captaindebug.threading.bad_example; 5 | 6 | /** 7 | * @author Roger 8 | * 9 | * Created 18:35:58 20 Jan 2013 10 | * 11 | */ 12 | public class ThreadWrapper { 13 | 14 | /** 15 | * Start the thread running so that it does some work. 16 | */ 17 | public void doWork() { 18 | 19 | Thread thread = new Thread() { 20 | 21 | /** 22 | * Run method adding data to a fictitious database 23 | */ 24 | @Override 25 | public void run() { 26 | 27 | System.out.println("Start of the thread"); 28 | addDataToDB(); 29 | System.out.println("End of the thread method"); 30 | } 31 | 32 | private void addDataToDB() { 33 | // Dummy Code... 34 | try { 35 | Thread.sleep(4000); 36 | } catch (InterruptedException e) { 37 | e.printStackTrace(); 38 | } 39 | } 40 | 41 | }; 42 | 43 | thread.start(); 44 | System.out.println("Off and running..."); 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /unit-testing-threads/src/main/java/com/captaindebug/threading/future/ThreadWrapper.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package com.captaindebug.threading.future; 5 | 6 | import java.util.concurrent.Callable; 7 | 8 | /** 9 | * @author Roger 10 | * 11 | * Created 18:35:58 20 Jan 2013 12 | * 13 | */ 14 | public class ThreadWrapper implements Callable { 15 | 16 | @Override 17 | public Boolean call() throws Exception { 18 | System.out.println("Start of the thread"); 19 | Boolean added = addDataToDB(); 20 | System.out.println("End of the thread method"); 21 | return added; 22 | } 23 | 24 | /** 25 | * Add to the DB and return true if added okay 26 | */ 27 | private Boolean addDataToDB() { 28 | 29 | try { 30 | Thread.sleep(4000); 31 | } catch (InterruptedException e) { 32 | e.printStackTrace(); 33 | } 34 | return Boolean.valueOf(true); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /unit-testing-threads/src/main/java/com/captaindebug/threading/good_example/ThreadWrapper.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package com.captaindebug.threading.good_example; 5 | 6 | import java.util.concurrent.CountDownLatch; 7 | 8 | /** 9 | * @author Roger 10 | * 11 | * Created 18:35:58 20 Jan 2013 12 | * 13 | */ 14 | public class ThreadWrapper { 15 | 16 | /** 17 | * Start the thread running so that it does some work. 18 | */ 19 | public void doWork(final CountDownLatch latch) { 20 | 21 | Thread thread = new Thread() { 22 | 23 | /** 24 | * Run method adding data to a fictitious database 25 | */ 26 | @Override 27 | public void run() { 28 | 29 | System.out.println("Start of the thread"); 30 | addDataToDB(); 31 | System.out.println("End of the thread method"); 32 | countDown(); 33 | } 34 | 35 | private void addDataToDB() { 36 | 37 | try { 38 | Thread.sleep(4000); 39 | } catch (InterruptedException e) { 40 | e.printStackTrace(); 41 | } 42 | } 43 | 44 | private void countDown() { 45 | if (isNotNull(latch)) { 46 | latch.countDown(); 47 | } 48 | } 49 | 50 | private boolean isNotNull(Object obj) { 51 | return latch != null; 52 | } 53 | 54 | }; 55 | 56 | thread.start(); 57 | System.out.println("Off and running..."); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /unit-testing-threads/src/main/java/com/captaindebug/threading/joinexample/ThreadWrapper.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package com.captaindebug.threading.joinexample; 5 | 6 | /** 7 | * @author Roger 8 | * 9 | * Created 18:35:58 20 Jan 2013 10 | * 11 | */ 12 | public class ThreadWrapper { 13 | 14 | private Thread thread; 15 | 16 | /** 17 | * Start the thread running so that it does some work. 18 | */ 19 | public void doWork() { 20 | 21 | thread = new Thread() { 22 | 23 | /** 24 | * Run method adding data to a fictitious database 25 | */ 26 | @Override 27 | public void run() { 28 | 29 | System.out.println("Start of the thread"); 30 | addDataToDB(); 31 | System.out.println("End of the thread method"); 32 | } 33 | 34 | private void addDataToDB() { 35 | 36 | try { 37 | Thread.sleep(4000); 38 | } catch (InterruptedException e) { 39 | e.printStackTrace(); 40 | } 41 | } 42 | }; 43 | 44 | thread.start(); 45 | System.out.println("Off and running..."); 46 | } 47 | 48 | /** 49 | * Synchronization method. 50 | */ 51 | public void join() { 52 | 53 | try { 54 | thread.join(); 55 | } catch (InterruptedException ex) { 56 | Thread.currentThread().interrupt(); 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /unit-testing-threads/src/main/java/com/captaindebug/threading/strategy/DatabaseJob.java: -------------------------------------------------------------------------------- 1 | package com.captaindebug.threading.strategy; 2 | 3 | public class DatabaseJob implements Runnable { 4 | 5 | /** 6 | * Run method adding data to a fictitious database 7 | */ 8 | @Override 9 | public void run() { 10 | 11 | System.out.println("Start of the thread"); 12 | addDataToDB(); 13 | System.out.println("End of the thread method"); 14 | } 15 | 16 | private void addDataToDB() { 17 | 18 | try { 19 | Thread.sleep(4000); 20 | } catch (InterruptedException e) { 21 | e.printStackTrace(); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /unit-testing-threads/src/main/java/com/captaindebug/threading/strategy/ThreadWrapper.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package com.captaindebug.threading.strategy; 5 | 6 | 7 | /** 8 | * @author Roger 9 | * 10 | * Created 18:35:58 20 Jan 2013 11 | * 12 | */ 13 | public class ThreadWrapper { 14 | 15 | /** 16 | * Start the thread running so that it does some work. 17 | */ 18 | public void doWork(Runnable job) { 19 | 20 | Thread thread = new Thread(job); 21 | thread.start(); 22 | System.out.println("Off and running..."); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /unit-testing-threads/src/main/java/com/captaindebug/threading/strategy/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | /** 5 | * @author Roger 6 | * 7 | * Created 21:20:40 26 Jan 2013 8 | * 9 | */ 10 | package com.captaindebug.threading.strategy; -------------------------------------------------------------------------------- /unit-testing-threads/src/test/java/com/captaindebug/threading/bad_example/ThreadWrapperTest.java: -------------------------------------------------------------------------------- 1 | package com.captaindebug.threading.bad_example; 2 | 3 | import static org.junit.Assert.assertTrue; 4 | 5 | import org.junit.Test; 6 | 7 | public class ThreadWrapperTest { 8 | 9 | @Test 10 | public void testDoWork() throws InterruptedException { 11 | 12 | ThreadWrapper instance = new ThreadWrapper(); 13 | 14 | instance.doWork(); 15 | 16 | Thread.sleep(10000); 17 | 18 | boolean result = getResultFromDatabase(); 19 | assertTrue(result); 20 | } 21 | 22 | /** 23 | * Dummy database method - just return true 24 | */ 25 | private boolean getResultFromDatabase() { 26 | return true; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /unit-testing-threads/src/test/java/com/captaindebug/threading/future/ThreadWrapperTest.java: -------------------------------------------------------------------------------- 1 | package com.captaindebug.threading.future; 2 | 3 | import static org.junit.Assert.assertTrue; 4 | 5 | import java.util.concurrent.ExecutionException; 6 | import java.util.concurrent.ExecutorService; 7 | import java.util.concurrent.Executors; 8 | import java.util.concurrent.Future; 9 | 10 | import org.junit.Test; 11 | 12 | public class ThreadWrapperTest { 13 | 14 | @Test 15 | public void testCall() throws ExecutionException, InterruptedException { 16 | 17 | ThreadWrapper instance = new ThreadWrapper(); 18 | 19 | ExecutorService executorService = Executors.newFixedThreadPool(1); 20 | 21 | Future future = executorService.submit(instance); 22 | 23 | Boolean result = future.get(); 24 | 25 | assertTrue(result); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /unit-testing-threads/src/test/java/com/captaindebug/threading/good_example/ThreadWrapperTest.java: -------------------------------------------------------------------------------- 1 | package com.captaindebug.threading.good_example; 2 | 3 | import static org.junit.Assert.assertTrue; 4 | 5 | import java.util.concurrent.CountDownLatch; 6 | 7 | import org.junit.Test; 8 | 9 | public class ThreadWrapperTest { 10 | 11 | @Test 12 | public void testDoWork() throws InterruptedException { 13 | 14 | ThreadWrapper instance = new ThreadWrapper(); 15 | 16 | CountDownLatch latch = new CountDownLatch(1); 17 | 18 | instance.doWork(latch); 19 | latch.await(); 20 | boolean result = getResultFromDatabase(); 21 | assertTrue(result); 22 | } 23 | 24 | /** 25 | * Dummy database method - just return true 26 | */ 27 | private boolean getResultFromDatabase() { 28 | return true; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /unit-testing-threads/src/test/java/com/captaindebug/threading/good_example2/ThreadWrapperTest.java: -------------------------------------------------------------------------------- 1 | package com.captaindebug.threading.good_example2; 2 | 3 | import static org.junit.Assert.assertTrue; 4 | 5 | import java.util.concurrent.CountDownLatch; 6 | 7 | import org.junit.Test; 8 | 9 | public class ThreadWrapperTest { 10 | 11 | @Test 12 | public void testDoWork() throws InterruptedException { 13 | 14 | ThreadWrapper instance = new ThreadWrapper(); 15 | 16 | CountDownLatch latch = new CountDownLatch(1); 17 | 18 | instance.doWork(latch); 19 | latch.await(); 20 | boolean result = getResultFromDatabase(); 21 | assertTrue(result); 22 | } 23 | 24 | /** 25 | * Dummy database method - just return true 26 | */ 27 | private boolean getResultFromDatabase() { 28 | return true; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /unit-testing-threads/src/test/java/com/captaindebug/threading/joinexample/ThreadWrapperTest.java: -------------------------------------------------------------------------------- 1 | package com.captaindebug.threading.joinexample; 2 | 3 | import static org.junit.Assert.assertTrue; 4 | 5 | import org.junit.Test; 6 | 7 | public class ThreadWrapperTest { 8 | 9 | @Test 10 | public void testDoWork() throws InterruptedException { 11 | 12 | ThreadWrapper instance = new ThreadWrapper(); 13 | 14 | instance.doWork(); 15 | instance.join(); 16 | 17 | boolean result = getResultFromDatabase(); 18 | assertTrue(result); 19 | } 20 | 21 | /** 22 | * Dummy database method - just return true 23 | */ 24 | private boolean getResultFromDatabase() { 25 | return true; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /unit-testing-threads/src/test/java/com/captaindebug/threading/semaphore/ThreadWrapperTest.java: -------------------------------------------------------------------------------- 1 | package com.captaindebug.threading.semaphore; 2 | 3 | import static org.junit.Assert.assertTrue; 4 | 5 | import java.util.concurrent.Semaphore; 6 | 7 | import org.junit.Test; 8 | 9 | public class ThreadWrapperTest { 10 | 11 | @Test 12 | public void testDoWork() throws InterruptedException { 13 | 14 | ThreadWrapper instance = new ThreadWrapper(); 15 | 16 | Semaphore semaphore = new Semaphore(1); 17 | instance.doWork(semaphore); 18 | semaphore.acquire(); 19 | 20 | boolean result = getResultFromDatabase(); 21 | assertTrue(result); 22 | } 23 | 24 | /** 25 | * Dummy database method - just return true 26 | */ 27 | private boolean getResultFromDatabase() { 28 | return true; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /unit-testing-threads/src/test/java/com/captaindebug/threading/strategy/ThreadWrapperTest.java: -------------------------------------------------------------------------------- 1 | package com.captaindebug.threading.strategy; 2 | 3 | import static org.junit.Assert.assertTrue; 4 | 5 | import java.util.concurrent.CountDownLatch; 6 | 7 | import org.junit.Test; 8 | 9 | public class ThreadWrapperTest { 10 | 11 | @Test 12 | public void testDoWork() throws InterruptedException { 13 | 14 | ThreadWrapper instance = new ThreadWrapper(); 15 | 16 | CountDownLatch latch = new CountDownLatch(1); 17 | 18 | DatabaseJobTester tester = new DatabaseJobTester(latch); 19 | instance.doWork(tester); 20 | latch.await(); 21 | 22 | boolean result = getResultFromDatabase(); 23 | assertTrue(result); 24 | } 25 | 26 | /** 27 | * Dummy database method - just return true 28 | */ 29 | private boolean getResultFromDatabase() { 30 | return true; 31 | } 32 | 33 | private class DatabaseJobTester extends DatabaseJob { 34 | 35 | private final CountDownLatch latch; 36 | 37 | public DatabaseJobTester(CountDownLatch latch) { 38 | super(); 39 | this.latch = latch; 40 | } 41 | 42 | @Override 43 | public void run() { 44 | super.run(); 45 | latch.countDown(); 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /xml-tips-blog/.gitignore: -------------------------------------------------------------------------------- 1 | /.project 2 | /.settings 3 | /.classpath 4 | /target 5 | -------------------------------------------------------------------------------- /xml-tips-blog/src/main/java/com/captaindebug/xml/as_string/OrderPizza.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2011 Marin Solutions 3 | */ 4 | package com.captaindebug.xml.as_string; 5 | 6 | /** 7 | * @author Roger 8 | * 9 | */ 10 | public class OrderPizza { 11 | 12 | private String pizzaName; 13 | private String base; 14 | private String quantity; 15 | 16 | public void order(String xmlOrder) { 17 | 18 | pizzaName = xmlOrder.substring(57, xmlOrder.indexOf("", 58); 20 | int index2 = xmlOrder.indexOf("", index2); 23 | index2 = xmlOrder.indexOf(" 2 | 3 | Capricciosa 4 | thin 5 | 2 6 | 7 | -------------------------------------------------------------------------------- /xml-tips-blog/src/test/resources/pizza2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Capricciosa 5 | thin 6 | 2 7 | 8 | 9 | Margherita 10 | thin 11 | 1 12 | 13 | 14 | -------------------------------------------------------------------------------- /xml-tips-blog/src/test/resources/pizza3.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Capricciosa 5 | thin 6 | 2 7 | 8 | 9 | Margherita 10 | thin 11 | 1 12 | 13 | 14 | -------------------------------------------------------------------------------- /xml-tips-blog/src/test/resources/sitemap1.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | http://www.example.com/ 6 | 2005-01-01 7 | monthly 8 | 0.8 9 | 10 | 11 | http://www.example.com/page1/ 12 | 2006-01-02 13 | weekly 14 | 0.8 15 | 16 | 17 | -------------------------------------------------------------------------------- /xml-tips-blog/src/test/resources/sitemap2.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | http://www.example.com/ 7 | 2005-01-01 8 | monthly 9 | 0.8 10 | 11 | 12 | http://www.example.com/page1/ 13 | 2006-01-02 14 | weekly 15 | 0.8 16 | 17 | 18 | -------------------------------------------------------------------------------- /xml-tips-blog/src/test/resources/sitemap3.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | http://www.example.com/ 7 | 2005-01-01 8 | monthly 9 | 0.8 10 | 11 | 12 | http://www.example.com/page1/ 13 | 2006-01-02 14 | weekly 15 | 0.8 16 | 17 | 18 | -------------------------------------------------------------------------------- /xml-tips-jaxb/.gitignore: -------------------------------------------------------------------------------- 1 | /.project 2 | /.settings 3 | /.classpath 4 | /target 5 | -------------------------------------------------------------------------------- /xml-tips-jaxb/src/main/java/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | Class-Path: 3 | 4 | -------------------------------------------------------------------------------- /xml-tips-xmlbeans/.gitignore: -------------------------------------------------------------------------------- 1 | /.project 2 | /.settings 3 | /.classpath 4 | /target 5 | -------------------------------------------------------------------------------- /xml-tips-xmlbeans/src/main/java/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | Class-Path: 3 | 4 | --------------------------------------------------------------------------------