Feb 20 2012

Self Motivation with RunKeeper

Category: MiscPhil @ 2:13 pm

I started jogging a little over 4 years ago after seeing a story on the news. The story was about the benefits of only 20 minutes of daily exercise! My metabolism had definitely slowed down as I got older, combine that with expanding responsibilities and time demands, meant less time for to stay fit. The only exercise I got was mowing the yard! So, I started jogging every morning before I went to work and it honestly made (makes) me feel a lot better; I did lose some pounds, but more importantly, it energizes me for the day.  It gives me about 25 minutes of me time, to listen to a podcast, music, or just think. It is a really good opportunity to get your day started on the right foot.

I basically run everyday on a treadmill; bad knees prevent me from running outside. So, unless I am not able to get out of bed, I am on the treadmill by 5AM.   I was running one morning last December and I smelled something burning, I thought the house was on fire! Unfortunately, the motor burned out and put a damper on my running! I figured it would be easier to fix it, rather than figuring out how to get rid of it! I had previously replaced two circuit boards in the treadmill, so I knew a guy in Michigan who dealt in treadmill parts (I found him on eBay!). He was a pretty interesting guy; he knew exactly what I needed and even through in a new belt. After a couple hours of fun and a lot of little adjustments, I had a brand new treadmill! I wish I knew how many miles I have logged on this thing; I assume that I have at least 3000+ miles on it… I know I have been through quite a few pairs of Brooks shoes!

One of my goals this year was to actually track my running.  I decided to  give RunKeeper a try. There are numerous web site / mobile application suites like this, but I had seen some good feedback on this one. The Android application is pretty basic and did what I need it to do.  The mobile applications are much more useful if you run out side; they are GPS enabled, recording your path and mileage, pretty cool! The RunKeeper website is actually pretty nice. I don’t really use it that much. You need to be an Elite member to get access to all of the interesting graphs and reports. I would actually like this information to be integrated with my blog, but have not found a WordPress plugin that does exactly what I want.  I might actually use this as an opportunity to create a small plugin that will let me manage my data the way I want! I actually have the whole thing designed in my head, it is just a matter of prioritization!

I thought that I would share my progress today, since I ran my longest distance of the year. Sometimes, if I feel the desire or need, I will actually run again when I get home from work; those are days that you see the unusually tall lines in the graph! I unfortunately broke my daily streak in January due to an illness, but have been fairly consistent ever since. It is kind of amazing, according to the treadmill’s calculations, I have burned an extra 22,000 calories this year!

My next challenge is to make it through a P90X session… I friend loaned me his DVD series to try… Sadly, my 4+ years of running has done nothing to prepare me for those workouts. I’m not very consistent with them, but will keep trying.  The problem is, I usually cannot walk the next day, they are seriously hard! Jogging is so much easier!

https://www.beilers.com/wp-content/plugins/sociofluid/images/digg_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/reddit_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/dzone_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/stumbleupon_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/delicious_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/blinklist_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/blogmarks_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/google_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/facebook_48.png


Feb 20 2012

Inspiration and Motivation

Category: MiscPhil @ 1:02 pm

I am so far behind in my blogging, apparently, I’m the one that needs some inspiration and motivation! I recently started a new opportunity which has given me the time and energy to be more creative and productive; I just have to start putting that extra time to good use!  I shared a really good motivational video a couple of years ago; apparently is still well received as it recently showed up again in my reading list, 4 Great Motivational Videos for 2012.   I was thinking that most people have probably given up on their New Year’s Resolutions by now or might need some encouragement or inspiration, so it seemed like a perfect time to re-share these videos… better late than never!

I have watched this video several times and it touches me every time…

This video is very clever, make sure you don’t give up on it…

Enjoy!

https://www.beilers.com/wp-content/plugins/sociofluid/images/digg_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/reddit_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/dzone_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/stumbleupon_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/delicious_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/blinklist_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/blogmarks_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/google_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/facebook_48.png


