Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue discovered on log4j-cassandra/src/test/java/org/apache/logging/log4j/cassandra/CassandraAppenderIT.java with Change type #447

Open
knutwannheden opened this issue Dec 28, 2023 · 1 comment
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@knutwannheden
Copy link
Contributor

Problem

Error:

@Category(Appenders.Cassandra.class)
public class CassandraAppenderIT {
  @BeforeAll
  public static void disbaleOnAarch64() {
      Assumptions.assumeFalse(SystemUtils.OS_ARCH.equalsIgnoreCase("aarch64"));
  }
  private static final String DDL = "CREATE TABLE logs (" + "id timeuuid PRIMARY KEY,"
@ -100,4 +100,4 @@
      }
      assertEquals(20, i);
  }
}

Message:

class org.openrewrite.java.tree.J$FieldAccess cannot be cast to class org.openrewrite.java.tree.J$Identifier (org.openrewrite.java.tree.J$FieldAccess and org.openrewrite.java.tree.J$Identifier are in unnamed module of loader 'app')

Detail:

java.lang.ClassCastException: class org.openrewrite.java.tree.J$FieldAccess cannot be cast to class org.openrewrite.java.tree.J$Identifier (org.openrewrite.java.tree.J$FieldAccess and org.openrewrite.java.tree.J$Identifier are in unnamed module of loader 'app')
org.openrewrite.java.testing.junit5.CategoryToTag$CategoryToTagVisitor.lambda$categoryAnnotationToTagAnnotations$0(CategoryToTag.java:106)
java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
java.base/java.util.stream.Streams$StreamBuilderImpl.forEachRemaining(Streams.java:411)
java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150)
java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173)
java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
...

Expected behavior

Describe what you expected to see.

Example diff

From: log4j-cassandra/src/test/java/org/apache/logging/log4j/cassandra/CassandraAppenderIT.java

   */
package org.apache.logging.log4j.cassandra;

-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;

import com.datastax.driver.core.Row;
import com.datastax.driver.core.Session;
  import org.apache.logging.log4j.ThreadContext;
import org.apache.logging.log4j.core.test.categories.Appenders;
import org.apache.logging.log4j.core.test.junit.LoggerContextRule;
-import org.junit.Assume;
-import org.junit.BeforeClass;
import org.junit.ClassRule;
-import org.junit.Test;
import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.Assumptions;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
import org.junit.rules.RuleChain;

/**
* Integration test for CassandraAppender.
*/
-@Category(Appenders.Cassandra.class)
+{{80000000-0003-7833-0000-000000000000}}@Category(Appenders.Cassandra.class)
public class CassandraAppenderIT {

-    @BeforeClass
+    @BeforeAll
public static void disbaleOnAarch64() {
-        Assume.assumeFalse(SystemUtils.OS_ARCH.equalsIgnoreCase("aarch64"));
+        Assumptions.assumeFalse(SystemUtils.OS_ARCH.equalsIgnoreCase("aarch64"));
}

private static final String DDL = "CREATE TABLE logs (" + "id timeuuid PRIMARY KEY,"
      }
assertEquals(20, i);
}
-}
+}{{80000000-0003-7833-0000-000000000000}}

Recipes in example diff:

  • org.openrewrite.java.ChangeType
  • org.openrewrite.java.testing.junit5.AssertToAssertions
  • org.openrewrite.java.testing.junit5.CategoryToTag
  • org.openrewrite.java.testing.junit5.UpdateBeforeAfterAnnotations
  • org.openrewrite.java.testing.junit5.UpdateTestAnnotation

References:

  • View original result
  • Recipe ID: org.openrewrite.java.ChangeType
  • Recipe Name: Change type
  • Repository: apache/logging-log4j2/2.x
  • Created at Thu Dec 28 2023 22:47:58 GMT+0100 (Central European Standard Time)
@knutwannheden knutwannheden added the bug Something isn't working label Dec 28, 2023
@knutwannheden knutwannheden transferred this issue from openrewrite/rewrite Dec 28, 2023
@knutwannheden
Copy link
Contributor Author

knutwannheden commented Dec 28, 2023

Looks like CategoryToTag has issues with qualified names as in @Category(Appenders.Cassandra.class).

@knutwannheden knutwannheden added the good first issue Good for newcomers label Dec 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
Status: Backlog
Development

No branches or pull requests

1 participant