hivemind-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hls...@apache.org
Subject svn commit: r355540 - in /jakarta/hivemind/branches/maven2-dec12-2005: ./ framework/src/main/java/org/apache/hivemind/impl/ framework/src/test/java/ framework/src/test/java/org/apache/hivemind/impl/ framework/src/test/resources/
Date Fri, 09 Dec 2005 17:05:11 GMT
Author: hlship
Date: Fri Dec  9 09:05:02 2005
New Revision: 355540

URL: http://svn.apache.org/viewcvs?rev=355540&view=rev
Log:
Simplify the TestMessageFormatter test case

Added:
    jakarta/hivemind/branches/maven2-dec12-2005/framework/src/test/java/DefaultPackageMessages.java
    jakarta/hivemind/branches/maven2-dec12-2005/framework/src/test/resources/DefaultPackageStrings.properties
Modified:
    jakarta/hivemind/branches/maven2-dec12-2005/.classpath
    jakarta/hivemind/branches/maven2-dec12-2005/framework/src/main/java/org/apache/hivemind/impl/MessageFormatter.java
    jakarta/hivemind/branches/maven2-dec12-2005/framework/src/test/java/org/apache/hivemind/impl/TestMessageFormatter.java
    jakarta/hivemind/branches/maven2-dec12-2005/framework/src/test/java/org/apache/hivemind/impl/TestRegistryInfrastructure.java

Modified: jakarta/hivemind/branches/maven2-dec12-2005/.classpath
URL: http://svn.apache.org/viewcvs/jakarta/hivemind/branches/maven2-dec12-2005/.classpath?rev=355540&r1=355539&r2=355540&view=diff
==============================================================================
--- jakarta/hivemind/branches/maven2-dec12-2005/.classpath (original)
+++ jakarta/hivemind/branches/maven2-dec12-2005/.classpath Fri Dec  9 09:05:02 2005
@@ -1,6 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <classpath>
-	<classpathentry kind="src" path="framework/src/java"/>
 	<classpathentry kind="src" path="framework/src/test/java"/>
 	<classpathentry kind="src" path="framework/src/main/java"/>
 	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>

Modified: jakarta/hivemind/branches/maven2-dec12-2005/framework/src/main/java/org/apache/hivemind/impl/MessageFormatter.java
URL: http://svn.apache.org/viewcvs/jakarta/hivemind/branches/maven2-dec12-2005/framework/src/main/java/org/apache/hivemind/impl/MessageFormatter.java?rev=355540&r1=355539&r2=355540&view=diff
==============================================================================
--- jakarta/hivemind/branches/maven2-dec12-2005/framework/src/main/java/org/apache/hivemind/impl/MessageFormatter.java
(original)
+++ jakarta/hivemind/branches/maven2-dec12-2005/framework/src/main/java/org/apache/hivemind/impl/MessageFormatter.java
Fri Dec  9 09:05:02 2005
@@ -98,19 +98,11 @@
 
     private static String getResourceBundleName(Class referenceClass, String name)
     {
-        String packageName = null;
-        if (referenceClass.getPackage() != null)
-        {
-            packageName = referenceClass.getPackage().getName();
-        }
-        else
-        {
-            final int lastDotIndex = referenceClass.getName().lastIndexOf('.');
-            packageName = (lastDotIndex == -1 ? "" : referenceClass.getName().substring(
-                    0,
-                    lastDotIndex));
+        int lastDotIndex = referenceClass.getName().lastIndexOf('.');
 
-        }
-        return packageName.equals("") ? name : packageName + "." + name;
+        if (lastDotIndex < 0)
+            return name;
+
+        return referenceClass.getName().substring(0, lastDotIndex) + "." + name;
     }
 }

Added: jakarta/hivemind/branches/maven2-dec12-2005/framework/src/test/java/DefaultPackageMessages.java
URL: http://svn.apache.org/viewcvs/jakarta/hivemind/branches/maven2-dec12-2005/framework/src/test/java/DefaultPackageMessages.java?rev=355540&view=auto
==============================================================================
--- jakarta/hivemind/branches/maven2-dec12-2005/framework/src/test/java/DefaultPackageMessages.java
(added)
+++ jakarta/hivemind/branches/maven2-dec12-2005/framework/src/test/java/DefaultPackageMessages.java
Fri Dec  9 09:05:02 2005
@@ -0,0 +1,32 @@
+// Copyright 2005 The Apache Software Foundation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+import org.apache.hivemind.Messages;
+import org.apache.hivemind.impl.MessageFormatter;
+
+/**
+ * Used to test the case where a class is in the default package.
+ * 
+ * @author Howard M. Lewis Ship
+ * @since 1.2
+ */
+public class DefaultPackageMessages
+{
+    private static final Messages _messages = new MessageFormatter(DefaultPackageMessages.class);
+
+    public static String success()
+    {
+        return _messages.getMessage("success");
+    }
+}