Dec 28 2011

Bluetooth Rocks with Home Phone Integration!

Category: Misc,VOIPPhil @ 12:02 am

I’m not sure how many normal people take advantage of Bluetooth technology, but I’m absolutely hooked. I run two and a half miles every morning using my Motorola S9 headphones. They are great for running, I can’t recommend them enough. I’m on my second pair; they unfortunately have an unreplaceable battery and would not hold a charge after a year or so.  My car has hands-free Bluetooth, which I must say that is pretty cool!  And now, my cordless phones are Bluetooth enabled too!

After the purchase of my OBi110, I needed to buy a real phone for the house, I honestly did not have one! I had researched Bluetooth / land-line phone integration solutions several years ago, but they always seemed rather “iffy”. I could never determine how well they really worked. They were always a little pricey, so I never took the risk.  I happen to see that Panasonic  had a line of phones with what they called a “Link-to-Cell” feature.  The phone seemed to get good reviews and was pretty reasonably priced; I picked them up for $57 from Walmart!  I have purchased Panasonic phones in the past and was always happy with them. These phone seem to be well made and comfortable to hold. I have not used the answering machine feature, since Google Voice provides that function for me; but did notice the “Voice Mail” indicator works on the phone! Think about that Integration – Google Voice services tell the OBiTalk network that I have voice mail, and then OBiTalk sends the message to my OBi adapter, which ultimately lights up the indicator on my cordless phone… Pretty crazy!

The Bluetooth integration is pretty slick. You can pair two different cell phones with the unit and assign different rings to each cell phone. You can also download your cell phone’s phone-book to the handsets. The phones even include “talking caller-id”, announcing the phone number or name of the person that called. My cell phone seems to pair instantly with the base unit when I walk into the house, no fuss at all.  The call quality seems no better or worse than using my old Jawbone Bluetooth headset. I think the sound quality is actually very good and have had no problems carrying on a conversation. You can easily make outbound phone calls with your cell phone, just dial the phone number and press the cell button.

I have only had the phones for a couple of weeks, but have been very happy with them. The convenience of being able to pickup a real phone is kind of nice, plus I don’t have to worry about where laid my cell phone down!

OK, back to the more traditional blogs starting tomorrow!  I just really wanted to share how well this inexpensive combination of technology really worked, linking together your cellular service, VOIP (Google Voice), and a traditional home phone into an unbelievably simple and convenient package!

https://www.beilers.com/wp-content/plugins/sociofluid/images/digg_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/reddit_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/dzone_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/stumbleupon_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/delicious_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/blinklist_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/blogmarks_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/google_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/facebook_48.png


Apr 09 2011

PingTags and LinkedIn…

Category: Blogging,MiscPhil @ 7:00 am

I recently attended  a couple of webinars that focused on the relationship between social media and recruiting. It was very interesting how much emphasis was put on your Internet Presence.  LinkedIn was the obviously leader in professional networking. The speaker actually said your LinkedIn profile is 10 times more important than your resume. I’m not sure I completely believe that point,  at least not until I can apply for a job opportunity with my LinkedIn profile URL!!! However, there must be some truth to the statement; they also said less than 10% of jobs are filled by randomly submitted resumes, via job websites. Most jobs are obtained via your professional network, almost eliminating the need for an actual paper resume. With so much information available about you on the Internet, it is just easier to Google someone. If a perspective hiring manager Googles your name, what exactly will they find? An interesting question…. Are you completely anonymous, with no Internet presence at all? You have a LinkedIn profile, but it is essentially empty and your profile picture is of Rover, your favorite pet. What exactly does that say about you, professionally?  Internet Presence, that was exact reason I started this blog. In the back of my mind, I thought that blogging would be a great, personal communication tool. How better could I share my thoughts, ideas, and lessons learned? It hopefully communicates what I believe is important, from a typically professional perspective.

