From a73afe1b71b62386dbf5f463571a54f8b0bca9a1 Mon Sep 17 00:00:00 2001
From: matthew_swift <matthew_swift@localhost>
Date: Tue, 10 Feb 2009 11:17:26 +0000
Subject: [PATCH] Fix org.opends.messages.PropertiesFilesTest unit test failure - remove duplicate messages.
---
opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/ui/ConnectionHandlerMonitoringPanel.java | 16 ++++++--
opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/ui/BrowseGeneralMonitoringPanel.java | 12 +++++
opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/messages/PropertiesFilesTest.java | 46 +++++++++++++++++-----
opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/ui/BrowseSchemaPanel.java | 14 ++++++
opendj-sdk/opends/src/messages/messages/admin_tool.properties | 7 +--
5 files changed, 73 insertions(+), 22 deletions(-)
diff --git a/opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/ui/BrowseGeneralMonitoringPanel.java b/opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/ui/BrowseGeneralMonitoringPanel.java
index 4970260..9560bc5 100644
--- a/opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/ui/BrowseGeneralMonitoringPanel.java
+++ b/opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/ui/BrowseGeneralMonitoringPanel.java
@@ -85,7 +85,7 @@
private Message NO_ELEMENT_SELECTED =
INFO_CTRL_PANEL_GENERAL_MONITORING_NO_ITEM_SELECTED.get();
private Message MULTIPLE_ITEMS_SELECTED =
- INFO_CTRL_PANEL_MULTIPLE_ITEMS_SELECTED.get();
+ INFO_CTRL_PANEL_MULTIPLE_ITEMS_SELECTED_LABEL.get();
/**
* The enumeration used to define the different static nodes of the tree.
@@ -137,6 +137,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean requiresBorder()
{
return false;
@@ -145,6 +146,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean requiresScroll()
{
return false;
@@ -153,6 +155,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean callConfigurationChangedInBackground()
{
return true;
@@ -161,6 +164,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void toBeDisplayed(boolean visible)
{
((GenericDialog)Utilities.getParentDialog(this)).getRootPane().
@@ -195,6 +199,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Message getTitle()
{
return INFO_CTRL_PANEL_GENERAL_MONITORING_TITLE.get();
@@ -203,6 +208,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Component getPreferredFocusComponent()
{
return treePane;
@@ -211,6 +217,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void okClicked()
{
// No ok button
@@ -219,6 +226,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public GenericDialog.ButtonType getButtonType()
{
return GenericDialog.ButtonType.CLOSE;
@@ -294,6 +302,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void setInfo(ControlPanelInfo info)
{
super.setInfo(info);
@@ -622,6 +631,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Component getTreeCellRendererComponent(JTree tree, Object value,
boolean isSelected, boolean isExpanded, boolean isLeaf, int row,
boolean hasFocus)
diff --git a/opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/ui/BrowseSchemaPanel.java b/opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/ui/BrowseSchemaPanel.java
index 5a54ecc..77afb19 100644
--- a/opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/ui/BrowseSchemaPanel.java
+++ b/opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/ui/BrowseSchemaPanel.java
@@ -184,7 +184,7 @@
private Message CATEGORY_ITEM_SELECTED =
INFO_CTRL_PANEL_CATEGORY_ITEM_SELECTED.get();
private Message MULTIPLE_ITEMS_SELECTED =
- INFO_CTRL_PANEL_MULTIPLE_ITEMS_SELECTED.get();
+ INFO_CTRL_PANEL_MULTIPLE_SCHEMA_ITEMS_SELECTED.get();
/**
* Default constructor.
@@ -199,6 +199,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean requiresBorder()
{
return false;
@@ -207,6 +208,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean requiresScroll()
{
return false;
@@ -215,6 +217,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean callConfigurationChangedInBackground()
{
return true;
@@ -223,6 +226,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void toBeDisplayed(boolean visible)
{
((GenericDialog)Utilities.getParentDialog(this)).getRootPane().
@@ -316,6 +320,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void keyReleased(KeyEvent e)
{
if ((e.getKeyCode() == KeyEvent.VK_ENTER) && applyButton.isEnabled())
@@ -421,6 +426,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Message getTitle()
{
return INFO_CTRL_PANEL_MANAGE_SCHEMA_TITLE.get();
@@ -429,6 +435,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Component getPreferredFocusComponent()
{
return filter;
@@ -437,6 +444,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void closeClicked()
{
setSecondaryValid(lFilter);
@@ -446,6 +454,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void okClicked()
{
// No ok button
@@ -454,6 +463,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public GenericDialog.ButtonType getButtonType()
{
return GenericDialog.ButtonType.NO_BUTTON;
@@ -599,6 +609,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void setInfo(ControlPanelInfo info)
{
super.setInfo(info);
@@ -1807,6 +1818,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Component getTreeCellRendererComponent(JTree tree, Object value,
boolean isSelected, boolean isExpanded, boolean isLeaf, int row,
boolean hasFocus)
diff --git a/opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/ui/ConnectionHandlerMonitoringPanel.java b/opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/ui/ConnectionHandlerMonitoringPanel.java
index 076f652..e6bb42b 100644
--- a/opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/ui/ConnectionHandlerMonitoringPanel.java
+++ b/opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/ui/ConnectionHandlerMonitoringPanel.java
@@ -76,8 +76,6 @@
import org.opends.guitools.controlpanel.datamodel.ConnectionHandlerDescriptor.
State;
import org.opends.guitools.controlpanel.event.ConfigurationChangeEvent;
-import org.opends.guitools.controlpanel.ui.StatusGenericPanel.
- IgnoreItemListener;
import org.opends.guitools.controlpanel.ui.renderer.CustomListCellRenderer;
import org.opends.guitools.controlpanel.util.Utilities;
import org.opends.guitools.controlpanel.util.ViewPositions;
@@ -259,6 +257,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Message getTitle()
{
return INFO_CTRL_PANEL_CONNECTION_HANDLER_MONITORING_TITLE.get();
@@ -267,6 +266,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public JMenuBar getMenuBar()
{
if (menuBar == null)
@@ -397,6 +397,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Component getPreferredFocusComponent()
{
return connectionHandlers;
@@ -405,6 +406,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void okClicked()
{
// No ok button
@@ -413,6 +415,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public GenericDialog.ButtonType getButtonType()
{
return GenericDialog.ButtonType.CLOSE;
@@ -422,6 +425,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean requiresBorder()
{
return false;
@@ -430,6 +434,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean requiresScroll()
{
return false;
@@ -542,7 +547,7 @@
{
if (ch.getProtocol() != Protocol.LDIF)
{
- cchs.add((ConnectionHandlerDescriptor)ch);
+ cchs.add(ch);
}
}
cchs.add(server.getAdminConnector());
@@ -554,7 +559,7 @@
{
if (getConnectionHandlerLabel(ch).equals(name))
{
- cchs.add((ConnectionHandlerDescriptor)ch);
+ cchs.add(ch);
break;
}
}
@@ -593,6 +598,7 @@
/**
* {@inheritDoc}
*/
+ @Override
protected void addMenus()
{
add(createViewMenuBar());
@@ -603,6 +609,7 @@
* Creates the view menu bar.
* @return the view menu bar.
*/
+ @Override
protected JMenu createViewMenuBar()
{
JMenu menu = Utilities.createMenu(
@@ -655,6 +662,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Component getListCellRendererComponent(JList list, Object value,
int index, boolean isSelected, boolean cellHasFocus)
{
diff --git a/opendj-sdk/opends/src/messages/messages/admin_tool.properties b/opendj-sdk/opends/src/messages/messages/admin_tool.properties
index 92e1ef7..8e515a9 100644
--- a/opendj-sdk/opends/src/messages/messages/admin_tool.properties
+++ b/opendj-sdk/opends/src/messages/messages/admin_tool.properties
@@ -1430,7 +1430,7 @@
INFO_CTRL_PANEL_NO_SCHEMA_ITEM_SELECTED=No Schema Item Selected
INFO_CTRL_PANEL_CATEGORY_ITEM_SELECTED=Category Item Selected
-INFO_CTRL_PANEL_MULTIPLE_ITEMS_SELECTED=Multiple Schema Items Selected
+INFO_CTRL_PANEL_MULTIPLE_SCHEMA_ITEMS_SELECTED=Multiple Schema Items Selected
MILD_ERR_CANNOT_DELETE_PARENT_OBJECTCLASS=ObjectClass '%s' is superior of the \
following classes: %s. You must redefine these classes so that they do not \
@@ -2327,8 +2327,7 @@
INFO_CTRL_PANEL_CATEGORY_MONITORING=Monitoring
INFO_CTRL_PANEL_BROWSE_GENERAL_MONITORING=General Information
-INFO_CTRL_PANEL_GENERAL_MONITORING_NO_ITEM_SELECTED=-No Item Selected-
-INFO_CTRL_PANEL_MULTIPLE_ITEMS_SELECTED=-Multiple Items Selected-
+INFO_CTRL_PANEL_GENERAL_MONITORING_NO_ITEM_SELECTED=- No Item Selected -
INFO_CTRL_PANEL_GENERAL_MONITORING_TITLE=General Information
INFO_CTRL_PANEL_AUTH_REQUIRED_TO_BROWSE_MONITORING_SUMMARY=The server is \
running. You must provide authentication to see the monitoring data.
@@ -2425,7 +2424,5 @@
for the Connection Handler Monitoring
INFO_CTRL_PANEL_SHOW_AVERAGES=Show Averages
INFO_CTRL_PANEL_CONNECTION_HANDLER_HEADER=Connection Handler
-INFO_CTRL_PANEL_ADMINISTRATION_CONNECTOR_NAME=%d - Administration \
- Connector
INFO_CTRL_PANEL_CONNECTION_HANDLER_MONITORING=Connection Handler
INFO_CTRL_PANEL_AVERAGE_HEADER=%s Avg per second
diff --git a/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/messages/PropertiesFilesTest.java b/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/messages/PropertiesFilesTest.java
index 4bbf330..cc88400 100644
--- a/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/messages/PropertiesFilesTest.java
+++ b/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/messages/PropertiesFilesTest.java
@@ -22,12 +22,14 @@
* CDDL HEADER END
*
*
- * Copyright 2008 Sun Microsystems, Inc.
+ * Copyright 2008-2009 Sun Microsystems, Inc.
*/
package org.opends.messages;
import org.opends.server.TestCaseUtils;
+import org.opends.server.util.StaticUtils;
+
import static org.testng.Assert.*;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
@@ -37,6 +39,8 @@
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
+import java.util.LinkedList;
+import java.util.List;
import java.util.Set;
import java.util.HashSet;
@@ -46,6 +50,10 @@
*/
public class PropertiesFilesTest extends MessagesTestCase {
+ /**
+ * Creates date for testForDuplicateKeys.
+ * @return The test data.
+ */
@DataProvider(name = "messagePropertiesFiles")
public Object[][] getMessagePropertiesFiles() {
File propFilesDir = getPropertiesFilesDirectory();
@@ -73,24 +81,40 @@
* @throws IOException if problems reading the file
*/
@Test(dataProvider = "messagePropertiesFiles")
- public void testForDuplicateKeys(File propertiesFile) throws IOException {
+ public void testForDuplicateKeys(File propertiesFile)
+ throws IOException
+ {
Set<String> keys = new HashSet<String>();
- BufferedReader reader = new BufferedReader(new FileReader(propertiesFile));
+ BufferedReader reader =
+ new BufferedReader(new FileReader(propertiesFile));
+ List<String> errors = new LinkedList<String>();
+
String prevLine = null;
String line;
- while (null != (line = reader.readLine())) {
- if (!(prevLine == null || prevLine.endsWith("\\")) && // not a value continuation
- !(line.startsWith("#")) && // not a comment
- (line.indexOf('=') > 0)) { // defines a key
+ while (null != (line = reader.readLine()))
+ {
+ if (!(prevLine == null || prevLine.endsWith("\\")) // not a value continuation
+ && !(line.startsWith("#")) // not a comment
+ && (line.indexOf('=') > 0))
+ {
+ // defines a key
String key = line.substring(0, line.indexOf('='));
- assertFalse(keys.contains(key),
- "Key " + key + " is defined multiple places in " +
- propertiesFile.getName());
- keys.add(key);
+ if (keys.contains(key))
+ {
+ errors.add(key);
+ }
+ else
+ {
+ keys.add(key);
+ }
}
prevLine = line;
}
+ assertTrue(errors.isEmpty(),
+ "The following keys are defined multiple times in "
+ + propertiesFile.getName() + ":" + EOL
+ + StaticUtils.listToString(errors, EOL));
}
private File getPropertiesFilesDirectory() {
--
Gitblit v1.10.0