Modified: jakarta/hivemind/branches/maven2-dec12-2005/framework/src/test/java/org/apache/hivemind/impl/TestMessageFormatter.java
URL: http://svn.apache.org/viewcvs/jakarta/hivemind/branches/maven2-dec12-2005/framework/src/test/java/org/apache/hivemind/impl/TestMessageFormatter.java?rev=355540&r1=355539&r2=355540&view=diff
==============================================================================
--- jakarta/hivemind/branches/maven2-dec12-2005/framework/src/test/java/org/apache/hivemind/impl/TestMessageFormatter.java
(original)
+++ jakarta/hivemind/branches/maven2-dec12-2005/framework/src/test/java/org/apache/hivemind/impl/TestMessageFormatter.java
Fri Dec  9 09:05:02 2005
@@ -14,49 +14,21 @@
 
 package org.apache.hivemind.impl;
 
-import java.net.URL;
-import java.net.URLClassLoader;
+import DefaultPackageMessages;
 
 import org.apache.hivemind.test.HiveMindTestCase;
 
 /**
- * @author James Carman
+ * Most of the testing for MessageFormatter is implicit or indirect; this test case covers
some
+ * situations not used by HiveMind code proper.
+ * 
+ * @author James Carman, Howard Lewis Ship
  * @version 1.0
  */
 public class TestMessageFormatter extends HiveMindTestCase
 {
-    public void testWithNoPackage() throws Exception
+    public void testMessagesInDefaultPackage()
     {
-        final ClassLoader loader = new NoPackageClassLoader();
-
-        new MessageFormatter(loader.loadClass(TestMessageFormatter.class
-                .getName()), "MessageFinder");
-    }
-
-    private class NoPackageClassLoader extends URLClassLoader
-    {
-
-        public NoPackageClassLoader()
-        {
-            super( new URL[] { TestMessageFormatter.class.getProtectionDomain().getCodeSource().getLocation()
} );
-        }
-
-        protected Package getPackage(String name)
-        {
-            return null;
-        }
-        public Class loadClass(String name) throws ClassNotFoundException
-        {
-            try
-            {
-                return findClass( name );
-            }
-            catch( ClassNotFoundException e )
-            {
-                return super.loadClass(name);
-            }
-            
-
-        }
+        assertEquals("Success!", DefaultPackageMessages.success());
     }
 }

Modified: jakarta/hivemind/branches/maven2-dec12-2005/framework/src/test/java/org/apache/hivemind/impl/TestRegistryInfrastructure.java
URL: http://svn.apache.org/viewcvs/jakarta/hivemind/branches/maven2-dec12-2005/framework/src/test/java/org/apache/hivemind/impl/TestRegistryInfrastructure.java?rev=355540&r1=355539&r2=355540&view=diff
==============================================================================
--- jakarta/hivemind/branches/maven2-dec12-2005/framework/src/test/java/org/apache/hivemind/impl/TestRegistryInfrastructure.java
(original)
+++ jakarta/hivemind/branches/maven2-dec12-2005/framework/src/test/java/org/apache/hivemind/impl/TestRegistryInfrastructure.java
Fri Dec  9 09:05:02 2005
@@ -11,6 +11,7 @@
 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 // See the License for the specific language governing permissions and
 // limitations under the License.
+
 package org.apache.hivemind.impl;
 
 import org.apache.hivemind.ApplicationRuntimeException;

Added: jakarta/hivemind/branches/maven2-dec12-2005/framework/src/test/resources/DefaultPackageStrings.properties
URL: http://svn.apache.org/viewcvs/jakarta/hivemind/branches/maven2-dec12-2005/framework/src/test/resources/DefaultPackageStrings.properties?rev=355540&view=auto
==============================================================================
--- jakarta/hivemind/branches/maven2-dec12-2005/framework/src/test/resources/DefaultPackageStrings.properties
(added)
+++ jakarta/hivemind/branches/maven2-dec12-2005/framework/src/test/resources/DefaultPackageStrings.properties
Fri Dec  9 09:05:02 2005
@@ -0,0 +1,15 @@
+# Copyright 2005 The Apache Software Foundation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+success=Success!
\ No newline at end of file



---------------------------------------------------------------------
To unsubscribe, e-mail: hivemind-cvs-unsubscribe@jakarta.apache.org
For additional commands, e-mail: hivemind-cvs-help@jakarta.apache.org


Mime
View raw message