On to PingTags; a new service, which I believe started earlier this year. It is a pretty simple, generate a QR code and link it with your LinkedIn profile. Give it a try, scan the code to the left! After spending way too much time on my resume and LinkedIn profile, I was rather intrigued by this idea.  I have seen QR codes in magazines, but was never excited by them. They obviously are bound to a paper world and I’m not really much of a paper person. At least 95% of my reading is done through my phone or Kindle, which essentially eliminates the need for scanning QR codes, I just click the link!  So, what is the point of PingTags? What about your business card? That was another interesting suggestion from the webinar; they recommended that everyone have a personal business card, something you can easily share with the people you meet. I honestly have not had a business card in over 15 years. A personal business card is something that I really never thought about, but it does seem like a good idea; and that is exactly what PingTags wants you do to… put the QR code on the back of your business card. I actually thought was kind of cool, in a geeky way! Flip over the card, scan it, and navigate to a nicely formatted mobile version of your profile. Not sure where I will go with this, just good information to know!

https://www.beilers.com/wp-content/plugins/sociofluid/images/digg_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/reddit_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/dzone_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/stumbleupon_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/delicious_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/blinklist_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/blogmarks_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/google_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/facebook_48.png


Feb 04 2011

Social Bookmarking… Migrating to Diigo

Category: Android,MiscPhil @ 12:01 am

The pending demise of Delicious was blogged to death a couple of months ago. I too was saddened by Yahoo’s decision, having become quite dependent on this service. Like many, I began a search for a new solution, but nothing seem to be the perfect replacement. It now appears that Delicious will be sold off, but who really knows what direction it will take. I discovered Delicious a couple of years ago; I blogged about it, showed it to my friends, and used it as a “sharing” solution whenever I had the chance. I’m always looking for ways to be more effective and efficient, both remembering and information sharing. I’m not exactly sure why, but none of my friends were ever really jazzed about the tool or concept… I could only come up with a couple of possible reasons:

  1. Many of my friends are Apple Fanboys… There must be something in that space that performs a similar function, maybe they have their own club!
  2. None of my friends blog. Many of them read multiple RSS feeds, I guess they just read and run! They must be able to retain a lot more information than I can!

My environment and thought process must be a little different.

  1. I live in an Apple free world.  I look for tools that work across platforms.  Dropbox is one of my favorites. It runs on my Android phone, my Ubuntu machines, and even those pesky Windows machines I have to support for the family.  Delicious provided effective plug-ins for most of the web browsers, and there were multiple options in the Android marketplace; this solution pretty much guaranteed I could find what I was looking for!
  2. The more RSS feeds I read, the more topics I find to blog about! This is vicious cycle and quickly creates a backlog! It was so easy to create a simple bookmark in Delicious, and tag it for blogging.
  3. Many times, I start reading an article and determine that it is too heavy and need some extra time to comprehend it. I just create another Delicious bookmark, and tag it for follow up.

After a lot of Googling for Delicious replacements and I landed on Diigo (My Library). I like the free stuff best and they also had a pretty decent Android application. Diigo has one feature that I have really grown to appreciate, the “Read Later” option.  If you find a web page that is interesting, but don’t have the time to read it, you simply click the “Read Later” button on the Diigo tool bar. Pretty simple! When you find time and want to catch up on your reading, you just go to your library and browse the Read Later items. I have not actually taken the time to use the notes and highlighting features, but am completely sold on tagging. Tagging seems like such an efficient way of classifying and searching for information; at least it works for me!  Diigo almost seems like a cross between Evernote and Delicious. It has many more features that Delicious, but the question is…. how will they survive?  I can only hope and might actually have to give them some $$$ to support their efforts.  My only rant is they do not provide a “tag cloud” view in their Android client… If they implement this view, I promise to become a paid member!

