01: /*
02: * Copyright (C) 2007 Rob Manning
03: * manningr@users.sourceforge.net
04: *
05: * This library is free software; you can redistribute it and/or
06: * modify it under the terms of the GNU Lesser General Public
07: * License as published by the Free Software Foundation; either
08: * version 2.1 of the License, or (at your option) any later version.
09: *
10: * This library is distributed in the hope that it will be useful,
11: * but WITHOUT ANY WARRANTY; without even the implied warranty of
12: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13: * Lesser General Public License for more details.
14: *
15: * You should have received a copy of the GNU Lesser General Public
16: * License along with this library; if not, write to the Free Software
17: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18: */
19: package net.sourceforge.squirrel_sql.plugins.i18n;
20:
21: import static org.junit.Assert.fail;
22:
23: import java.io.ByteArrayInputStream;
24: import java.io.File;
25: import java.net.URL;
26: import java.util.Properties;
27:
28: import org.junit.After;
29: import org.junit.Before;
30: import org.junit.Test;
31:
32: /**
33: * Test class for I18nProps
34: *
35: * @author manningr
36: */
37: public class I18nPropsTest {
38:
39: InMemoryI18nProperties propsUnderTest = null;
40:
41: @Before
42: public void setUp() throws Exception {
43: propsUnderTest = new InMemoryI18nProperties();
44: }
45:
46: @After
47: public void tearDown() throws Exception {
48: propsUnderTest = null;
49: }
50:
51: /**
52: * This tests the bug-fix for the following exception:
53: *
54: java.util.ConcurrentModificationException
55: at java.util.Hashtable$Enumerator.next(Hashtable.java:1020)
56: at net.sourceforge.squirrel_sql.plugins.i18n.I18nProps.getTranslateableProperties(I18nProps.java:221)
57: at net.sourceforge.squirrel_sql.plugins.i18n.I18nPropsTest.testGetTranslateableProperties_Bug1787731(I18nPropsTest.java:57)
58: */
59: @Test
60: public void testGetTranslateableProperties_Bug1787731() {
61: /* Call class under test */
62: propsUnderTest.getTranslateableProperties();
63: }
64:
65: private class InMemoryI18nProperties extends I18nProps {
66:
67: public InMemoryI18nProperties() {
68: super (new File("foo"), new URL[] {});
69: }
70:
71: @Override
72: Properties getProperties() {
73: StringBuilder propsFile = new StringBuilder();
74: propsFile.append("test1.image=test1.jpg\n");
75: propsFile.append("test2.image=test2.jpg\n");
76: propsFile.append("test3.image=test3.jpg\n");
77: propsFile.append("test4.image=test4.jpg\n");
78: ByteArrayInputStream is = new ByteArrayInputStream(
79: propsFile.toString().getBytes());
80: Properties result = new Properties();
81: try {
82: result.load(is);
83: } catch (Exception e) {
84: e.printStackTrace();
85: fail(e.getMessage());
86: }
87: return result;
88: }
89:
90: }
91: }
|