Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Various

  • Loading branch information...
commit 5ef2fa0f9491359e72ca904cd49421889b7a6812 1 parent cf57c2c
@cbeams cbeams authored
View
2  .gitignore
@@ -11,3 +11,5 @@
*.ipr
*.iws
.settings
+bin
+*.sw*
View
2  .springBeans
@@ -7,7 +7,7 @@
</configSuffixes>
<enableImports><![CDATA[true]]></enableImports>
<configs>
- <config>src/main/resources/com/bank/config/xml/transfer-config.xml</config>
+ <config>src/main/resources/com/bank/config/xml/transfer-service-config.xml</config>
</configs>
<configSets>
</configSets>
View
88 README
@@ -1,83 +1,29 @@
-----------------------------------------------------------
-Spring DI Styles webinar companion project
-----------------------------------------------------------
+For those familiar with Git:
-Introduction
-------------
+ git clone git@github.com:cbeams/spring-3.1-profiles-xml.git
-This project uses Git for source control (http://git-scm.com), and is hosted
-at GitHub (http://github.com/cbeams/distyles).
+Or if you prefer using Subversion:
-To clone (check out) the project:
+ svn co http://svn.github.com/cbeams/spring-3.1-profiles-xml.git spring-3.1-profiles-xml.git
- git clone git://github.com/cbeams/distyles.git
+Once checked out, you can build from the command line using either Gradle or
+Maven. If you're new to Gradle, don't worry -- there's nothing for you to
+install. Simply type the following within the root directory of the project:
-If you don't have git installed, and would like a zip or tar of the sources:
+ >$ ./gradlew build
- http://github.com/cbeams/distyles/archives/master
+If necessary, this 'Gradle wrapper' script will download a distribution of
+Gradle for you. If you prefer Maven, of course you can simply type:
+ >$ mvn test
-This project is built using Gradle (http://gradle.org).
+If you're using an IDE that supports Maven-based projects, you can of course
+import the project directly from its POM. In any case, if you're using Eclipse
+you can generate Eclipse project metadata with
-To execute build system tasks, simply run the 'gradle wrapper' script
-appropriate to your platform. You'll notice these scripts are available in the
-root of this project, meaning there is nothing for you to download or install.
+ >$ ./gradlew eclipse
- For Windows: `gradlew.bat`
- For OSX/*nix: `gradlew`
-
-The remainder of this document will simply refer these scripts as 'gradlew'.
-
-
-Discover available tasks:
--------------------------
-
- gradlew --tasks
- or
- gradlew -t
-
-
-Build the project:
-------------------
-
- gradlew build
-
-Note that 'build' includes compilation, testing, and packaging. For Maven users,
-`gradlew build` is roughly equivalent to `mvn package`.
-
-Of course, the first time you execute this task, Gradle will download all
-project dependencies.
-
-
-Import the project into Eclipse/STS:
-------------------------------------
-
- gradlew eclipse
-
-to update .classpath file with paths to the dependency jars you just downloaded
-(note that .project and .springBeans files already exist). This command will
-also retrive and link dependency source jars. After this is complete, you can
-import the project as follows:
-
- File->Import->Existing Projects Into Workspace
-
-If using STS (http://www.springsource.com/developer/sts), you'll be glad to know
-that the Spring Project Nature has already been applied for you in the .project
-file, so you should have complete tooling for the Spring XML files in the
-project without any extra steps.
-
-
-Import the project into IntellJ IDEA:
--------------------------------------
-
- gradlew idea
-
-to create .iml, .ipr, and .iws files
-
-
-Run the TransferScript main():
-------------------------------
-
- gradlew runTransferScript
+IDEA users can do the same with
+ >$ ./gradlew idea
View
4 build.gradle
@@ -32,8 +32,8 @@ task wrapper(type: Wrapper) {
group = 'Admin'
description = "Generates gradlew and gradlew.bat bootstrap scripts"
gradleVersion = '0.9.2'
- urlRoot='http://gradle.artifactoryonline.com/gradle/distributions'
+ //urlRoot='http://gradle.artifactoryonline.com/gradle/distributions'
// place jar file and properties into a
// subdirectory to avoid root dir clutter
- jarPath = 'src/build'
+ jarFile = 'src/build/gradle-wrapper.jar'
}
View
33 gradlew
@@ -12,16 +12,20 @@
GRADLE_APP_NAME=Gradle
+# Use the maximum available, or set MAX_FD != -1 to use that value.
+MAX_FD="maximum"
+
warn ( ) {
- echo "${PROGNAME}: $*"
+ echo "$*"
}
die ( ) {
- warn "$*"
+ echo
+ echo "$*"
+ echo
exit 1
}
-
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
@@ -79,12 +83,31 @@ if [ -z "$JAVACMD" ] ; then
fi
fi
if [ ! -x "$JAVACMD" ] ; then
- die "JAVA_HOME is not defined correctly, can not execute: $JAVACMD"
+ die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
fi
if [ -z "$JAVA_HOME" ] ; then
warn "JAVA_HOME environment variable is not set"
fi
+# Increase the maximum file descriptors if we can.
+if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
+ MAX_FD_LIMIT=`ulimit -H -n`
+ if [ $? -eq 0 ] ; then
+ if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
+ MAX_FD="$MAX_FD_LIMIT"
+ fi
+ ulimit -n $MAX_FD
+ if [ $? -ne 0 ] ; then
+ warn "Could not set maximum file descriptor limit: $MAX_FD"
+ fi
+ else
+ warn "Could not query businessSystem maximum file descriptor limit: $MAX_FD_LIMIT"
+ fi
+fi
+
# For Darwin, add GRADLE_APP_NAME to the JAVA_OPTS as -Xdock:name
if $darwin; then
JAVA_OPTS="$JAVA_OPTS -Xdock:name=$GRADLE_APP_NAME"
@@ -137,7 +160,7 @@ fi
GRADLE_APP_BASE_NAME=`basename "$0"`
-"$JAVACMD" $JAVA_OPTS $GRADLE_OPTS \
+exec "$JAVACMD" $JAVA_OPTS $GRADLE_OPTS \
-classpath "$CLASSPATH" \
-Dorg.gradle.appname="$GRADLE_APP_BASE_NAME" \
-Dorg.gradle.wrapper.properties="$WRAPPER_PROPERTIES" \
View
60 gradlew.bat
@@ -5,10 +5,6 @@
@rem ##
@rem ##########################################################################
-@rem
-@rem $Revision: 10602 $ $Date: 2008-01-25 02:49:54 +0100 (ven., 25 janv. 2008) $
-@rem
-
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
@@ -19,69 +15,29 @@ if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.\
-@rem Determine the command interpreter to execute the "CD" later
-set COMMAND_COM="cmd.exe"
-if exist "%SystemRoot%\system32\cmd.exe" set COMMAND_COM="%SystemRoot%\system32\cmd.exe"
-if exist "%SystemRoot%\command.com" set COMMAND_COM="%SystemRoot%\command.com"
+@rem Find java.exe
+set JAVA_EXE=java.exe
+if not defined JAVA_HOME goto init
-@rem Use explicit find.exe to prevent cygwin and others find.exe from being used
-set FIND_EXE="find.exe"
-if exist "%SystemRoot%\system32\find.exe" set FIND_EXE="%SystemRoot%\system32\find.exe"
-if exist "%SystemRoot%\command\find.exe" set FIND_EXE="%SystemRoot%\command\find.exe"
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
-:check_JAVA_HOME
-@rem Make sure we have a valid JAVA_HOME
-if not "%JAVA_HOME%" == "" goto have_JAVA_HOME
+if exist "%JAVA_EXE%" goto init
echo.
-echo ERROR: Environment variable JAVA_HOME has not been set.
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
echo.
goto end
-:have_JAVA_HOME
-@rem Validate JAVA_HOME
-%COMMAND_COM% /C DIR "%JAVA_HOME%" 2>&1 | %FIND_EXE% /I /C "%JAVA_HOME%" >nul
-if not errorlevel 1 goto init
-
-echo.
-echo ERROR: JAVA_HOME might be set to an invalid directory: %JAVA_HOME%
-echo.
-echo Please set the JAVA_HOME variable in your environment to match the
-echo location of your Java installation if there are problems.
-echo.
-
:init
-@rem get name of script to launch with full path
@rem Get command-line arguments, handling Windowz variants
-SET _marker=%JAVA_HOME: =%
-@rem IF NOT "%_marker%" == "%JAVA_HOME%" ECHO JAVA_HOME "%JAVA_HOME%" contains spaces. Please change to a location without spaces if this causes problems.
if not "%OS%" == "Windows_NT" goto win9xME_args
if "%eval[2+2]" == "4" goto 4NT_args
-IF "%_marker%" == "%JAVA_HOME%" goto :win9xME_args
-
-set _FIXPATH=
-call :fixpath "%JAVA_HOME%"
-set JAVA_HOME=%_FIXPATH:~1%
-
-goto win9xME_args
-
-:fixpath
-if not %1.==. (
-for /f "tokens=1* delims=;" %%a in (%1) do (
-call :shortfilename "%%a" & call :fixpath "%%b"
-)
-)
-goto :EOF
-:shortfilename
-for %%i in (%1) do set _FIXPATH=%_FIXPATH%;%%~fsi
-goto :EOF
-
-
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
@@ -103,10 +59,10 @@ set CMD_LINE_ARGS=%$
set STARTER_MAIN_CLASS=org.gradle.wrapper.GradleWrapperMain
set CLASSPATH=%DIRNAME%\src\build\gradle-wrapper.jar
set WRAPPER_PROPERTIES=%DIRNAME%\src\build\gradle-wrapper.properties
-set JAVA_EXE=%JAVA_HOME%\bin\java.exe
set GRADLE_OPTS=%JAVA_OPTS% %GRADLE_OPTS% -Dorg.gradle.wrapper.properties="%WRAPPER_PROPERTIES%"
+@rem Execute Gradle
"%JAVA_EXE%" %GRADLE_OPTS% -classpath "%CLASSPATH%" %STARTER_MAIN_CLASS% %CMD_LINE_ARGS%
:end
View
BIN  src/build/gradle-wrapper.jar
Binary file not shown
View
7 src/build/gradle-wrapper.properties
@@ -1,9 +1,6 @@
-#Sat Feb 05 12:24:36 ICT 2011
+#Mon Feb 07 16:21:43 ICT 2011
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
-distributionVersion=0.9.2
zipStorePath=wrapper/dists
-urlRoot=http\://gradle.artifactoryonline.com/gradle/distributions
-distributionName=gradle
-distributionClassifier=bin
+distributionUrl=http\://gradle.artifactoryonline.com/gradle/distributions/gradle-0.9.2-bin.zip
View
17 src/main/java/com/bank/config/code/InfrastructureConfig.java
@@ -1,17 +0,0 @@
-package com.bank.config.code;
-
-import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.core.io.ClassPathResource;
-
-@Configuration
-public class InfrastructureConfig {
-
- @Bean
- public PropertyPlaceholderConfigurer propertyPlaceholderConfigurer() {
- PropertyPlaceholderConfigurer ppc = new PropertyPlaceholderConfigurer();
- ppc.setLocation(new ClassPathResource("com/bank/config/transfer.properties"));
- return ppc;
- }
-}
View
2  .../com/bank/config/code/TransferConfig.java → ...nk/config/code/TransferServiceConfig.java
@@ -12,7 +12,7 @@
import com.bank.service.internal.ZeroFeePolicy;
@Configuration
-public class TransferConfig {
+public class TransferServiceConfig {
@Autowired DataConfig dataConfig;
View
0  ...s/com/bank/config/xml/transfer-config.xml → ...nk/config/xml/transfer-service-config.xml
File renamed without changes
View
16 src/test/java/com/bank/config/code/IntegrationTests.java
@@ -23,28 +23,30 @@
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import com.bank.domain.InsufficientFundsException;
-import com.bank.domain.TransferReceipt;
import com.bank.repository.AccountRepository;
import com.bank.service.TransferService;
public class IntegrationTests {
@Test
- public void transfer() throws InsufficientFundsException {
+ public void transferTenDollars() throws InsufficientFundsException {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
ctx.getEnvironment().setDefaultProfiles("dev");
- ctx.register(TransferConfig.class, JndiDataConfig.class, StandaloneDataConfig.class);
+ //ctx.register(TransferConfig.class, JndiDataConfig.class, StandaloneDataConfig.class);
+ ctx.scan("com.bank.config.code");
ctx.refresh();
TransferService transferService = ctx.getBean(TransferService.class);
- TransferReceipt receipt = transferService.transfer(10.00, "A123", "C456");
+ AccountRepository accountRepository = ctx.getBean(AccountRepository.class);
- assertThat(receipt.getFinalDestinationAccount().getBalance(), equalTo(10.00));
+ assertThat(accountRepository.findById("A123").getBalance(), equalTo(100.00));
+ assertThat(accountRepository.findById("C456").getBalance(), equalTo(0.00));
- AccountRepository accountRepository = ctx.getBean(AccountRepository.class);
- assertThat(accountRepository.findById("A123").getBalance(), equalTo(90.00));
+ transferService.transfer(10.00, "A123", "C456");
+ assertThat(accountRepository.findById("A123").getBalance(), equalTo(90.00));
+ assertThat(accountRepository.findById("C456").getBalance(), equalTo(10.00));
}
}
View
14 src/test/java/com/bank/config/xml/IntegrationTests.java
@@ -20,11 +20,9 @@
import static org.junit.Assert.assertThat;
import org.junit.Test;
-
import org.springframework.context.support.GenericXmlApplicationContext;
import com.bank.domain.InsufficientFundsException;
-import com.bank.domain.TransferReceipt;
import com.bank.repository.AccountRepository;
import com.bank.service.TransferService;
@@ -34,17 +32,19 @@
public void transfer() throws InsufficientFundsException {
GenericXmlApplicationContext ctx = new GenericXmlApplicationContext();
ctx.getEnvironment().setDefaultProfiles("dev");
- ctx.load("classpath:/com/bank/config/transfer-config.xml");
+ ctx.load("classpath:/com/bank/config/xml/transfer-service-config.xml");
ctx.refresh();
TransferService transferService = ctx.getBean(TransferService.class);
- TransferReceipt receipt = transferService.transfer(10.00, "A123", "C456");
+ AccountRepository accountRepository = ctx.getBean(AccountRepository.class);
- assertThat(receipt.getFinalDestinationAccount().getBalance(), equalTo(10.00));
+ assertThat(accountRepository.findById("A123").getBalance(), equalTo(100.00));
+ assertThat(accountRepository.findById("C456").getBalance(), equalTo(0.00));
- AccountRepository accountRepository = ctx.getBean(AccountRepository.class);
- assertThat(accountRepository.findById("A123").getBalance(), equalTo(90.00));
+ transferService.transfer(10.00, "A123", "C456");
+ assertThat(accountRepository.findById("A123").getBalance(), equalTo(90.00));
+ assertThat(accountRepository.findById("C456").getBalance(), equalTo(10.00));
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.