I still believe there is real value in the community, I’m not sure I will find one that is receptive, but I can always hope! There has to be value in exploring what your friends and coworkers are discovering and recording as important. I have to assume that much of that information is the bond which brings people together in the first place and ultimately enables them to communicate in a much more efficient and effective manner.

I highly recommend that you give Diigo a chance, and better yet, add me to your network!

https://www.beilers.com/wp-content/plugins/sociofluid/images/digg_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/reddit_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/dzone_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/stumbleupon_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/delicious_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/blinklist_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/blogmarks_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/google_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/facebook_48.png


Feb 03 2011

Where to start….

Category: Blogging,MiscPhil @ 2:52 pm

Everyone keeps asking me why, what happened to your blog? Why did you stop posting? Unfortunately, it is very complicated answer… I really don’t want to go into the the details. Chances are, you have been in the same boat as me; placed on high profile, transformational project which needed to be done by a specific, non-movable date.  It was a rather large project when you consider how it was staffed; project managers, agile coaches, testing teams, analysis team, business liaisons, business consultants, architects, and a few developers. Combine this sizable staff with a new business vision, introduce some new technology requirements (ESB, BPM, Rules), and I think you will get a pretty clear picture of why I stopped blogging!  This was a very unique opportunity to finally “do it right”; we were able to complete the system last November/December and successfully migrate to production. It was a very stressful period of time for everyone on the team, spanning many months; this including canceled vacations, working weekends, and extremely long days. This is not really a rant, as we all have to go through these experiences at different times in our career, this is really more about what you can learn and can take away from the experience.  Fortunately, I was able to be a student of the process and observed and learned many valuable lessons, and even the reinforcement of many of my fundamental beliefs. Unfortunately, I just did not have the energy to share those thoughts and gave myself a break from blogging.  There are several topics that I do hope to go back and revisit, so you will have to keep on reading!!!!

Finally, the biggest change for me occurred last Friday. I was given the opportunity to take a package from my employer of eighteen years. I want to thank all of the people that guided and supported me during my time there, you know who you are.  I have so many fond memories, met so many great people, it was truly a wonderful time. You would not even believe some my stories from the early days, being chased by security guards (it was not my fault, really), to directing traffic on Wisconsin Ave, flying flight simulators in Silicon Valley with SUN engineers, to almost sitting in Steve Job’s office chair!  Combine this with the large number of projects and unique people that I was given the chance to work with, it was a great place to be. Fortunately, I did not think of my job as work, I was always given the opportunity to learn new things while continually working to innovate and improve the environment.   Anyway, times change, companies change, and people change.  The bottom line is that I am very happy, happier than I have been in a long time. I look at this as a blessing and something that will lead to even better opportunities…  I have no idea what those are, but have a little time to explore the landscape. Thanks again, for all of the personal messages…

What’s next?
Fortunately, I had been working on my resume for the last month, and hope to have it in a marketable state in the very near future. It is amazing how much time it takes to get this going! I have written more emails in the last few days, than I did in the last year! I’m also doing a lot of thinking, what type of place do I really want to work, I hope I have a choice!  I don’t really want a job, I want to be part of a company where I can contribute; I think there is subtle, but significant difference… I worked in a factory during college making all types of flexible steel hose, this was production, not contribution… Contribution is being part of a team, making a difference, having pride in what you do, while producing and meeting your goal. I hope this is not to much to ask!

I am going into learning mode, which makes me very happy… I plan to ramp up my blogging and get my writing skills back into shape. I really enjoy writing, weird! I have already rebuilt my Linux box and have it wired up to a domain, Share My Progress.  I have video conferencing setup via Skype, switched over to my Google Voice number for almost all of my phone calls, all running under Ubuntu 10.10. I had a really good idea yesterday, I’m going to blog about interview questions that I think are very interesting or tripped me up… I already have one in the hopper!

https://www.beilers.com/wp-content/plugins/sociofluid/images/digg_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/reddit_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/dzone_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/stumbleupon_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/delicious_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/blinklist_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/blogmarks_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/google_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/facebook_48.png


