Skip to content

added XML parsing test#2293

Merged
rrayst merged 4 commits into
masterfrom
xml-parsing-test
Nov 11, 2025
Merged

added XML parsing test#2293
rrayst merged 4 commits into
masterfrom
xml-parsing-test

Conversation

@rrayst
Copy link
Copy Markdown
Member

@rrayst rrayst commented Nov 10, 2025

Summary by CodeRabbit

  • Tests

    • Added unit tests for XML parsing, element nesting and child-element handling
    • Enhanced annotation-processor test scenarios and resource mappings
  • Chores

    • Overhauled in-memory compilation and test utilities, including overlay class/resource handling
    • Added composite class-loading and in-memory resource support to improve test isolation and diagnostics

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Nov 10, 2025

Warning

Rate limit exceeded

@rrayst has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 14 minutes and 17 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between b61b849 and 9647059.

📒 Files selected for processing (2)
  • annot/src/test/java/com/predic8/membrane/annot/util/InMemoryURLStreamHandler.java (1 hunks)
  • annot/src/test/java/com/predic8/membrane/annot/util/LoggingInMemoryJavaFileManager.java (1 hunks)

Walkthrough

Adds parsing tests and refactors test compilation infrastructure: replaces the old CustomJavaFileManager with a logging in-memory manager, introduces multiple in-memory file/classloader utilities, changes CompilerHelper/CompilerResult APIs, and adds new test classes and supporting utilities for overlayed in-memory resources.

Changes

Cohort / File(s) Change Summary
Parsing tests
annot/src/test/java/com/predic8/membrane/annot/ParsingTest.java
New test class ParsingTest with simple() and childElements() methods to compile and parse Spring-wrapped XML using MCElement-decorated sources.
Minor test edits
annot/src/test/java/com/predic8/membrane/annot/SpringConfigXSDErrorsTest.java, annot/src/test/java/com/predic8/membrane/annot/SpringConfigurationXSDGeneratingAnnotationProcessorTest.java
Replaced explicit List<JavaFileObject> with var; added Spring resource mappings (META-INF/spring.handlers, META-INF/spring.schemas) to test fixture string.
Compiler helper & API
annot/src/test/java/com/predic8/membrane/annot/util/CompilerHelper.java
Refactored compile(...) to accept Iterable<? extends FileObject>; added parse(CompilerResult, String); changed splitSources() to return List<FileObject>; added helpers for java sources/resources extraction and resource copying; switched to LoggingInMemoryJavaFileManager and OverlayInMemoryJavaFile for sources.
Compiler result
annot/src/test/java/com/predic8/membrane/annot/util/CompilerResult.java
CompilerResult record now includes an additional ClassLoader classLoader field (constructor/signature updated).
Removed manager
annot/src/test/java/com/predic8/membrane/annot/util/CustomJavaFileManager.java
Deleted the previous CustomJavaFileManager and its inner in-memory/logging implementations.
In-memory data & file objects
annot/src/test/java/com/predic8/membrane/annot/util/InMemoryData.java, .../InMemoryFileObject.java, .../InMemoryJavaFileObject.java, .../InnerFileObject.java, .../OverlayInMemoryFile.java, .../OverlayInMemoryJavaFile.java
Added InMemoryData map and multiple FileObject implementations (in-memory and overlay variants) plus InnerFileObject for backing storage and UTF‑8 I/O.
Logging wrappers
annot/src/test/java/com/predic8/membrane/annot/util/LoggingFileObject.java, .../LoggingJavaFileObject.java
New wrappers that log FileObject/JavaFileObject operations and delegate to inner objects.
JavaFileManager
annot/src/test/java/com/predic8/membrane/annot/util/LoggingInMemoryJavaFileManager.java
New JavaFileManager implementation that can route IO to in-memory overlays, registers URL handler, and logs operations.
Classloader & resource utilities
annot/src/test/java/com/predic8/membrane/annot/util/InMemoryClassLoader.java, .../CompositeClassLoader.java, .../InMemoryURLStreamHandler.java, .../ConcatenatingEnumeration.java
Added InMemoryClassLoader (overlay-aware, child-first), CompositeClassLoader (delegates to two loaders), InMemoryURLStreamHandler (serve resources from InMemoryData), and ConcatenatingEnumeration to merge enumerations.

Sequence Diagram(s)

