kriegaex commented on code in PR #133:
URL: https://github.com/apache/xalan-java/pull/133#discussion_r1412364822


##########
xalan/src/test/java/org/apache/xalan/VersionTest.java:
##########
@@ -0,0 +1,100 @@
+/*
+ * 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.xalan;
+
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.Arguments;
+import org.junit.jupiter.params.provider.MethodSource;
+import org.mockito.MockedStatic;
+import org.mockito.Mockito;
+
+import java.io.ByteArrayInputStream;
+import java.util.stream.Stream;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+public class VersionTest {
+
+  @ParameterizedTest(name = "{0} -> {2}")
+  @MethodSource("testReadPropertiesArgs")
+  public void testReadProperties(String ignoredName, String properties, String 
version) {
+    try (MockedStatic<Version> versionMock = Mockito.mockStatic(Version.class, 
Mockito.CALLS_REAL_METHODS)) {
+      versionMock
+        .when(Version::getPropertiesStream)
+        .thenReturn(new ByteArrayInputStream(properties.getBytes()));
+      assertEquals(version, Version.readVersionNumber());
+    }
+  }
+
+  private static Stream<Arguments> testReadPropertiesArgs() {
+    return Stream.of(
+      Arguments.of("single line without line feed", "version=1.2.3", "1.2.3"),
+      Arguments.of("single line with line feed", "version=4.5.D6-SNAPSHOT\n", 
"4.5.D6-SNAPSHOT"),
+      Arguments.of("multiple lines with version number", 
"foo=bar\nversion=7.8.9\nbaz=zot\n", "7.8.9"),
+      Arguments.of("single line without version number", "verXion=7.8.9\n", 
"0.0.0"),
+      Arguments.of("multiple lines without version number", 
"foo=bar\nverXion=7.8.9\nbaz=zot\n", "0.0.0")
+    );
+  }
+
+  @Test
+  public void testCannotReadProperties() {
+    try (MockedStatic<Version> versionMock = Mockito.mockStatic(Version.class, 
Mockito.CALLS_REAL_METHODS)) {
+      versionMock
+        .when(Version::getPropertiesStream)
+        .thenThrow(NullPointerException.class);
+      assertEquals("0.0.0", Version.readVersionNumber());

Review Comment:
   > We're getting into a bad pattern of trying to design in reviews. (I've 
been guilty of it too.)
   > 
   > May I suggest that we keep review focused on "is it an improvement" and 
"is there any reason _not_ to commit", and move extended discussion back to the 
dev list?
   
   Yes, **pleeease!**
   
   Joe, do you remember my post on the mailing list about dysfunctional, 
micro-managing code reviews in OSS projects? This is exactly what I was talking 
about. Yet another OSS project I started volunteering to donate code to, and 
again I need to spend (waste, actually) 90% of my time defending bug-free code 
and good tests. Again, I am solving problems and people find problems in every 
solution I propose. This is the main reason why OSS project are 
resource-starved: Nobody wants to go through processes like this. It is not 
that nobody wants to contribute. It is that the reviews spoil the experience 
and taint the little bit of pride people take in doing something positive for 
free.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscr...@xalan.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@xalan.apache.org
For additional commands, e-mail: dev-h...@xalan.apache.org

Reply via email to