Oct 18 2009

Droid Does…

Category: MiscPhil @ 5:55 am

I like anything that gives Apple a little jab… and am looking forward to Verizon releasing some interesting new phones. Verizon just created a new sub-site, http://www.verizonwireless.com/droid. I think it is actually a pretty good campaign, “iDon’t”. I have been using Windows Mobile for many years, and I will be the first to say that it has be be considered a complete failure; but similar to the old Palm OS, there have always been a multitude of free applications with no Steve restrictions. My primary need for a Windows-based phone was the integration with Outlook, which allowed me to sync my calendar, contacts, email, etc; which did work flawlessly. I have never been into the whole Android thing, as I am no fan of “single” source solutions, such as that iThing. But, now that Verizon and several other carriers are planning to release phones, and even Acer has released a new Android-based netbook, I’m starting to get a little more interested!

https://www.beilers.com/wp-content/plugins/sociofluid/images/digg_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/reddit_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/dzone_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/stumbleupon_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/delicious_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/blinklist_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/blogmarks_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/google_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/facebook_48.png


Jun 14 2009

New Trees… Like we don't have enough!

Category: MiscPhil @ 6:40 pm

Fortunately, we only lost a couple of trees last summer due to the drought.  Unfortunately, there were both relatively close to the house, so they really needed to be replaced. Amazingly, there were only two trees on our lot when we purchased it, now there are over two hundred! Call me crazy, I push mow around all of them before mowing with the big mower! I can’t believe how these trees have grown; we purchased about 150 Evergreens that were only 18 inches tall; many of them are over 10 fee tall now. Pretty cool!

We found a nice little nursery up in Frederick MD this weekend,  The Dutch Plant Farm. We live far enough to the west, that we can actually go up to Frederick, out to Winchester, or over to West Virginia; the distance is about the same any direction we go! The staff was very helpful and the prices were more reasonable than some of the big Northern Virginia nurseries.

One of the trees we lost was a six year old Japanese Maple. We wanted to replace it with another one, but were a little worried about their hardiness and cost. Between the hot, humid summers, too much rain, not enough rain, and the crazy amount of wind we get in the winter, we have some pretty tough tree growing conditions!  We ended up purchasing a different variety of Japanese Maple, one that was a little more tolerant of direct sunlight, a Red Dragon.  I obviously need to do some mulching, but it is a really pretty tree. The other tree we lost was a Harry Lauder Walking Stick; it was several years old too, but never really did that well.  We decided to replace it with a Raspberry Sundae Crapemyrtle. Living in the south, you see so many Crapemrytles, I think they are one of my favorites; especially when they start blooming. Hopefully, they will both survive the summer heat; I guess I will just have to keep up with my watering!

https://www.beilers.com/wp-content/plugins/sociofluid/images/digg_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/reddit_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/dzone_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/stumbleupon_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/delicious_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/blinklist_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/blogmarks_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/google_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/facebook_48.png


May 19 2009

How to customize your jUnit Behavior and Interaction

Category: Java,Misc,Testing,UbuntuPhil @ 8:17 pm

I have tried to walk through the jUnit source code a couple of times, trying to figure out how to implement my own behavior; only to give up in frustration (no I did not read the documentation, real developers don’t do that, they Google!) Why would I want to implement my own behavior? Well, it always seems to center around integrating with Spring. I usually want/need to do control the way the context is being created or do something immediately before the context is loaded or as the context is loading; something that might not be possible not possible using a @BeforeClass annotation.

This problem was actually related to my previous blog on Implementing Custom Scopes in Spring. Because I implemented some beans using the session scope, I kind of created a catch-22 scenario;  I have tried to capture the problem in bullet form:

  • Each jUnit test needs the ability to specify the specific test user (role, user info, etc.) that is relevant for that individual test
  • The test user profiles are configured and controlled by a Spring managed bean
  • All beans are lazy-init = true and injected into the unit test using the @Resource annotation
  • The session scope beans need to have the SecurityContextHolder configured with the appropriate principal (test user), before they are created
  • So, the problem is: How do you specify the test user, before the session scope beans are created and injected into the unit test class?

