01: /*
02: * $Header: /cvsroot/jvalidate/jvalidate-framework/jvalidate/src/test/java/nl/knowlogy/validation/test/AdressMetadataTest.java,v 1.5 2007/04/07 12:28:01 roberthofstra Exp $
03: * $Revision: 1.5 $
04: * $Date: 2007/04/07 12:28:01 $
05: *
06: *
07: * Created on Oct 6, 2004
08: *
09: * All right reserved(c) 2004, Knowlogy
10: *
11: * Copyright 2004 - 2005 Knowlogy, the Netherlands. All rights reserved.
12: * All Knowlogy brand and product names are trademarks or registered trademarks
13: * of Knowlogy in the Netherlands and other countries.
14: *
15: * No part of this publication may be reproduced, transmitted, stored in a retrieval system,
16: * or translated into any human or computer language, in any form, or by any means, electronic,
17: * mechanical, magnetic, optical, chemical, manual, or otherwise,
18: * without the prior written permission of the copyright owner, Knowlogy.
19: *
20: */
21: package nl.knowlogy.validation.test;
22:
23: import junit.framework.TestCase;
24: import nl.knowlogy.validation.Messages;
25: import nl.knowlogy.validation.MessagesImpl;
26: import nl.knowlogy.validation.ValidationEngine;
27: import nl.knowlogy.validation.metadata.ClassMetadata;
28: import nl.knowlogy.validation.metadata.PropertyMetadata;
29:
30: /**
31: *
32: * @author Robert
33: */
34: public class AdressMetadataTest extends TestCase {
35:
36: public void testAdressStreetMetadata() {
37:
38: ClassMetadata addressClassMetadataInfo = ValidationEngine
39: .getClassMetaData(Address.class);
40:
41: PropertyMetadata streetMetadata = addressClassMetadataInfo
42: .getPropertyMetadata("street");
43: assertNotNull(streetMetadata);
44: assertEquals(new Long(30), streetMetadata.getMaxLength());
45: assertEquals(Boolean.TRUE, streetMetadata.isRequired());
46: }
47:
48: public void testInternationalization() throws Exception {
49: Address address = new Address();
50:
51: address.setCity("Groningen, what is much to long");
52: //adress.setHouseNumber(new Integer(2));
53: //adress.setStreet("DiephuisStraat");
54: //adress.setTypeAdres("V");
55:
56: Messages errors = new MessagesImpl();
57: ValidationEngine.validate(address, errors);
58:
59: assertNotNull(errors.getMessage(address, "city"));
60:
61: // Message pe = errors.getError("city");
62: // pe.getErrorCode();
63: // pe.getPropertyName();
64: // Object[] arguments = pe.getErrorArgs();
65: //
66: // InputStream ip = this.getClass().getClassLoader().getResourceAsStream("test.properties");
67: // ResourceBundle rb = new PropertyResourceBundle(ip);
68: // String propertyName = rb.getString(pe.getPropertyName());
69: // String errorMessage = rb.getString(pe.getErrorCode());
70: // // replace first argument with localized propertyname
71: // arguments[0] = propertyName;
72: //
73: //
74: // String result = MessageFormat.format(
75: // errorMessage,
76: // arguments);
77: // System.out.println(result);
78:
79: }
80:
81: }
|