sequenceDiagram
    participant Test
    participant CompilerHelper
    participant JavaCompiler
    participant LoggingInMemoryJavaFileManager
    participant InMemoryClassLoader
    participant Parser

    Test->>CompilerHelper: compile(sourceFiles, logOutput)
    CompilerHelper->>LoggingInMemoryJavaFileManager: prepare (javaSources + resources)
    CompilerHelper->>JavaCompiler: run compilation task with LoggingInMemoryJavaFileManager
    JavaCompiler-->>CompilerHelper: CompilerResult(compilationSuccess, diagnostics, classLoader)
    Test->>CompilerHelper: parse(CompilerResult, xmlSpringConfig)
    CompilerHelper->>Parser: parse using CompositeClassLoader(InMemoryClassLoader, result.classLoader)
    Parser->>InMemoryClassLoader: loadClass / getResource (overlay first)
    Parser-->>Test: parsed Spring configuration
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60–90 minutes

  • Review focus areas:
    • CompilerHelper API changes and resource/source handling (getJavaSources, copyResourcesToOutput).
    • Correct construction and lifecycle of class loaders returned in CompilerResult.
    • Interaction and precedence between InMemoryData, InMemoryURLStreamHandler, InMemoryClassLoader, and LoggingInMemoryJavaFileManager.
    • Ensure removal of CustomJavaFileManager does not break other tests relying on its semantics.

Possibly related PRs

Poem

🐇 I stitched some bytes in memory bright,

classes hum and resources light.
Loaders dance, overlays play,
Spring XML wakes without delay.
A rabbit cheers — tests compile today!

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 1.68% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'added XML parsing test' accurately describes the main change: a new ParsingTest class with XML parsing test cases for Spring configuration handling.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@rrayst
Copy link
Copy Markdown
Member Author

rrayst commented Nov 10, 2025

/ok-to-test

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🧹 Nitpick comments (1)
annot/src/test/java/com/predic8/membrane/annot/SpringConfigXSDErrorsTest.java (1)

20-21: Remove unused imports.

The imports for JavaFileObject and List are no longer needed after replacing explicit type declarations with var for local variables. Clean up the imports.

-import javax.tools.JavaFileObject;
-import java.util.List;
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 36ee04b and c9ddcfe.

📒 Files selected for processing (19)
  • annot/src/test/java/com/predic8/membrane/annot/ParsingTest.java (1 hunks)
  • annot/src/test/java/com/predic8/membrane/annot/SpringConfigXSDErrorsTest.java (17 hunks)
  • annot/src/test/java/com/predic8/membrane/annot/SpringConfigurationXSDGeneratingAnnotationProcessorTest.java (2 hunks)
  • annot/src/test/java/com/predic8/membrane/annot/util/CompilerHelper.java (1 hunks)
  • annot/src/test/java/com/predic8/membrane/annot/util/CompilerResult.java (1 hunks)
  • annot/src/test/java/com/predic8/membrane/annot/util/CompositeClassLoader.java (1 hunks)
  • annot/src/test/java/com/predic8/membrane/annot/util/ConcatenatingEnumeration.java (1 hunks)
  • annot/src/test/java/com/predic8/membrane/annot/util/CustomJavaFileManager.java (0 hunks)
  • annot/src/test/java/com/predic8/membrane/annot/util/InMemoryClassLoader.java (1 hunks)
  • annot/src/test/java/com/predic8/membrane/annot/util/InMemoryData.java (1 hunks)
  • annot/src/test/java/com/predic8/membrane/annot/util/InMemoryFileObject.java (1 hunks)
  • annot/src/test/java/com/predic8/membrane/annot/util/InMemoryJavaFileObject.java (1 hunks)
  • annot/src/test/java/com/predic8/membrane/annot/util/InMemoryURLStreamHandler.java (1 hunks)
  • annot/src/test/java/com/predic8/membrane/annot/util/InnerFileObject.java (1 hunks)
  • annot/src/test/java/com/predic8/membrane/annot/util/LoggingFileObject.java (1 hunks)
  • annot/src/test/java/com/predic8/membrane/annot/util/LoggingInMemoryJavaFileManager.java (1 hunks)
  • annot/src/test/java/com/predic8/membrane/annot/util/LoggingJavaFileObject.java (1 hunks)
  • annot/src/test/java/com/predic8/membrane/annot/util/OverlayInMemoryFile.java (1 hunks)
  • annot/src/test/java/com/predic8/membrane/annot/util/OverlayInMemoryJavaFile.java (1 hunks)
💤 Files with no reviewable changes (1)
  • annot/src/test/java/com/predic8/membrane/annot/util/CustomJavaFileManager.java
🧰 Additional context used
🧬 Code graph analysis (3)
annot/src/test/java/com/predic8/membrane/annot/ParsingTest.java (2)
annot/src/test/java/com/predic8/membrane/annot/util/CompilerHelper.java (1)
  • CompilerHelper (35-198)
annot/src/test/java/com/predic8/membrane/annot/SpringConfigurationXSDGeneratingAnnotationProcessorTest.java (1)
  • SpringConfigurationXSDGeneratingAnnotationProcessorTest (23-66)