In a normal execution environment, using the Spring Security filters and a Servlet, the SecurityContextHolder would have been assigned using the authenticated principal, before creating any Spring dependencies. Because I created my own custom scopes for unit testing, the SecurityContextHolder was null and the session scope beans constructor was failing an assertion (principal != null). I could have easily fixed this by adding a pre-authenticated user to the SecurityContextHolder, using some static method approach,. However, because my mechanism for handling test users was itself a Spring bean, I had no possible way of specifying before the beans were injected into my unit test.

When jUnit 4.0 was released, it added several new constructs that make some very elegant solutions. I don’t think most developer’s ever look beyond the base jUnit functionality; fortunately it seems to solve 99% of the typical test scenarios. The new constructs are actually specified via annotations, they are the @RunWith and @TestExecutionListeners. My example code, can probably be made a little cleaner, but my main goal was to get the unit tests working. Because you don’t directly create any of these objects, you have to be aware of the timing; implement your customizations at  the correct point in the lifecycle. Another interesting problem, is that you don’t actually create the Spring Context, but you can interact with it via listeners.

First, we need a class which extends DependencyInjectionTestExecutionListener. This base class is required when using Spring and provides several override-able methods. I needed to configure the SecurityContextHolder, before any beans were injected into the unit test; I could accomplish this by utilizing the injectDependencies method. To support my testing needs, I added two (2) properties to the sub-class (this could have been cleaner); one to specify a user from a “user provider” factory, and a simpler one that used the user id of the person running the test. As you can see from the code, before an beans are injected into the unit test, I have access to the Spring context. This allows me to request the “user provider” factory and then request a specific test user. At this point, I can now assign the user to the SecurityContextHolder; all before any of the session scope beans are created.

public class AuthorizedTestExecutionListener extends DependencyInjectionTestExecutionListener {

    private TestUserAuthorization defaultAuthorization;
    private String                junitAuthorization;

    public void setJunitAuthorization(final String junitAuthorization) {
       this.junitAuthorization = junitAuthorization;
    }

    public void setDefaultAuthorization(final TestUserAuthorizationdefaultAuthorization) {
       this.defaultAuthorization = defaultAuthorization;
    }

    @Override
    @SuppressWarnings("PMD.SignatureDeclareThrowsException")
    protected voidinjectDependencies(final TestContext testContext) throws Exception {
       if (StringUtils.isNotBlank(junitAuthorization)) {
           final Authentication login = new UnitTestAuthenticationToken(this.getClass().getSimpleName());
           SecurityContextHolder.getContext().setAuthentication(login);
       }
       else if (defaultAuthorization != null) {
           finalTestUserModuleManager manager = (TestUserModuleManager) testContext.getApplicationContext()
                    .getBean(defaultAuthorization.testUserManager());
           final SecureUserInterface user = manager.find(defaultAuthorization.principal());
           final Authentication login = new UnitTestAuthenticationToken(user);
            SecurityContextHolder.getContext().setAuthentication(login);
        }

       super.injectDependencies(testContext);
    }
}

Next, we need to extend SpringJUnit4ClassRunner. This class is responsible for for creating the Spring test context and  DI listener class.  By over-ridding the  createTestContextManager, you have the opportunity to configure the test execution listeners.  I  also created two custom annotations, TestUserAuthentication and  JUnitAuthentication.  Using either one of these annotations, I could provide run-time meta-data  to my  custom AuthorizedSpringjUnit4ClassRunner; the meta data was then used to configure my custom  AuthorizedTestExecutionListner.

public class AuthorizedSpringjUnit4ClassRunner extends SpringJUnit4ClassRunner {

