You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lo...@apache.org on 2016/02/17 23:51:59 UTC
svn commit: r1730964 - in
/myfaces/tobago/branches/tobago-3.0.x/tobago-core/src:
main/java/org/apache/myfaces/tobago/internal/util/
test/java/org/apache/myfaces/tobago/component/
test/java/org/apache/myfaces/tobago/layout/
Author: lofwyr
Date: Wed Feb 17 22:51:58 2016
New Revision: 1730964
URL: http://svn.apache.org/viewvc?rev=1730964&view=rev
Log:
TOBAGO-1501: Refactoring: using further enums
Added:
myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/test/java/org/apache/myfaces/tobago/layout/AlignItemsUnitTest.java
Modified:
myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/util/StringUtils.java
myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/test/java/org/apache/myfaces/tobago/component/RendererTypesUnitTest.java
Modified: myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/util/StringUtils.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/util/StringUtils.java?rev=1730964&r1=1730963&r2=1730964&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/util/StringUtils.java (original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/util/StringUtils.java Wed Feb 17 22:51:58 2016
@@ -90,7 +90,15 @@ public final class StringUtils {
return indices;
}
- public static String constantToCamelCase(final String constant) {
+ public static String constantToLowerCamelCase(final String constant) {
+ final StringBuilder builder = new StringBuilder(constantToUpperCamelCase(constant));
+ if (builder.length() > 0) {
+ builder.setCharAt(0, Character.toLowerCase(builder.charAt(0)));
+ }
+ return builder.toString();
+ }
+
+ public static String constantToUpperCamelCase(final String constant) {
final StringBuilder builder = new StringBuilder(constant.length());
final char[] chars = constant.toCharArray();
for (int i = 0; i < chars.length; i++) {
Modified: myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/test/java/org/apache/myfaces/tobago/component/RendererTypesUnitTest.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/test/java/org/apache/myfaces/tobago/component/RendererTypesUnitTest.java?rev=1730964&r1=1730963&r2=1730964&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/test/java/org/apache/myfaces/tobago/component/RendererTypesUnitTest.java (original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/test/java/org/apache/myfaces/tobago/component/RendererTypesUnitTest.java Wed Feb 17 22:51:58 2016
@@ -20,31 +20,24 @@
package org.apache.myfaces.tobago.component;
import org.apache.myfaces.tobago.internal.util.StringUtils;
-import org.junit.Assert;
+import org.apache.myfaces.tobago.util.EnumUnitTest;
import org.junit.Test;
-import java.lang.reflect.Field;
-
-public class RendererTypesUnitTest {
+public class RendererTypesUnitTest extends EnumUnitTest {
@Test
- public void testNames() throws IllegalAccessException {
-
+ public void testNames() throws IllegalAccessException, NoSuchFieldException {
- final Field[] fields = RendererTypes.class.getFields();
- final RendererTypes[] values = RendererTypes.values();
+ testNames(RendererTypes.class);
+ }
- Assert.assertEquals("count", fields.length, 2 * values.length);
+ @Override
+ protected String getEnumRegexp() {
+ return "[A-Z][a-zA-Z]*";
+ }
- for (final Field field : fields) {
- final Object object = field.get(null);
- if (object instanceof String) {
- final String value = (String) object;
- Assert.assertTrue("value='" + value + "'", value.matches("[A-Z][a-zA-Z]*"));
- final String expected = StringUtils.constantToCamelCase(field.getName());
- Assert.assertEquals(expected, value);
- Assert.assertNotNull("exists", RendererTypes.valueOf(value));
- }
- }
+ @Override
+ protected String constantCaseToEnum(String constant) {
+ return StringUtils.constantToUpperCamelCase(constant);
}
}
Added: myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/test/java/org/apache/myfaces/tobago/layout/AlignItemsUnitTest.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/test/java/org/apache/myfaces/tobago/layout/AlignItemsUnitTest.java?rev=1730964&view=auto
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/test/java/org/apache/myfaces/tobago/layout/AlignItemsUnitTest.java (added)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/test/java/org/apache/myfaces/tobago/layout/AlignItemsUnitTest.java Wed Feb 17 22:51:58 2016
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+
+package org.apache.myfaces.tobago.layout;
+
+import org.apache.myfaces.tobago.util.EnumUnitTest;
+import org.junit.Test;
+
+public class AlignItemsUnitTest extends EnumUnitTest {
+
+ @Test
+ public void testNames() throws IllegalAccessException, NoSuchFieldException {
+ testNames(AlignItems.class);
+ }
+
+}