annot/src/test/java/com/predic8/membrane/annot/util/InMemoryClassLoader.java (1)
annot/src/test/java/com/predic8/membrane/annot/util/InMemoryURLStreamHandler.java (1)
  • InMemoryURLStreamHandler (14-53)
annot/src/test/java/com/predic8/membrane/annot/util/LoggingInMemoryJavaFileManager.java (1)
annot/src/test/java/com/predic8/membrane/annot/util/InMemoryURLStreamHandler.java (1)
  • InMemoryURLStreamHandler (14-53)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Automated tests
  • GitHub Check: Analyze (java)
🔇 Additional comments (2)
annot/src/test/java/com/predic8/membrane/annot/SpringConfigXSDErrorsTest.java (1)

30-30: Consistent and appropriate use of var for local variable type inference.

The refactoring from explicit List<JavaFileObject> and CompilerResult types to var is clean and follows modern Java best practices. The inferred types are unambiguous from the method return types, making the code more readable without sacrificing clarity.

Also applies to: 50-50, 66-66, 77-77, 100-100, 126-126, 142-142, 158-158, 174-174, 196-196, 215-215, 236-236, 258-258, 283-283, 298-298, 318-318, 341-341

annot/src/test/java/com/predic8/membrane/annot/ParsingTest.java (1)

44-78: Great coverage for nested child elements. The new childElements case thoroughly exercises the generated schema’s ability to handle polymorphic children, which boosts confidence in the annotation processor’s output.

Comment thread annot/src/test/java/com/predic8/membrane/annot/util/InMemoryClassLoader.java Outdated
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

♻️ Duplicate comments (2)
annot/src/test/java/com/predic8/membrane/annot/util/LoggingInMemoryJavaFileManager.java (1)

124-139: Allow resource snippets without payloads.

The loop around Line 130 still throws when the snippet is only resource /foo (no newline content). This is the same issue flagged earlier and it still breaks otherwise valid test inputs. Please tolerate a missing body by defaulting to "" instead of raising.

Apply this diff:

-        while(true) {
-            parts = content.split("\n", 2);
-            if (parts.length != 2)
-                throw new RuntimeException("Invalid resource file: " + content + ". The resource is expected to have the format 'resource <path>\n<content>'.");
+        while (true) {
+            parts = content.split("\n", 2);
+            if (parts.length < 1)
+                throw new RuntimeException("Invalid resource file: " + content);
             if (!parts[0].isEmpty())
                 break;
             content = parts[1];
         };
 
         String name = parts[0].substring(9).trim();
-        return new OverlayInMemoryFile(name, parts[1]);
+        String body = parts.length > 1 ? parts[1] : "";
+        return new OverlayInMemoryFile(name, body);
annot/src/test/java/com/predic8/membrane/annot/util/InMemoryURLStreamHandler.java (1)

44-51: Handle missing base resources safely.

Line 50 still blindly wraps data.content.get(uri) without verifying that data exists or that the map contains the key. When absent, new ByteArrayInputStream(null) throws a NullPointerException. Mirror the overlay guard: resolve the bytes first, throw FileNotFoundException if null, then build the stream.

Apply this diff:

-                    return new ByteArrayInputStream(data.content.get(uri));
+                    byte[] buffer = data != null ? data.content.get(uri) : null;
+                    if (buffer == null)
+                        throw new FileNotFoundException("No in-memory resource for " + uri);
+                    return new ByteArrayInputStream(buffer);
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c9ddcfe and b61b849.

📒 Files selected for processing (4)
  • annot/src/test/java/com/predic8/membrane/annot/util/CompilerHelper.java (1 hunks)
  • annot/src/test/java/com/predic8/membrane/annot/util/InMemoryClassLoader.java (1 hunks)
  • annot/src/test/java/com/predic8/membrane/annot/util/InMemoryURLStreamHandler.java (1 hunks)
  • annot/src/test/java/com/predic8/membrane/annot/util/LoggingInMemoryJavaFileManager.java (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • annot/src/test/java/com/predic8/membrane/annot/util/InMemoryClassLoader.java
🧰 Additional context used
🧬 Code graph analysis (1)
annot/src/test/java/com/predic8/membrane/annot/util/LoggingInMemoryJavaFileManager.java (1)
annot/src/test/java/com/predic8/membrane/annot/util/InMemoryURLStreamHandler.java (1)
  • InMemoryURLStreamHandler (15-58)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Automated tests
  • GitHub Check: Analyze (java)

@rrayst rrayst merged commit 7271f37 into master Nov 11, 2025
5 checks passed
@rrayst rrayst deleted the xml-parsing-test branch November 11, 2025 14:35
@coderabbitai coderabbitai Bot mentioned this pull request Dec 3, 2025
@coderabbitai coderabbitai Bot mentioned this pull request Dec 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants