Started using Geb (http://www.gebish.org/) for some simple UI automations to run via Jenkins. Basically, login to several instances of our app every half an hour and make sure something infrastructure-wise has not taken our app down. Only issue is something with the network (proxy config etc.) makes it run REAL slow so far...
>>>
@Grapes([
@Grab("org.codehaus.geb:geb-core:0.6.0"),
@Grab("org.seleniumhq.selenium:selenium-firefox-driver:2.0rc3")
])
import geb.*
import org.openqa.selenium.firefox.FirefoxDriver
class LoginPage extends Page {
static url = ""
static content = {
submitButton(to: MainPage) { $("input", type: "button", name: "signin") }
usernameInput() { $("input", type: "text", name: "usernameInput") }
passwordInput() { $("input", type: "password", name: "passwordInput") }
}
}
class MainPage extends Page {
static url = "main"
}
Browser.drive() {
def username = config.rawConfig.username
def password = config.rawConfig.password
def loginTitle = config.rawConfig.loginTitle
println "Opening login page..."
to LoginPage
at LoginPage
assert $("title").text() == "Sign In"
println "Setting username=$username"
usernameInput << username
println "Validating username..."
assert usernameInput.value() == username
println "Setting password=$password"
passwordInput << password
println "Validating password..."
assert passwordInput.value() == password
println "Submitting login form..."
submitButton.click(MainPage)
println "Waiting for main page..."
at MainPage
println "Checking for main title..."
assert $("title").text() == "Main Title"
}.quit()
println "Done!"
<<<
Crontar the Programmer
I've been a programmer for 12 years. I have opinions that I can't put anywhere else. Even though few will read them, I must get them out. Hopefully you find I am open minded about most programming technologies except for those that run on Windows only.
Tuesday, October 18, 2011
Wednesday, October 12, 2011
If you can't beat em', join em'
I started out my little EclipsePhase RPG tracking web app using a Flex UI on top of Gaelyk services. However, this last weekend I gave up on that and rebuilt my starting point plus some more features with Grails and HTML.
Using Grails instead of Gaelyk was an easy choice for now since I can get a free cloud deployment via CloudFoundry. Nevermind the fact that I use Grails at my day job, I think I might generally like it better than Gaelyk.
However, the Flex vs. HTML/JavaScript thing is a little less logical. I spent 4 years getting decent with the Flex framework which I think is a great RIA platform. However these days with all the Flash FUD going around and the hype around HTML5, it seems highly unlikely that I will build many more Flex UIs professionally. That's a shame but I'm growing tired of fighting it for now.
My project is a "no Flash" zone as my company's head management is convinced Steve Jobs "Flash is dead"eventhough we have several RIA front-end projects that have been success and no JavaScript/HTML ones yet to do anything significant.
We actually pay for a JavaScript framework (ExtJs) when Adobe Flex is open source now. Our UI constantly has browser issues. It does very little. In Flex it would be the equivalent of a couple data grids, a couple forms and file uploader.
I'm not digging on our UI guys, but they have alot more work to do dealing with what one guy referred to as "GarbageScript".
I'm also not digging on JavaScript but browsers suck. JavaScript devs that spend their time hating on Flash suck. And eventhough I love my Mac and don't want to be insensitive, but Steve Jobs hateraid for Adobe Flash sucked also.
I'm tired and beaten, so I'm just doing HTML and GarbageScript for now. The good thing is I am back to basically writing my UI on the server with Groovy/Grails and only slightly with HTML and JavaScript.
Using Grails instead of Gaelyk was an easy choice for now since I can get a free cloud deployment via CloudFoundry. Nevermind the fact that I use Grails at my day job, I think I might generally like it better than Gaelyk.
However, the Flex vs. HTML/JavaScript thing is a little less logical. I spent 4 years getting decent with the Flex framework which I think is a great RIA platform. However these days with all the Flash FUD going around and the hype around HTML5, it seems highly unlikely that I will build many more Flex UIs professionally. That's a shame but I'm growing tired of fighting it for now.
My project is a "no Flash" zone as my company's head management is convinced Steve Jobs "Flash is dead"eventhough we have several RIA front-end projects that have been success and no JavaScript/HTML ones yet to do anything significant.
We actually pay for a JavaScript framework (ExtJs) when Adobe Flex is open source now. Our UI constantly has browser issues. It does very little. In Flex it would be the equivalent of a couple data grids, a couple forms and file uploader.
I'm not digging on our UI guys, but they have alot more work to do dealing with what one guy referred to as "GarbageScript".
I'm also not digging on JavaScript but browsers suck. JavaScript devs that spend their time hating on Flash suck. And eventhough I love my Mac and don't want to be insensitive, but Steve Jobs hateraid for Adobe Flash sucked also.
I'm tired and beaten, so I'm just doing HTML and GarbageScript for now. The good thing is I am back to basically writing my UI on the server with Groovy/Grails and only slightly with HTML and JavaScript.
Thursday, October 6, 2011
Shady Illuminations
Posted to Pragmatic Bookshelf under PragPub topic...
http://forums.pragprog.com/forums/134/topics/9732
I have to admit that although I am a regular customer of The Pragmatic Bookshelf and have gleaned wisdom from many resources provided here, I have not been a regular reader of the PragPub magazine. However, with that being said, I was skimming October’s issue and saw a section labeled “Porn” that described how “Pornography… is a positive good that encourages experimentation with new media.” and “Porn is a subvirtue.”
This disappointed me a great deal. I believe that any positive pornography seems to bring to ANY industry should be immediately discounted as it promotes an escalating devaluing of the people involved and some might even say that on the extreme end it can even promote prostitution and sex trafficking. I am not here to make a case for the latter, but I think any article putting a positive spin on a industry like “porn” is not worthy of the “Pragmatic” name.
I sincerely hope Andy and Dave give this concern serious consideration.
Thanks guys for all that you have done for our industry and my career.
Todd W. Crone
http://forums.pragprog.com/forums/134/topics/9732
I have to admit that although I am a regular customer of The Pragmatic Bookshelf and have gleaned wisdom from many resources provided here, I have not been a regular reader of the PragPub magazine. However, with that being said, I was skimming October’s issue and saw a section labeled “Porn” that described how “Pornography… is a positive good that encourages experimentation with new media.” and “Porn is a subvirtue.”
This disappointed me a great deal. I believe that any positive pornography seems to bring to ANY industry should be immediately discounted as it promotes an escalating devaluing of the people involved and some might even say that on the extreme end it can even promote prostitution and sex trafficking. I am not here to make a case for the latter, but I think any article putting a positive spin on a industry like “porn” is not worthy of the “Pragmatic” name.
I sincerely hope Andy and Dave give this concern serious consideration.
Thanks guys for all that you have done for our industry and my career.
Todd W. Crone
Friday, September 16, 2011
Maintenance costs versus writing better initial code
But I wonder the cost of having a poor programmer do something that has high maintenance costs but is available right away as opposed to wait for a good programmer to be available to do it. My guess is you are still better off waiting, but I think people find themselves in this spot more than any. They know that good programmers write code that is easier to maintain, but they feel there is an urgency to get something done and they can't find a 'good' programmer to do it now. The compromise is, get a not so good programmer to do it and potentially make a mess and if the system lives long enough, get the good programmer to come along when they are available to make it better or fix it.
Obviously I consider myself a good programmer. In my 12+ year career, I have spent less time maintaining a system wrote well than I have maintaining/fixing one that someone else wrote poorly.
Early in my career, I spent most of my time maintaining code that I had written poorly. So for the first 3-4 years, 'I' was the not so good programmer whose code I maintained. But at some point I started getting better and I spent more time dealing with fixing other systems than ones I wrote. My code was still not 'great' since it was difficult for me to hand off to anyone but the bugs were much lower than my first few years coding and when bugs came up, I could find and fix them more readily.
After my 6th year (or so) I started following some 'Agile' development practices. Not 'processes'. I used "Agile Developer" techniques geared toward making the code I wrote more easy to change and more easy to keep in a working state. This also facilitated working with other developers more.
I started writing code that junior developers could take a run with it and I moved on to other things. This happens a lot with "Senior" devs handing off work to "Junior" devs but not always in a manner that enables the junior devs to be productive. I think a truly senior developer's main task is to write code that is easy for someone else to modify. Getting it to 'work' is assumed and means little when you are supposed to me a senior software engineer.
Some senior software engineers justify the complexity in their code to "It's hard stuff." "I'm smarter/senior so that is why I understand it and you don't." This is bull. More often than not though, that same senior developer subconsciously is 'protecting' their code with complexity. If you don't want some sharp young developer to come along and show you up, make their job hard. Hand them overly complicated code to maintain and prove you are smarter than they are.
Yes, some things by their nature are complex, but a truly good dev lead can boil it down so that someone else can be empowered by the design to be productive. If you are 'senior' and a 'junior' dev can't maintain/modify your code it is YOUR fault 9 times out of 10. Even if they are not necessarily very experienced or skilled. You should be enabling them and building up their confidence with well designed code. You should not be crushing their spirit by dropping a pile of crap in their laps and saying, "This code is about 99% done. I just need you to plug the database in."
Monday, September 12, 2011
Two Things
I decided to use the programmatic properties file reading for a more 'sensible' solution to my last implementation:
applicationContext.groovy (via spring-grails DSL/BeanBuiler) in the src/webapp/WEB-INF directory
The throughout the 'beans' closure, I can say 'properties[property]' at load time rather than getting a proxy as the last implementation returned. This means I can use properties to conditionally configure
beans based on environment. It also allows a 'default.properties' file that will hopefully cover 90% of
what will be done and then the 'overrides.properties' can cover the few things that will likely be
different but can be loaded via that environment (e.g. tomcat/lib).
The other thing is I did very basic implementation with full CRUD for an EclipsePhase character tracker with a Flex front-end and a Gaelyk back-end.
http://ep-tools.appspot.com/epui.html
Slow services on app engine, but free. Using the app engine Entity for persistence is easy but I still thing I'll look at doing it with Grails and deploying to CloudFoundry as long as it is 'cheap enough'.
Code is nothing exciting but on github.
https://github.com/twcrone/eclpsephase-character-tracker-services
https://github.com/twcrone/eclipsephase-character-tracker-ui
No guarantees that the code will stick around or stay the same as the base site. Cool thing is...with Flex (and my skills), the back-end can change. Not embedded in any particular environment (e.g. Gaelyk, Grails, Rails, Spring).
applicationContext.groovy (via spring-grails DSL/BeanBuiler) in the src/webapp/WEB-INF directory
...
Properties properties = loadProperties(logger)
...
Properties loadProperties(logger) {
String baseFilename = "overrides.properties"
String defaultBaseFilename = "default.properties"
def contextClassLoader = Thread.currentThread().getContextClassLoader()
String defaultFilename = contextClassLoader.getResource(defaultBaseFilename).getFile()
String overrideFileName = contextClassLoader.getResource(baseFilename)?.getFile()
File defaultPropertyFile = new File(defaultFilename)
Properties properties = new Properties()
properties.load(new FileReader(defaultPropertyFile))
if(overrideFileName) {
File overridePropertyFile = new File(overrideFileName)
if(overridePropertyFile.exists()) {
logger.info "Loading overrides..."
properties.load(new FileReader(overridePropertyFile))
}
}
else {
logger.warn "No override properties file was found, using project defaults ONLY."
}
logger.info "Properties"
properties.each {k,v -> logger.info "$k=$v"}
return properties
}
String baseFilename = "overrides.properties"
String defaultBaseFilename = "default.properties"
def contextClassLoader = Thread.currentThread().getContextClassLoader()
String defaultFilename = contextClassLoader.getResource(defaultBaseFilename).getFile()
String overrideFileName = contextClassLoader.getResource(baseFilename)?.getFile()
File defaultPropertyFile = new File(defaultFilename)
Properties properties = new Properties()
properties.load(new FileReader(defaultPropertyFile))
if(overrideFileName) {
File overridePropertyFile = new File(overrideFileName)
if(overridePropertyFile.exists()) {
logger.info "Loading overrides..."
properties.load(new FileReader(overridePropertyFile))
}
}
else {
logger.warn "No override properties file was found, using project defaults ONLY."
}
logger.info "Properties"
properties.each {k,v -> logger.info "$k=$v"}
return properties
}
The throughout the 'beans' closure, I can say 'properties[property]' at load time rather than getting a proxy as the last implementation returned. This means I can use properties to conditionally configure
beans based on environment. It also allows a 'default.properties' file that will hopefully cover 90% of
what will be done and then the 'overrides.properties' can cover the few things that will likely be
different but can be loaded via that environment (e.g. tomcat/lib).
The other thing is I did very basic implementation with full CRUD for an EclipsePhase character tracker with a Flex front-end and a Gaelyk back-end.
http://ep-tools.appspot.com/epui.html
Slow services on app engine, but free. Using the app engine Entity for persistence is easy but I still thing I'll look at doing it with Grails and deploying to CloudFoundry as long as it is 'cheap enough'.
Code is nothing exciting but on github.
https://github.com/twcrone/eclpsephase-character-tracker-services
https://github.com/twcrone/eclipsephase-character-tracker-ui
No guarantees that the code will stick around or stay the same as the base site. Cool thing is...with Flex (and my skills), the back-end can change. Not embedded in any particular environment (e.g. Gaelyk, Grails, Rails, Spring).
Wednesday, September 7, 2011
Spring Grails Bean Builder Confusion
Spent hours today trying to convert some traditional Spring XML config into more dynamic Grails Bean Builder script to allow dynamic config based on the environment that the webapp is deployed (Windows vs. non-Windows/*nix). This was NOT a Grails project so I first had to include the dependency in the build.gradle file.
compile "org.grails:grails-spring:1.3.7"
Here is a snippet of the Spring XML I was trying to convert:
All was okay until I tried to deal with the 'property-placeholder' for the config.properties. I tried lots of stuff and on a whim tried this very counterintuitive thing with a Java String for the property key that looks like a Groovy String that in the BeanBuilder should be interpolated:
Yes boys and girls...
compile "org.grails:grails-spring:1.3.7"
Here is a snippet of the Spring XML I was trying to convert:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<context:property-placeholder location="classpath:config.properties"/>
<bean id="connectionFactory" class="org.springframework.jms.connection.CachingConnectionFactory">
<property name="targetConnectionFactory">
<bean class="org.apache.activemq.ActiveMQConnectionFactory">
<property name="brokerURL" value="${jms.brokerUrl}"/>
</bean>
</property>
<property name="sessionCacheSize" value="10"/>
<property name="cacheProducers" value="false"/>
</bean>
<bean id="jmsTemplate" class="org.springframework.jms.core.JmsTemplate">
<property name="connectionFactory"><ref local="connectionFactory"/></property>
</bean>
...
</beans>
All was okay until I tried to deal with the 'property-placeholder' for the config.properties. I tried lots of stuff and on a whim tried this very counterintuitive thing with a Java String for the property key that looks like a Groovy String that in the BeanBuilder should be interpolated:
beans {
xmlns context:"http://www.springframework.org/schema/context"
context.'property-placeholder'('location':'classpath:config.properties')
activeMqConnectionFactory(org.apache.activemq.ActiveMQConnectionFactory) {
brokerURL = '${jms.brokerUrl}' // Yes, this is meant to be a java.lang.String
}
jmsFactory(org.springframework.jms.connection.CachingConnectionFactory) {
targetConnectionFactory = activeMqConnectionFactory
}
jmsTemplate(org.springframework.jms.core.JmsTemplate) {
connectionFactory = jmsFactory
}
...
}
Yes boys and girls...
'${jms.brokerUrl}'
Major brain eff here with something that looks like it should be "${jms.brokerUrl}" with double quotes for Groovy String interpolation or perhaps even simply jms.brokerUrl like a variable attached to a dynamically generated property on the beans object. I even tried context['jms.brokerUrl']and beans['jms.brokerUrl']to no avail.
I tried the actual solution when it occurred to me that Spring would not be doing interpolation on the ${blah} like Groovy when reading the XML. For Spring, that means 'use this string as a key to a resource'.
Oyvay.
Wednesday, August 31, 2011
August Rush
So August is coming to close and only one peep out of me for this month. So I'm going to write something before midnight so that I can see "August(2)" rather than "August(1)". Really a moral victory but a victory.
Lately I have been spending my time away from work...away from work. Since my project is going 1.0 in October, right now I am putting in some overtime which means I don't want to code at home. Not ridiculous overtime as I have seen on other projects that come to their final months and everyone is say "Oh crap! We need more features!" So far we are still getting things done at a reasonable pace.
I do hope to work on a Grails on Flex project this weekend related to my two feeble attempts at pure Grails and HTML implementations of an EclipsePhase character tracker. Surely this one will stick.
Anyways, I wish I had something more profound to say before midnight but after one class of wine, I'm ready to sleep. Good night, and thanks James for your profound words of wisdom on handling trials of one sort or another. "Consider it pure joy..."
Lately I have been spending my time away from work...away from work. Since my project is going 1.0 in October, right now I am putting in some overtime which means I don't want to code at home. Not ridiculous overtime as I have seen on other projects that come to their final months and everyone is say "Oh crap! We need more features!" So far we are still getting things done at a reasonable pace.
I do hope to work on a Grails on Flex project this weekend related to my two feeble attempts at pure Grails and HTML implementations of an EclipsePhase character tracker. Surely this one will stick.
Anyways, I wish I had something more profound to say before midnight but after one class of wine, I'm ready to sleep. Good night, and thanks James for your profound words of wisdom on handling trials of one sort or another. "Consider it pure joy..."
Subscribe to:
Posts (Atom)