[jboss-svn-commits] JBL Code SVN: r5340 - in labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/banks: src/org/jboss/soa/esb/samples/loanbroker/banks test/org/jboss/soa/esb/samples/loanbroker/banks
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Fri Jul 28 08:55:47 EDT 2006
Author: kurt.stam at jboss.com
Date: 2006-07-28 08:55:35 -0400 (Fri, 28 Jul 2006)
New Revision: 5340
Added:
labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/src/org/jboss/soa/esb/samples/loanbroker/banks/FlatFilePollManager.java
labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/src/org/jboss/soa/esb/samples/loanbroker/banks/FlatFilePollManagerFactory.java
labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/test/org/jboss/soa/esb/samples/loanbroker/banks/FlatFileProcessorTest.java
Removed:
labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/src/org/jboss/soa/esb/samples/loanbroker/banks/BankPollManager.java
labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/src/org/jboss/soa/esb/samples/loanbroker/banks/BankPollManagerFactory.java
Modified:
labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/src/org/jboss/soa/esb/samples/loanbroker/banks/BankQuoteRequest.java
Log:
adding bank code for the loan broker example
Deleted: labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/src/org/jboss/soa/esb/samples/loanbroker/banks/BankPollManager.java
===================================================================
--- labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/src/org/jboss/soa/esb/samples/loanbroker/banks/BankPollManager.java 2006-07-28 09:55:45 UTC (rev 5339)
+++ labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/src/org/jboss/soa/esb/samples/loanbroker/banks/BankPollManager.java 2006-07-28 12:55:35 UTC (rev 5340)
@@ -1,143 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.soa.esb.samples.loanbroker.banks;
-
-import java.io.File;
-import java.math.BigDecimal;
-
-import org.apache.log4j.Logger;
-import org.apache.log4j.Priority;
-import org.sadun.util.polling.BasePollManager;
-import org.sadun.util.polling.CycleEndEvent;
-import org.sadun.util.polling.CycleStartEvent;
-import org.sadun.util.polling.DirectoryLookupEndEvent;
-import org.sadun.util.polling.DirectoryLookupStartEvent;
-import org.sadun.util.polling.FileFoundEvent;
-import org.sadun.util.polling.FileSetFoundEvent;
-
-
-class BankPollManager extends BasePollManager
-{
- private Logger logger = Logger.getLogger(this.getClass());
-
- private static final String BANK_NAME = "FileBasedBank";
- private static final BigDecimal RATE_PREMIUM = BigDecimal.valueOf(0.25);
- private static final int MAXLOANTERM = 120;
- private static final String OUTGOING_DIR = "outgoing";
- private static final String PREFIX = "reply_to_";
- private static final String PROCESSED_DIR = "processed";
-
- public void cycleStarted(CycleStartEvent evt) {
- logger.log(Priority.DEBUG, "Poller awakened "
- + (evt.getPoller().getFilter() == null ? "(no filtering)" : evt
- .getPoller().getFilter().toString()));
- }
-
- public void cycleEnded(CycleEndEvent evt) {
- logger.log(Priority.DEBUG, "Poller going to sleep");
- }
-
- public void directoryLookupStarted(DirectoryLookupStartEvent evt) {
- logger.log(Priority.DEBUG, "Scanning " + evt.getDirectory());
- }
-
- public void directoryLookupEnded(DirectoryLookupEndEvent evt) {
- logger.log(Priority.DEBUG, "Finished scanning " + evt.getDirectory());
- }
-
- public void fileSetFound(FileSetFoundEvent evt) {
- File[] files = evt.getFiles();
-
- for (int i = 0; i < files.length; i++) {
- File file = files[i];
- BankQuoteReply bankQuoteReply=new BankQuoteReply();
- bankQuoteReply.setQuoteId(BANK_NAME);
- int errorCode=6;
- String message=null;
- logger.log(Priority.INFO, "Found " + file.getAbsolutePath() );
-
-
- try {
- BankQuoteRequest bankQuoteRequest = new BankQuoteRequest();
- //Read the content of the file into a String
- message=FileUtil.readTextFile(file);
- String[] messagePart = message.split(",");
-
- errorCode=1;
- bankQuoteRequest.setSsn(Integer.valueOf(messagePart[0]));
- errorCode=2;
- bankQuoteRequest.setCreditScore(Integer.valueOf(messagePart[1]));
- errorCode=3;
- bankQuoteRequest.setHistoryLength(Integer.valueOf(messagePart[2]));
- errorCode=4;
- bankQuoteRequest.setLoanAmount(Integer.valueOf(messagePart[3]));
- errorCode=5;
- bankQuoteRequest.setLoanTerm(Integer.valueOf(messagePart[4]));
-
- Bank fileBasedBank = new Bank(BANK_NAME, RATE_PREMIUM, MAXLOANTERM);
- bankQuoteReply = fileBasedBank.processMessage(bankQuoteRequest);
-
- } catch (Throwable e) {
- logger.log(Priority.ERROR, e.getMessage());
- bankQuoteReply.setErrorCode(errorCode);
- }
-
- try {
- //Create the outgoing response file
- File outgoingDir = new File(file.getParent() + "/" + OUTGOING_DIR);
- if (!outgoingDir.exists()) {
- outgoingDir.mkdir();
- }
- File outgoingFile = new File(outgoingDir + "/" + PREFIX + file.getName());
- logger.log(Priority.INFO, "Creating outgoing file " + outgoingFile.getAbsolutePath());
- outgoingFile.createNewFile();
- String reply=bankQuoteReply.getInterestRate() + "," + bankQuoteReply.getQuoteId() + "," + bankQuoteReply.getErrorCode();
- logger.log(Priority.INFO, "Writing reply " + reply);
- FileUtil.writeTextFile(outgoingFile, reply);
-
- //Move the processed file away so it does not get processed again
- File processedDir = new File(file.getParent() + "/" + PROCESSED_DIR);
- if (!processedDir.exists()) {
- processedDir.mkdir();
- }
- logger.log(Priority.INFO, "Moving file " + file.getName() + " to processed directory");
- File processedFile = new File(processedDir.getAbsolutePath() + "/" + file.getName());
- file.renameTo(processedFile);
- if (file.exists()) {
- file.delete();
- }
- } catch (Exception e) {
- logger.log(Priority.ERROR, e.getMessage(), e);
- }
- }
- }
-
- public void fileFound(FileFoundEvent evt) {
- logger.log(Priority.DEBUG, evt);
- // Add artificial delay
- }
-
- public String toString() {
- return "BankPollManager - a pollmanager which processed incoming loan requests";
- }
-
-}
\ No newline at end of file
Deleted: labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/src/org/jboss/soa/esb/samples/loanbroker/banks/BankPollManagerFactory.java
===================================================================
--- labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/src/org/jboss/soa/esb/samples/loanbroker/banks/BankPollManagerFactory.java 2006-07-28 09:55:45 UTC (rev 5339)
+++ labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/src/org/jboss/soa/esb/samples/loanbroker/banks/BankPollManagerFactory.java 2006-07-28 12:55:35 UTC (rev 5340)
@@ -1,61 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2006, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-
-package org.jboss.soa.esb.samples.loanbroker.banks;
-
-import java.util.logging.Level;
-
-import org.apache.log4j.Logger;
-import org.apache.log4j.Priority;
-import org.sadun.util.polling.PollManager;
-import org.sadun.util.polling.PollManagerFactory;
-import org.sadun.util.polling.pollmanagers.LoggerHistoryPollManager;
-
-/**
- * A {@link org.sadun.util.polling.PollManagerFactory PollManagerFactory} which produces one
- * instance of {@link org.jboss.soa.esb.samples.loanbroker.banks.BankPollManager BankPollManager}
- *
- * @author cris
- */
-public class BankPollManagerFactory implements PollManagerFactory
-{
- private Logger logger = Logger.getLogger(this.getClass());
- /**
- * @see org.sadun.util.polling.PollManagerFactory#createPollManagers()
- */
- public PollManager[] createPollManagers(String name) {
- // In this particular factory, the MBean name is not used
- java.util.logging.Logger.getLogger("bank_f").setLevel(Level.WARNING);
- logger.log(Priority.INFO, "Creating testPollManager for MBean <"+name+">");
- return new PollManager[] { new BankPollManager(), new LoggerHistoryPollManager("bank_f") };
- }
-
- /**
- * @see org.sadun.util.polling.PollManagerFactory#getDescription()
- */
- public String getDescription() {
- return "A factory producing one instance of org.jboss.soa.esb.samples.loanbroker.banks.BankPollManager";
- }
-
-}
-
-
\ No newline at end of file
Modified: labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/src/org/jboss/soa/esb/samples/loanbroker/banks/BankQuoteRequest.java
===================================================================
--- labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/src/org/jboss/soa/esb/samples/loanbroker/banks/BankQuoteRequest.java 2006-07-28 09:55:45 UTC (rev 5339)
+++ labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/src/org/jboss/soa/esb/samples/loanbroker/banks/BankQuoteRequest.java 2006-07-28 12:55:35 UTC (rev 5340)
@@ -47,14 +47,14 @@
this.creditScore = creditScore;
}
/**
- * Gets the credit history length (in years).
+ * Gets the credit history length (in months).
* @return credit history length
*/
public int getHistoryLength() {
return historyLength;
}
/**
- * Sets the credit history length (in years).
+ * Sets the credit history length (in months).
* @param historyLength
*/
public void setHistoryLength(int historyLength) {
Copied: labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/src/org/jboss/soa/esb/samples/loanbroker/banks/FlatFilePollManager.java (from rev 5333, labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/src/org/jboss/soa/esb/samples/loanbroker/banks/BankPollManager.java)
===================================================================
--- labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/src/org/jboss/soa/esb/samples/loanbroker/banks/BankPollManager.java 2006-07-28 02:26:42 UTC (rev 5333)
+++ labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/src/org/jboss/soa/esb/samples/loanbroker/banks/FlatFilePollManager.java 2006-07-28 12:55:35 UTC (rev 5340)
@@ -0,0 +1,184 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.soa.esb.samples.loanbroker.banks;
+
+import java.io.File;
+import java.math.BigDecimal;
+
+import org.apache.log4j.Logger;
+import org.apache.log4j.Priority;
+import org.sadun.util.polling.BasePollManager;
+import org.sadun.util.polling.CycleEndEvent;
+import org.sadun.util.polling.CycleStartEvent;
+import org.sadun.util.polling.DirectoryLookupEndEvent;
+import org.sadun.util.polling.DirectoryLookupStartEvent;
+import org.sadun.util.polling.FileFoundEvent;
+import org.sadun.util.polling.FileSetFoundEvent;
+
+/**
+ * The FlatFilePollManager monitors a directory specified in the configuration. When a file arrives it
+ * tries to process the content assuming it contains one line with loan request information.
+ * So for example the content of the file could read some like <br>23456890,3,4,20000,5<br>
+ * The order of values needs to be SocialSecurityNumber, CreditScore, HistoryLength [month], LoanAmount [dollar],
+ * and finally the LoanTerm [month]. The request will be processed and a BankQouteReply is generated. The
+ * original file is moved to a processed directory, and the BankQuoteReply is serialized to an 'outgoing'
+ * directory from the it can be picked up by the system that dropped the request.
+ *
+ * @author kstam
+ *
+ */
+
+class FlatFilePollManager extends BasePollManager
+{
+ private Logger logger = Logger.getLogger(this.getClass());
+
+ private static final String BANK_NAME = "FileBasedBank";
+ private static final BigDecimal RATE_PREMIUM = BigDecimal.valueOf(0.25);
+ private static final int MAXLOANTERM = 120;
+ private static final String OUTGOING_DIR = "outgoing";
+ private static final String PREFIX = "reply_to_";
+ private static final String PROCESSED_DIR = "processed";
+ /**
+ * Handle to the cycle start event.
+ */
+ public void cycleStarted(CycleStartEvent evt) {
+ logger.log(Priority.DEBUG, "Poller awakened "
+ + (evt.getPoller().getFilter() == null ? "(no filtering)" : evt
+ .getPoller().getFilter().toString()));
+ }
+ /**
+ * Handle to the cycle end event.
+ */
+ public void cycleEnded(CycleEndEvent evt) {
+ logger.log(Priority.DEBUG, "Poller going to sleep");
+ }
+ /**
+ * Handle to the directory lookup start event.
+ */
+ public void directoryLookupStarted(DirectoryLookupStartEvent evt) {
+ logger.log(Priority.DEBUG, "Scanning " + evt.getDirectory());
+ }
+ /**
+ * Handle to the directory lookup end event.
+ */
+ public void directoryLookupEnded(DirectoryLookupEndEvent evt) {
+ logger.log(Priority.DEBUG, "Finished scanning " + evt.getDirectory());
+ }
+ /**
+ * Handle to the file set found event. Currenty this is the only event that
+ * is actually used to proces the incoming loan quote requests. Each file
+ * is send to be processed.
+ */
+ public void fileSetFound(FileSetFoundEvent evt) {
+ File[] files = evt.getFiles();
+
+ for (int i = 0; i < files.length; i++) {
+ File file = files[i];
+ processFile(file);
+ }
+ }
+ /**
+ * Handle to the file found event.
+ */
+ public void fileFound(FileFoundEvent evt) {
+ logger.log(Priority.DEBUG, evt);
+ // Add artificial delay
+ }
+ /**
+ * Returns the name of this PollManager and a quick summary of what it does.
+ */
+ public String toString() {
+ return "FlatFilePollManager - a pollmanager which processed incoming -flat file based- loan requests";
+ }
+ /**
+ * Each file is processed assuming it contains one line with loan request information.
+ * So for example the content of the file could read some like <br>23456890,3,4,20000,5<br>
+ * The order of values needs to be SocialSecurityNumber, CreditScore, HistoryLength [month], LoanAmount [dollar],
+ * and finally the LoanTerm [month]. The BankQuoteRequest is processed and a BankQouteReply is generated. The
+ * original file is moved to a processed directory, and the BankQuoteReply is serialized to an 'outgoing'
+ * directory from the it can be picked up by the system that dropped the request.
+ *
+ * @param file - incoming flat file with loan quote request info.
+ */
+ private void processFile(File file)
+ {
+ BankQuoteReply bankQuoteReply=new BankQuoteReply();
+ bankQuoteReply.setQuoteId(BANK_NAME);
+ int errorCode=6;
+ String message=null;
+ logger.log(Priority.INFO, "Found " + file.getAbsolutePath() );
+
+ try {
+ BankQuoteRequest bankQuoteRequest = new BankQuoteRequest();
+ //Read the content of the file into a String
+ message=FileUtil.readTextFile(file);
+ String[] messagePart = message.split(",");
+
+ errorCode=1;
+ bankQuoteRequest.setSsn(Integer.valueOf(messagePart[0]));
+ errorCode=2;
+ bankQuoteRequest.setCreditScore(Integer.valueOf(messagePart[1]));
+ errorCode=3;
+ bankQuoteRequest.setHistoryLength(Integer.valueOf(messagePart[2]));
+ errorCode=4;
+ bankQuoteRequest.setLoanAmount(Integer.valueOf(messagePart[3]));
+ errorCode=5;
+ bankQuoteRequest.setLoanTerm(Integer.valueOf(messagePart[4]));
+
+ Bank fileBasedBank = new Bank(BANK_NAME, RATE_PREMIUM, MAXLOANTERM);
+ bankQuoteReply = fileBasedBank.processMessage(bankQuoteRequest);
+ } catch (Throwable e) {
+ //Package up the error, so it can be processed
+ logger.log(Priority.ERROR, e.getMessage());
+ bankQuoteReply.setErrorCode(errorCode);
+ }
+
+ try {
+ //Create the outgoing response file
+ File outgoingDir = new File(file.getParent() + "/" + OUTGOING_DIR);
+ if (!outgoingDir.exists()) {
+ outgoingDir.mkdir();
+ }
+ File outgoingFile = new File(outgoingDir + "/" + PREFIX + file.getName());
+ logger.log(Priority.INFO, "Creating outgoing file " + outgoingFile.getAbsolutePath());
+ outgoingFile.createNewFile();
+ String reply=bankQuoteReply.getInterestRate() + "," + bankQuoteReply.getQuoteId() + "," + bankQuoteReply.getErrorCode();
+ logger.log(Priority.INFO, "Writing reply " + reply);
+ FileUtil.writeTextFile(outgoingFile, reply);
+
+ //Move the processed file away so it does not get processed again
+ File processedDir = new File(file.getParent() + "/" + PROCESSED_DIR);
+ if (!processedDir.exists()) {
+ processedDir.mkdir();
+ }
+ logger.log(Priority.INFO, "Moving file " + file.getName() + " to processed directory");
+ File processedFile = new File(processedDir.getAbsolutePath() + "/" + file.getName());
+ file.renameTo(processedFile);
+ if (file.exists()) {
+ file.delete();
+ }
+ } catch (Exception e) {
+ logger.log(Priority.ERROR, e.getMessage(), e);
+ }
+ }
+
+}
\ No newline at end of file
Copied: labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/src/org/jboss/soa/esb/samples/loanbroker/banks/FlatFilePollManagerFactory.java (from rev 5334, labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/src/org/jboss/soa/esb/samples/loanbroker/banks/BankPollManagerFactory.java)
===================================================================
--- labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/src/org/jboss/soa/esb/samples/loanbroker/banks/BankPollManagerFactory.java 2006-07-28 02:27:15 UTC (rev 5334)
+++ labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/src/org/jboss/soa/esb/samples/loanbroker/banks/FlatFilePollManagerFactory.java 2006-07-28 12:55:35 UTC (rev 5340)
@@ -0,0 +1,61 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+
+package org.jboss.soa.esb.samples.loanbroker.banks;
+
+import java.util.logging.Level;
+
+import org.apache.log4j.Logger;
+import org.apache.log4j.Priority;
+import org.sadun.util.polling.PollManager;
+import org.sadun.util.polling.PollManagerFactory;
+import org.sadun.util.polling.pollmanagers.LoggerHistoryPollManager;
+
+/**
+ * A {@link org.sadun.util.polling.PollManagerFactory PollManagerFactory} which produces one
+ * instance of {@link org.jboss.soa.esb.samples.loanbroker.banks.FlatFilePollManager BankPollManager}
+ *
+ * @author kstam
+ */
+public class FlatFilePollManagerFactory implements PollManagerFactory
+{
+ private Logger logger = Logger.getLogger(this.getClass());
+ /**
+ * @see org.sadun.util.polling.PollManagerFactory#createPollManagers()
+ */
+ public PollManager[] createPollManagers(String name) {
+ // In this particular factory, the MBean name is not used
+ java.util.logging.Logger.getLogger("bank_f").setLevel(Level.WARNING);
+ logger.log(Priority.INFO, "Creating FlatFilePollManager for MBean <"+name+">");
+ return new PollManager[] { new FlatFilePollManager(), new LoggerHistoryPollManager("bank_f") };
+ }
+
+ /**
+ * @see org.sadun.util.polling.PollManagerFactory#getDescription()
+ */
+ public String getDescription() {
+ return "A factory producing one instance of org.jboss.soa.esb.samples.loanbroker.banks.FlatFilePollManager";
+ }
+
+}
+
+
\ No newline at end of file
Added: labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/test/org/jboss/soa/esb/samples/loanbroker/banks/FlatFileProcessorTest.java
===================================================================
--- labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/test/org/jboss/soa/esb/samples/loanbroker/banks/FlatFileProcessorTest.java 2006-07-28 09:55:45 UTC (rev 5339)
+++ labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/test/org/jboss/soa/esb/samples/loanbroker/banks/FlatFileProcessorTest.java 2006-07-28 12:55:35 UTC (rev 5340)
@@ -0,0 +1,67 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.soa.esb.samples.loanbroker.banks;
+
+import static org.junit.Assert.*;
+
+import java.io.File;
+import java.math.BigDecimal;
+
+import junit.framework.JUnit4TestAdapter;
+
+import org.apache.log4j.Logger;
+import org.apache.log4j.Priority;
+import org.junit.Test;
+
+public class FlatFileProcessorTest {
+
+ private Logger logger = Logger.getLogger(this.getClass());
+
+ /**
+ * Tests the processing of flat file containing a loan quote request. First
+ * we try to find a temporary directory
+ *
+ */
+ @Test public void processRequest()
+ {
+ File writableDir=null;
+ logger.log(Priority.INFO, "Check to see if I can write to /tmp");
+ File tmpDir = new File("/tmp");
+ if (tmpDir.exists() && tmpDir.canWrite()) {
+ writableDir=tmpDir;
+ } else {
+ File tempDir = new File("C:/temp");
+ if (tempDir.exists() && tempDir.canWrite()) {
+ writableDir=tempDir;
+ } else {
+ logger.log(Priority.ERROR, "Could not find either /tmp or C:\\Temp for a temporary "
+ + "writing space.");
+ assertTrue(false);
+ }
+ }
+
+ }
+
+ public static junit.framework.Test suite() {
+ return new JUnit4TestAdapter(FlatFileProcessorTest.class);
+ }
+}
More information about the jboss-svn-commits
mailing list