    public AuthorizedSpringjUnit4ClassRunner(final Class<?> clazz) throws InitializationError {
       super(clazz);
    }

    @Override
    @SuppressWarnings("PMD.ConfusingTernary")

    protected TestContextManager createTestContextManager(final Class<?> clazz) {

       final TestUserAuthorization defaultUser = clazz.getAnnotation(TestUserAuthorization.class);
       final JUnitAuthorization jUnitUser = clazz.getAnnotation(JUnitAuthorization.class);

       final TestContextManager context = super.createTestContextManager(clazz);

       for (final TestExecutionListener l : context.getTestExecutionListeners()) {
           if(AuthorizedTestExecutionListener.class.isAssignableFrom(l.getClass())) {
               if (defaultUser !=null) {
                    ((AuthorizedTestExecutionListener) l).setDefaultAuthorization(defaultUser);
                }
               else if (jUnitUser != null) {
                    ((AuthorizedTestExecutionListener) l).setJunitAuthorization(clazz.getSimpleName());
                }
            }
        }
       return context;
    }
}

Once you understand what all of the pieces do, they are super easy to customize to provide enhanced behavior. I think my solution provided a very clean, elegant solution for providing test specific user profiles, on a test by test basis.

@RunWith(AuthorizedSpringjUnit4ClassRunner.class)
@TestExecutionListeners(AuthorizedTestExecutionListener.class)
@ContextConfiguration(locations = {//
"/com/beilers/resources/spring/contexts/jUnitContext.xml" //
})

public class UnitTestHelper {
...
}
https://www.beilers.com/wp-content/plugins/sociofluid/images/digg_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/reddit_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/dzone_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/stumbleupon_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/delicious_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/blinklist_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/blogmarks_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/google_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/facebook_48.png


Jan 31 2009

Life on Pause….

Category: MiscPhil @ 11:08 am

Kind of amazing, I am almost recovered from a two week stint with pneumonia. I don’t know where the last two weeks went. Fortunately, I was not hospitalized, basically just confined to my house (my bed) for most of that time. The weird part is thinking about all of the stuff I have not done for a while:

  • I gave up reading, no RSS feeds, no books, minimal email. Most of the time, I had such a bad headache, it was practically impossible to think about anything, other than trying to stay warm and not induce coughing fits.
  • I have not worked out in two weeks. I guess I have a pretty good excuse, if you have no lung capacity and can’t breath, it is pretty hard to work out. The funny thing is that I lost 4 pounds towards my New Year Resolution goal. I guess you really don’t need to work out, just eat chicken soup and lots of water (Sprite in my case!)
  • I was listening to Pandora all of the time; I would crank up my “Nickelback Radio” every morning when I got to work. I guess I actually stopped listening to music all together; I would listen to music in the morning when I worked out too.
  • I listen to the Sports Junkies everyday on my way to work. I have only been in the car about thee times, and that was to drive to doctor’s appointments; not much car time! I should have saved some serious gas money this month! The Junkies are a pretty entertaining show, at least I will able to hear their Super Bowl recap on Monday morning, as that will be my first day back to work.
  • I don’t think I’ve been to church but one time this month. I think someone in our house has been sick every weekend this month. Hopefully, we can start February off on the right foot.

I guess we are all creatures of habit and have our little routines. I never thought much about my routine before, it was just automatic. So, just how routine should life be? This is not the kind of “spice” I wanted to break up my routine, but probably a good eye-opener. We should all work to find ways to break up the daily routine every so often. Life might get pretty dull when it is just work, doing laundry, mowing the grass, doing homework, making the kids practice their instruments… the list goes on an on! I don’t know what the right answer is, but it does give me more to think about!

https://www.beilers.com/wp-content/plugins/sociofluid/images/digg_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/reddit_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/dzone_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/stumbleupon_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/delicious_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/blinklist_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/blogmarks_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/google_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/facebook_48.png


Next Page »