|
From: Pelle B. <pe...@us...> - 2004-04-05 16:44:26
|
Update of /cvsroot/neuclear/neuclear-pay/src/test/org/neuclear/exchange/orders/builders In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25941/src/test/org/neuclear/exchange/orders/builders Added Files: AbstractExchangeOrderTest.java CancelExchangeOrderBuilderTest.java CancelExchangeReceiptBuilderTest.java ExchangeCompletedReceiptBuilderTest.java ExchangeCompletionOrderBuilderTest.java ExchangeOrderBuilderTest.java ExchangeOrderReceiptBuilderTest.java Log Message: Created new ServiceBuilder class for creating services. A service is an identity that has a seperate service URL and Service Public Key. --- NEW FILE: AbstractExchangeOrderTest.java --- package org.neuclear.exchange.orders.builders; import org.neuclear.asset.contracts.Asset; import org.neuclear.asset.contracts.builders.AssetBuilder; import org.neuclear.commons.NeuClearException; import org.neuclear.exchange.contracts.ExchangeAgent; import org.neuclear.exchange.contracts.builders.ExchangeAgentBuilder; import org.neuclear.tests.AbstractObjectCreationTest; import java.security.GeneralSecurityException; /* $Id: AbstractExchangeOrderTest.java,v 1.1 2004/04/05 16:31:44 pelle Exp $ $Log: AbstractExchangeOrderTest.java,v $ Revision 1.1 2004/04/05 16:31:44 pelle Created new ServiceBuilder class for creating services. A service is an identity that has a seperate service URL and Service Public Key. */ /** * User: pelleb * Date: Apr 5, 2004 * Time: 10:30:19 AM */ public abstract class AbstractExchangeOrderTest extends AbstractObjectCreationTest { public AbstractExchangeOrderTest(final String string) throws NeuClearException, GeneralSecurityException { super(string); bux = createTestAsset(); agent = createTestExchangeAgent(); shoes = createShoeAsset(); } public Asset createTestAsset() throws NeuClearException { AssetBuilder builder = new AssetBuilder("http://bux.neuclear.org", getSigner().getPublicKey("neu://test/bux"), getAlice().getPublicKey(), 2, 0); return (Asset) builder.convert(NAME, getSigner()); } public Asset createShoeAsset() throws NeuClearException { AssetBuilder builder = new AssetBuilder("http://shoes.neuclear.org", getSigner().getPublicKey("neu://test"), getAlice().getPublicKey(), 2, 0); return (Asset) builder.convert(NAME, getSigner()); } public ExchangeAgent createTestExchangeAgent() throws NeuClearException { ExchangeAgentBuilder builder = new ExchangeAgentBuilder("http://tradex.neuclear.org", getSigner().getPublicKey("neu://bob@test")); return (ExchangeAgent) builder.convert(NAME, getSigner()); } protected Asset bux; protected Asset shoes; protected ExchangeAgent agent; } --- NEW FILE: ExchangeCompletedReceiptBuilderTest.java --- package org.neuclear.exchange.orders.builders; import org.neuclear.asset.InvalidTransferException; import org.neuclear.asset.orders.Amount; import org.neuclear.commons.NeuClearException; import org.neuclear.commons.crypto.signers.NonExistingSignerException; import org.neuclear.exchange.orders.*; import org.neuclear.id.SignedNamedObject; import org.neuclear.id.builders.Builder; import org.neuclear.xml.XMLException; import java.security.GeneralSecurityException; import java.util.Date; /* NeuClear Distributed Transaction Clearing Platform (C) 2003 Pelle Braendgaard This library 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 library 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 library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA $Id: ExchangeCompletedReceiptBuilderTest.java,v 1.1 2004/04/05 16:31:45 pelle Exp $ $Log: ExchangeCompletedReceiptBuilderTest.java,v $ Revision 1.1 2004/04/05 16:31:45 pelle Created new ServiceBuilder class for creating services. A service is an identity that has a seperate service URL and Service Public Key. Revision 1.6 2004/04/02 23:04:36 pelle Got TransferOrder and Builder working with their test cases. Working on TransferReceipt which is the first embedded receipt. This is causing some problems at the moment. Revision 1.5 2004/04/02 17:56:16 pelle Added new createTestAsset() method. Revision 1.4 2004/04/01 23:18:33 pelle Split Identity into Signatory and Identity class. Identity remains a signed named object and will in the future just be used for self declared information. Signatory now contains the PublicKey etc and is NOT a signed object. Revision 1.3 2004/03/03 23:28:14 pelle Updated tests to use AbstractObjectCreationTest Revision 1.2 2004/02/18 00:13:31 pelle Many, many clean ups. I've readded Targets in a new method. Gotten rid of NamedObjectBuilder and revamped Identity and Resolvers Revision 1.1 2004/01/21 23:41:02 pelle Started the unit tests for the new payment message format. */ /** * User: pelleb * Date: Jan 21, 2004 * Time: 9:11:44 PM */ public class ExchangeCompletedReceiptBuilderTest extends AbstractExchangeOrderTest { public ExchangeCompletedReceiptBuilderTest(String string) throws NeuClearException, GeneralSecurityException { super(string); } protected void verifyObject(SignedNamedObject obj) throws NonExistingSignerException { assertNotNull(obj); assertTrue(obj instanceof ExchangeCompletedReceipt); ExchangeCompletedReceipt cr = (ExchangeCompletedReceipt) obj; assertEquals(getSigner().getPublicKey("neu://test").getEncoded(), cr.getSignatory().getPublicKey().getEncoded()); assertNotNull(cr.getOrder()); assertNotNull(cr.getValueTime()); ExchangeCompletionOrder complete = cr.getOrder(); assertEquals(getSigner().getPublicKey("neu://test/bux").getEncoded(), complete.getSignatory().getPublicKey().getEncoded()); assertEquals("done", complete.getComment()); assertEquals(19.0, complete.getAmount().getAmount(), 0); assertNotNull(complete.getExchangeTime()); assertNotNull(complete.getReceipt()); ExchangeOrderReceipt receipt = complete.getReceipt(); assertEquals(getSigner().getPublicKey("neu://test/bux").getEncoded(), receipt.getSignatory().getPublicKey().getEncoded()); assertNotNull(receipt.getValuetime()); assertNotNull(receipt.getOrder()); ExchangeOrder order = receipt.getOrder(); assertEquals(bux.getDigest(), order.getAsset().getDigest()); assertEquals(getSigner().getPublicKey("neu://test/bux").getEncoded(), order.getSignatory().getPublicKey().getEncoded()); // assertEquals(getBob().getPublicKey().getEncoded(), order.getRecipient().getSignatory().getPublicKey().getEncoded()); assertEquals("Test", order.getComment()); assertEquals(20.0, order.getAmount().getAmount(), 0); } protected Class getRequiredClass() { return ExchangeCompletedReceipt.class; } protected Builder createBuilder() throws NeuClearException, InvalidTransferException, XMLException { BidItem bids[] = new BidItem[]{new BidItem(shoes, new Amount(5))}; Builder ob = new ExchangeOrderBuilder(bux, agent, new Amount(20), new Date(System.currentTimeMillis() + 10000), bids, "Test"); ExchangeOrderReceiptBuilder rb = new ExchangeOrderReceiptBuilder((ExchangeOrder) ob.convert("neu://test/bux", getSigner()), new Date()); ExchangeCompletionOrderBuilder cb = new ExchangeCompletionOrderBuilder((ExchangeOrderReceipt) rb.convert("neu://test/bux", getSigner()), new Date(), "neu://alice@test", new Amount(19), "done"); ExchangeCompletedReceiptBuilder builder = new ExchangeCompletedReceiptBuilder((ExchangeCompletionOrder) cb.convert("neu://test/bux", getSigner()), new Date()); return builder; } } --- NEW FILE: ExchangeCompletionOrderBuilderTest.java --- package org.neuclear.exchange.orders.builders; import org.neuclear.asset.InvalidTransferException; import org.neuclear.asset.orders.Amount; import org.neuclear.commons.NeuClearException; import org.neuclear.commons.crypto.signers.NonExistingSignerException; import org.neuclear.exchange.orders.BidItem; import org.neuclear.exchange.orders.ExchangeCompletionOrder; import org.neuclear.exchange.orders.ExchangeOrder; import org.neuclear.exchange.orders.ExchangeOrderReceipt; import org.neuclear.id.SignedNamedObject; import org.neuclear.id.builders.Builder; import org.neuclear.xml.XMLException; import java.security.GeneralSecurityException; import java.util.Date; /* NeuClear Distributed Transaction Clearing Platform (C) 2003 Pelle Braendgaard This library 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 library 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 library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA $Id: ExchangeCompletionOrderBuilderTest.java,v 1.1 2004/04/05 16:31:45 pelle Exp $ $Log: ExchangeCompletionOrderBuilderTest.java,v $ Revision 1.1 2004/04/05 16:31:45 pelle Created new ServiceBuilder class for creating services. A service is an identity that has a seperate service URL and Service Public Key. Revision 1.6 2004/04/02 23:04:36 pelle Got TransferOrder and Builder working with their test cases. Working on TransferReceipt which is the first embedded receipt. This is causing some problems at the moment. Revision 1.5 2004/04/02 17:56:16 pelle Added new createTestAsset() method. Revision 1.4 2004/04/01 23:18:33 pelle Split Identity into Signatory and Identity class. Identity remains a signed named object and will in the future just be used for self declared information. Signatory now contains the PublicKey etc and is NOT a signed object. Revision 1.3 2004/03/03 23:28:14 pelle Updated tests to use AbstractObjectCreationTest Revision 1.2 2004/02/18 00:13:31 pelle Many, many clean ups. I've readded Targets in a new method. Gotten rid of NamedObjectBuilder and revamped Identity and Resolvers Revision 1.1 2004/01/21 23:41:02 pelle Started the unit tests for the new payment message format. */ /** * User: pelleb * Date: Jan 21, 2004 * Time: 9:11:44 PM */ public class ExchangeCompletionOrderBuilderTest extends AbstractExchangeOrderTest { public ExchangeCompletionOrderBuilderTest(String string) throws NeuClearException, GeneralSecurityException { super(string); } protected void verifyObject(SignedNamedObject obj) throws NonExistingSignerException { assertNotNull(obj); assertTrue(obj instanceof ExchangeCompletionOrder); ExchangeCompletionOrder complete = (ExchangeCompletionOrder) obj; assertEquals(getSigner().getPublicKey("neu://test").getEncoded(), complete.getSignatory().getPublicKey().getEncoded()); assertEquals("done", complete.getComment()); assertEquals(19.0, complete.getAmount().getAmount(), 0); assertNotNull(complete.getExchangeTime()); assertNotNull(complete.getReceipt()); ExchangeOrderReceipt receipt = complete.getReceipt(); assertEquals(getSigner().getPublicKey("neu://test/bux").getEncoded(), receipt.getSignatory().getPublicKey().getEncoded()); assertNotNull(receipt.getValuetime()); assertNotNull(receipt.getOrder()); ExchangeOrder order = receipt.getOrder(); assertEquals(bux.getDigest(), order.getAsset().getDigest()); assertEquals(getSigner().getPublicKey("neu://test/bux").getEncoded(), order.getSignatory().getPublicKey().getEncoded()); // assertEquals(getBob().getPublicKey().getEncoded(), order.getRecipient().getSignatory().getPublicKey().getEncoded()); assertEquals("Test", order.getComment()); assertEquals(20.0, order.getAmount().getAmount(), 0); } protected Class getRequiredClass() { return ExchangeCompletionOrder.class; } protected Builder createBuilder() throws NeuClearException, InvalidTransferException, XMLException { BidItem bids[] = new BidItem[]{new BidItem(shoes, new Amount(5))}; Builder ob = new ExchangeOrderBuilder(bux, agent, new Amount(20), new Date(System.currentTimeMillis() + 10000), bids, "Test"); ExchangeOrderReceiptBuilder rb = new ExchangeOrderReceiptBuilder((ExchangeOrder) ob.convert("neu://test/bux", getSigner()), new Date()); ExchangeCompletionOrderBuilder builder = new ExchangeCompletionOrderBuilder((ExchangeOrderReceipt) rb.convert("neu://test/bux", getSigner()), new Date(), "neu://alice@test", new Amount(19), "done"); return builder; } } --- NEW FILE: CancelExchangeOrderBuilderTest.java --- package org.neuclear.exchange.orders.builders; import org.neuclear.asset.InvalidTransferException; import org.neuclear.asset.orders.Amount; import org.neuclear.commons.NeuClearException; import org.neuclear.commons.crypto.signers.NonExistingSignerException; import org.neuclear.exchange.orders.BidItem; import org.neuclear.exchange.orders.CancelExchangeOrder; import org.neuclear.exchange.orders.ExchangeOrder; import org.neuclear.exchange.orders.ExchangeOrderReceipt; import org.neuclear.id.SignedNamedObject; import org.neuclear.id.builders.Builder; import org.neuclear.xml.XMLException; import java.security.GeneralSecurityException; import java.util.Date; /* NeuClear Distributed Transaction Clearing Platform (C) 2003 Pelle Braendgaard This library 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 library 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 library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA $Id: CancelExchangeOrderBuilderTest.java,v 1.1 2004/04/05 16:31:45 pelle Exp $ $Log: CancelExchangeOrderBuilderTest.java,v $ Revision 1.1 2004/04/05 16:31:45 pelle Created new ServiceBuilder class for creating services. A service is an identity that has a seperate service URL and Service Public Key. Revision 1.6 2004/04/02 23:04:36 pelle Got TransferOrder and Builder working with their test cases. Working on TransferReceipt which is the first embedded receipt. This is causing some problems at the moment. Revision 1.5 2004/04/02 17:56:16 pelle Added new createTestAsset() method. Revision 1.4 2004/04/01 23:18:33 pelle Split Identity into Signatory and Identity class. Identity remains a signed named object and will in the future just be used for self declared information. Signatory now contains the PublicKey etc and is NOT a signed object. Revision 1.3 2004/03/03 23:28:14 pelle Updated tests to use AbstractObjectCreationTest Revision 1.2 2004/02/18 00:13:31 pelle Many, many clean ups. I've readded Targets in a new method. Gotten rid of NamedObjectBuilder and revamped Identity and Resolvers Revision 1.1 2004/01/21 23:41:02 pelle Started the unit tests for the new payment message format. */ /** * User: pelleb * Date: Jan 21, 2004 * Time: 9:11:44 PM */ public class CancelExchangeOrderBuilderTest extends AbstractExchangeOrderTest { public CancelExchangeOrderBuilderTest(String string) throws NeuClearException, GeneralSecurityException { super(string); } protected void verifyObject(SignedNamedObject obj) throws NonExistingSignerException { assertNotNull(obj); assertTrue(obj instanceof CancelExchangeOrder); CancelExchangeOrder cancel = (CancelExchangeOrder) obj; assertEquals(getSigner().getPublicKey("neu://test").getEncoded(), cancel.getSignatory().getPublicKey().getEncoded()); assertNotNull(cancel.getReceipt()); ExchangeOrderReceipt receipt = cancel.getReceipt(); assertEquals(getSigner().getPublicKey("neu://test/bux").getEncoded(), receipt.getSignatory().getPublicKey().getEncoded()); assertNotNull(receipt.getValuetime()); assertNotNull(receipt.getOrder()); ExchangeOrder order = receipt.getOrder(); assertEquals(bux.getDigest(), order.getAsset().getDigest()); assertEquals(getSigner().getPublicKey("neu://test/bux").getEncoded(), order.getSignatory().getPublicKey().getEncoded()); // assertEquals(getBob().getPublicKey().getEncoded(), order.getRecipient().getSignatory().getPublicKey().getEncoded()); assertEquals("Test", order.getComment()); assertEquals(20.0, order.getAmount().getAmount(), 0); } protected Class getRequiredClass() { return CancelExchangeOrder.class; } protected Builder createBuilder() throws NeuClearException, InvalidTransferException, XMLException { BidItem bids[] = new BidItem[]{new BidItem(shoes, new Amount(5))}; Builder ob = new ExchangeOrderBuilder(bux, agent, new Amount(20), new Date(System.currentTimeMillis() + 10000), bids, "Test"); ExchangeOrderReceiptBuilder rb = new ExchangeOrderReceiptBuilder((ExchangeOrder) ob.convert("neu://test/bux", getSigner()), new Date()); CancelExchangeOrderBuilder builder = new CancelExchangeOrderBuilder((ExchangeOrderReceipt) rb.convert("neu://test/bux", getSigner())); return builder; } } --- NEW FILE: ExchangeOrderReceiptBuilderTest.java --- package org.neuclear.exchange.orders.builders; import org.neuclear.asset.InvalidTransferException; import org.neuclear.asset.orders.Amount; import org.neuclear.commons.NeuClearException; import org.neuclear.commons.crypto.signers.NonExistingSignerException; import org.neuclear.exchange.orders.BidItem; import org.neuclear.exchange.orders.ExchangeOrder; import org.neuclear.exchange.orders.ExchangeOrderReceipt; import org.neuclear.id.SignedNamedObject; import org.neuclear.id.builders.Builder; import org.neuclear.xml.XMLException; import java.security.GeneralSecurityException; import java.util.Date; /* NeuClear Distributed Transaction Clearing Platform (C) 2003 Pelle Braendgaard This library 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 library 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 library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA $Id: ExchangeOrderReceiptBuilderTest.java,v 1.1 2004/04/05 16:31:45 pelle Exp $ $Log: ExchangeOrderReceiptBuilderTest.java,v $ Revision 1.1 2004/04/05 16:31:45 pelle Created new ServiceBuilder class for creating services. A service is an identity that has a seperate service URL and Service Public Key. Revision 1.6 2004/04/02 23:04:36 pelle Got TransferOrder and Builder working with their test cases. Working on TransferReceipt which is the first embedded receipt. This is causing some problems at the moment. Revision 1.5 2004/04/02 17:56:16 pelle Added new createTestAsset() method. Revision 1.4 2004/04/01 23:18:33 pelle Split Identity into Signatory and Identity class. Identity remains a signed named object and will in the future just be used for self declared information. Signatory now contains the PublicKey etc and is NOT a signed object. Revision 1.3 2004/03/03 23:28:14 pelle Updated tests to use AbstractObjectCreationTest Revision 1.2 2004/02/18 00:13:31 pelle Many, many clean ups. I've readded Targets in a new method. Gotten rid of NamedObjectBuilder and revamped Identity and Resolvers Revision 1.1 2004/01/21 23:41:02 pelle Started the unit tests for the new payment message format. */ /** * User: pelleb * Date: Jan 21, 2004 * Time: 9:11:44 PM */ public class ExchangeOrderReceiptBuilderTest extends AbstractExchangeOrderTest { public ExchangeOrderReceiptBuilderTest(String string) throws NeuClearException, GeneralSecurityException { super(string); } protected void verifyObject(SignedNamedObject obj) throws NonExistingSignerException { assertNotNull(obj); assertTrue(obj instanceof ExchangeOrderReceipt); ExchangeOrderReceipt receipt = (ExchangeOrderReceipt) obj; assertEquals(getSigner().getPublicKey("neu://test").getEncoded(), receipt.getSignatory().getPublicKey().getEncoded()); assertNotNull(receipt.getValuetime()); assertNotNull(receipt.getOrder()); ExchangeOrder order = receipt.getOrder(); assertEquals(bux.getDigest(), order.getAsset().getDigest()); assertEquals(getSigner().getPublicKey("neu://test/bux").getEncoded(), order.getSignatory().getPublicKey().getEncoded()); // assertEquals(getBob().getPublicKey().getEncoded(), order.getRecipient().getSignatory().getPublicKey().getEncoded()); assertEquals("Test", order.getComment()); assertEquals(20.0, order.getAmount().getAmount(), 0); } protected Class getRequiredClass() { return ExchangeOrderReceipt.class; } protected Builder createBuilder() throws NeuClearException, InvalidTransferException, XMLException { BidItem bids[] = new BidItem[]{new BidItem(shoes, new Amount(5))}; Builder ob = new ExchangeOrderBuilder(bux, agent, new Amount(20), new Date(System.currentTimeMillis() + 10000), bids, "Test"); ExchangeOrderReceiptBuilder builder = new ExchangeOrderReceiptBuilder((ExchangeOrder) ob.convert("neu://test/bux", getSigner()), new Date()); return builder; } } --- NEW FILE: ExchangeOrderBuilderTest.java --- package org.neuclear.exchange.orders.builders; import org.neuclear.asset.InvalidTransferException; import org.neuclear.asset.orders.Amount; import org.neuclear.commons.NeuClearException; import org.neuclear.commons.crypto.signers.NonExistingSignerException; import org.neuclear.exchange.orders.BidItem; import org.neuclear.exchange.orders.ExchangeOrder; import org.neuclear.id.SignedNamedObject; import org.neuclear.id.builders.Builder; import org.neuclear.xml.XMLException; import java.security.GeneralSecurityException; import java.util.Date; /* NeuClear Distributed Transaction Clearing Platform (C) 2003 Pelle Braendgaard This library 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 library 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 library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA $Id: ExchangeOrderBuilderTest.java,v 1.1 2004/04/05 16:31:45 pelle Exp $ $Log: ExchangeOrderBuilderTest.java,v $ Revision 1.1 2004/04/05 16:31:45 pelle Created new ServiceBuilder class for creating services. A service is an identity that has a seperate service URL and Service Public Key. Revision 1.6 2004/04/02 23:04:36 pelle Got TransferOrder and Builder working with their test cases. Working on TransferReceipt which is the first embedded receipt. This is causing some problems at the moment. Revision 1.5 2004/04/02 17:56:16 pelle Added new createTestAsset() method. Revision 1.4 2004/04/01 23:18:33 pelle Split Identity into Signatory and Identity class. Identity remains a signed named object and will in the future just be used for self declared information. Signatory now contains the PublicKey etc and is NOT a signed object. Revision 1.3 2004/03/03 23:28:14 pelle Updated tests to use AbstractObjectCreationTest Revision 1.2 2004/02/18 00:13:31 pelle Many, many clean ups. I've readded Targets in a new method. Gotten rid of NamedObjectBuilder and revamped Identity and Resolvers Revision 1.1 2004/01/21 23:41:02 pelle Started the unit tests for the new payment message format. */ /** * User: pelleb * Date: Jan 21, 2004 * Time: 9:11:44 PM */ public class ExchangeOrderBuilderTest extends AbstractExchangeOrderTest { public ExchangeOrderBuilderTest(String string) throws NeuClearException, GeneralSecurityException { super(string); } protected void verifyObject(SignedNamedObject obj) throws NonExistingSignerException { assertNotNull(obj); assertTrue(obj instanceof ExchangeOrder); ExchangeOrder order = (ExchangeOrder) obj; assertEquals(bux.getDigest(), order.getAsset().getDigest()); assertEquals(getSigner().getPublicKey("neu://test").getEncoded(), order.getSignatory().getPublicKey().getEncoded()); // assertEquals(getBob().getPublicKey().getEncoded(), order.getRecipient().getSignatory().getPublicKey().getEncoded()); assertEquals("Test", order.getComment()); assertEquals(20.0, order.getAmount().getAmount(), 0); } protected Class getRequiredClass() { return ExchangeOrder.class; } protected Builder createBuilder() throws NeuClearException, InvalidTransferException, XMLException { BidItem bids[] = new BidItem[]{new BidItem(shoes, new Amount(5))}; Builder builder = new ExchangeOrderBuilder(bux, agent, new Amount(20), new Date(System.currentTimeMillis() + 10000), bids, "Test"); // System.out.println(builder.asXML()); return builder; } } --- NEW FILE: CancelExchangeReceiptBuilderTest.java --- package org.neuclear.exchange.orders.builders; import org.neuclear.asset.InvalidTransferException; import org.neuclear.asset.orders.Amount; import org.neuclear.commons.NeuClearException; import org.neuclear.commons.crypto.signers.NonExistingSignerException; import org.neuclear.exchange.orders.*; import org.neuclear.id.SignedNamedObject; import org.neuclear.id.builders.Builder; import org.neuclear.xml.XMLException; import java.security.GeneralSecurityException; import java.util.Date; /* NeuClear Distributed Transaction Clearing Platform (C) 2003 Pelle Braendgaard This library 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 library 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 library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA $Id: CancelExchangeReceiptBuilderTest.java,v 1.1 2004/04/05 16:31:45 pelle Exp $ $Log: CancelExchangeReceiptBuilderTest.java,v $ Revision 1.1 2004/04/05 16:31:45 pelle Created new ServiceBuilder class for creating services. A service is an identity that has a seperate service URL and Service Public Key. Revision 1.6 2004/04/02 23:04:36 pelle Got TransferOrder and Builder working with their test cases. Working on TransferReceipt which is the first embedded receipt. This is causing some problems at the moment. Revision 1.5 2004/04/02 17:56:16 pelle Added new createTestAsset() method. Revision 1.4 2004/04/01 23:18:33 pelle Split Identity into Signatory and Identity class. Identity remains a signed named object and will in the future just be used for self declared information. Signatory now contains the PublicKey etc and is NOT a signed object. Revision 1.3 2004/03/03 23:28:14 pelle Updated tests to use AbstractObjectCreationTest Revision 1.2 2004/02/18 00:13:31 pelle Many, many clean ups. I've readded Targets in a new method. Gotten rid of NamedObjectBuilder and revamped Identity and Resolvers Revision 1.1 2004/01/21 23:41:02 pelle Started the unit tests for the new payment message format. */ /** * User: pelleb * Date: Jan 21, 2004 * Time: 9:11:44 PM */ public class CancelExchangeReceiptBuilderTest extends AbstractExchangeOrderTest { public CancelExchangeReceiptBuilderTest(String string) throws NeuClearException, GeneralSecurityException { super(string); } protected void verifyObject(SignedNamedObject obj) throws NonExistingSignerException { assertNotNull(obj); assertTrue(obj instanceof CancelExchangeReceipt); CancelExchangeReceipt cr = (CancelExchangeReceipt) obj; assertEquals(getSigner().getPublicKey("neu://test").getEncoded(), cr.getSignatory().getPublicKey().getEncoded()); assertNotNull(cr.getCancellationTime()); assertNotNull(cr.getOrder()); CancelExchangeOrder cancel = (CancelExchangeOrder) cr.getOrder(); assertEquals(getSigner().getPublicKey("neu://test/bux").getEncoded(), cancel.getSignatory().getPublicKey().getEncoded()); assertNotNull(cancel.getReceipt()); ExchangeOrderReceipt receipt = cancel.getReceipt(); assertEquals(getSigner().getPublicKey("neu://test/bux").getEncoded(), receipt.getSignatory().getPublicKey().getEncoded()); assertNotNull(receipt.getValuetime()); assertNotNull(receipt.getOrder()); ExchangeOrder order = receipt.getOrder(); assertEquals(bux.getDigest(), order.getAsset().getDigest()); assertEquals(getSigner().getPublicKey("neu://test/bux").getEncoded(), order.getSignatory().getPublicKey().getEncoded()); // assertEquals(getBob().getPublicKey().getEncoded(), order.getRecipient().getSignatory().getPublicKey().getEncoded()); assertEquals("Test", order.getComment()); assertEquals(20.0, order.getAmount().getAmount(), 0); } protected Class getRequiredClass() { return CancelExchangeReceipt.class; } protected Builder createBuilder() throws NeuClearException, InvalidTransferException, XMLException { BidItem bids[] = new BidItem[]{new BidItem(shoes, new Amount(5))}; Builder ob = new ExchangeOrderBuilder(bux, agent, new Amount(20), new Date(System.currentTimeMillis() + 10000), bids, "Test"); ExchangeOrderReceiptBuilder rb = new ExchangeOrderReceiptBuilder((ExchangeOrder) ob.convert("neu://test/bux", getSigner()), new Date()); CancelExchangeOrderBuilder cb = new CancelExchangeOrderBuilder((ExchangeOrderReceipt) rb.convert("neu://test/bux", getSigner())); System.out.println(cb.asXML()); final CancelExchangeOrder req = (CancelExchangeOrder) cb.convert("neu://test/bux", getSigner()); CancelExchangeReceiptBuilder builder = new CancelExchangeReceiptBuilder(req, new Date()); return builder; } } |