We have to set the inherited annotation here to force immutables to not try and use 25 | * javax.annotation.Generated which is only available in JDK-8 and older. Not sure why it is doing 26 | * this, but it looks like a bug in Immutables rather than JCT itself, since it appears to be 27 | * resolving the class somewhere. Guessing there is an issue with the usage of the --release javac 28 | * flag somewhere? 29 | */ 30 | @Value.Immutable 31 | @Value.Style(allowedClasspathAnnotations = Inherited.class) 32 | public interface Animal { 33 | 34 | String name(); 35 | 36 | int legCount(); 37 | 38 | int age(); 39 | } 40 | -------------------------------------------------------------------------------- /java-compiler-testing/src/it/immutables/src/test/resources/code/jpms/module-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 - 2025, the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | module org.example { 17 | requires static org.immutables.value; 18 | requires java.base; 19 | } 20 | -------------------------------------------------------------------------------- /java-compiler-testing/src/it/immutables/src/test/resources/code/jpms/org/example/Animal.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 - 2025, the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.example; 17 | 18 | import java.lang.annotation.Inherited; 19 | import org.immutables.value.Value; 20 | 21 | /** 22 | * Interface that immutables will generate an implementation for. 23 | * 24 | *
We have to set the inherited annotation here to force immutables to not try and use
25 | * javax.annotation.Generated which is only available in JDK-8 and older. Not sure why it is doing
26 | * this, but it looks like a bug in Immutables rather than JCT itself, since it appears to be
27 | * resolving the class somewhere. Guessing there is an issue with the usage of the --release javac
28 | * flag somewhere?
29 | */
30 | @Value.Immutable
31 | @Value.Style(allowedClasspathAnnotations = Inherited.class)
32 | public interface Animal {
33 |
34 | String name();
35 |
36 | int legCount();
37 |
38 | int age();
39 | }
40 |
--------------------------------------------------------------------------------
/java-compiler-testing/src/it/immutables/src/test/resources/junit-platform.properties:
--------------------------------------------------------------------------------
1 | junit.jupiter.execution.parallel.enabled=true
2 | junit.jupiter.execution.parallel.mode.classes.default=SAME_THREAD
3 | junit.jupiter.execution.parallel.mode.default=CONCURRENT
4 |
--------------------------------------------------------------------------------
/java-compiler-testing/src/it/invoker-debug.properties:
--------------------------------------------------------------------------------
1 | invoker.mavenOpts = -Dmaven.surefire.debug="-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=localhost:5005" -Dmaven.failsafe.debug="-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=localhost:5005"
2 | invoker.quiet = false
3 | invoker.timeoutInSeconds = 0
4 |
--------------------------------------------------------------------------------
/java-compiler-testing/src/it/invoker.properties:
--------------------------------------------------------------------------------
1 | invoker.mavenOpts = ${invoker.mavenOpts}
2 | invoker.profiles = its
3 | invoker.quiet = false
4 | invoker.timeoutInSeconds = 300
5 |
--------------------------------------------------------------------------------
/java-compiler-testing/src/it/lombok/selector.bsh:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022 - 2025, the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | // Use bsh rather than groovy since groovy does not support arbitrary JVM bytecode versions.
17 | if (Runtime.version().toString().toLowerCase().contains("ea")) {
18 | System.out.println("Lombok does not support EA releases of the JDK.");
19 | return false;
20 | } else {
21 | System.out.println("Detected a GA release, proceeding");
22 | return true;
23 | }
24 |
--------------------------------------------------------------------------------
/java-compiler-testing/src/it/lombok/src/test/resources/code/flat/org/example/Animal.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022 - 2025, the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.example;
17 |
18 | import lombok.Data;
19 |
20 | /**
21 | * Animal data class.
22 | */
23 | @Data
24 | public class Animal {
25 |
26 | private final String name;
27 | private final int legCount;
28 | private final int age;
29 | }
30 |
--------------------------------------------------------------------------------
/java-compiler-testing/src/it/lombok/src/test/resources/code/jpms/module-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022 - 2025, the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | module org.example {
17 | requires java.base;
18 | requires static lombok;
19 | }
20 |
--------------------------------------------------------------------------------
/java-compiler-testing/src/it/lombok/src/test/resources/code/jpms/org/example/Animal.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022 - 2025, the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.example;
17 |
18 | import lombok.Data;
19 |
20 | /**
21 | * Animal data class.
22 | */
23 | @Data
24 | public class Animal {
25 |
26 | private final String name;
27 | private final int legCount;
28 | private final int age;
29 | }
30 |
--------------------------------------------------------------------------------
/java-compiler-testing/src/it/lombok/src/test/resources/junit-platform.properties:
--------------------------------------------------------------------------------
1 | junit.jupiter.execution.parallel.enabled=true
2 | junit.jupiter.execution.parallel.mode.classes.default=SAME_THREAD
3 | junit.jupiter.execution.parallel.mode.default=CONCURRENT
4 |
--------------------------------------------------------------------------------
/java-compiler-testing/src/it/mapstruct/src/test/resources/code/flat/org/example/Car.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022 - 2025, the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.example;
17 |
18 | /**
19 | * Basic POJO representing a car.
20 | */
21 | public class Car {
22 |
23 | private String make;
24 | private int numberOfSeats;
25 | private CarType type;
26 |
27 | public String getMake() {
28 | return make;
29 | }
30 |
31 | public int getNumberOfSeats() {
32 | return numberOfSeats;
33 | }
34 |
35 | public CarType getType() {
36 | return type;
37 | }
38 |
39 | public void setMake(String make) {
40 | this.make = make;
41 | }
42 |
43 | public void setNumberOfSeats(int numberOfSeats) {
44 | this.numberOfSeats = numberOfSeats;
45 | }
46 |
47 | public void setType(CarType type) {
48 | this.type = type;
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/java-compiler-testing/src/it/mapstruct/src/test/resources/code/flat/org/example/CarDto.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022 - 2025, the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.example;
17 |
18 | /**
19 | * Basic POJO representing a car DTO.
20 | */
21 | public class CarDto {
22 |
23 | private String make;
24 | private int seatCount;
25 | private String type;
26 |
27 | public String getMake() {
28 | return make;
29 | }
30 |
31 | public int getSeatCount() {
32 | return seatCount;
33 | }
34 |
35 | public String getType() {
36 | return type;
37 | }
38 |
39 | public void setMake(String make) {
40 | this.make = make;
41 | }
42 |
43 | public void setSeatCount(int seatCount) {
44 | this.seatCount = seatCount;
45 | }
46 |
47 | public void setType(String type) {
48 | this.type = type;
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/java-compiler-testing/src/it/mapstruct/src/test/resources/code/flat/org/example/CarMapper.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022 - 2025, the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.example;
17 |
18 | import org.mapstruct.Mapper;
19 | import org.mapstruct.Mapping;
20 | import org.mapstruct.factory.Mappers;
21 |
22 | /**
23 | * Mapper for a Car to a Car DTO object.
24 | */
25 | @Mapper
26 | public interface CarMapper {
27 |
28 | CarMapper INSTANCE = Mappers.getMapper(CarMapper.class);
29 |
30 | @Mapping(source = "numberOfSeats", target = "seatCount")
31 | CarDto carToCarDto(Car car);
32 | }
33 |
--------------------------------------------------------------------------------
/java-compiler-testing/src/it/mapstruct/src/test/resources/code/flat/org/example/CarType.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022 - 2025, the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.example;
17 |
18 | /**
19 | * Basic enum representing types of cars.
20 | */
21 | public enum CarType {
22 | SEDAN,
23 | HATCHBACK,
24 | SUV,
25 | CONVERTABLE,
26 | COUPE,
27 | MINIVAN,
28 | SPORTS,
29 | ATV,
30 | CLOWN,
31 | }
32 |
--------------------------------------------------------------------------------
/java-compiler-testing/src/it/mapstruct/src/test/resources/code/jpms/module-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022 - 2025, the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | module org.example {
17 | requires static org.mapstruct;
18 | requires java.base;
19 | }
20 |
--------------------------------------------------------------------------------
/java-compiler-testing/src/it/mapstruct/src/test/resources/code/jpms/org/example/Car.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022 - 2025, the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.example;
17 |
18 | /**
19 | * Basic POJO representing a car.
20 | */
21 | public class Car {
22 |
23 | private String make;
24 | private int numberOfSeats;
25 | private CarType type;
26 |
27 | public String getMake() {
28 | return make;
29 | }
30 |
31 | public int getNumberOfSeats() {
32 | return numberOfSeats;
33 | }
34 |
35 | public CarType getType() {
36 | return type;
37 | }
38 |
39 | public void setMake(String make) {
40 | this.make = make;
41 | }
42 |
43 | public void setNumberOfSeats(int numberOfSeats) {
44 | this.numberOfSeats = numberOfSeats;
45 | }
46 |
47 | public void setType(CarType type) {
48 | this.type = type;
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/java-compiler-testing/src/it/mapstruct/src/test/resources/code/jpms/org/example/CarDto.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022 - 2025, the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.example;
17 |
18 | /**
19 | * Basic POJO representing a car DTO.
20 | */
21 | public class CarDto {
22 |
23 | private String make;
24 | private int seatCount;
25 | private String type;
26 |
27 | public String getMake() {
28 | return make;
29 | }
30 |
31 | public int getSeatCount() {
32 | return seatCount;
33 | }
34 |
35 | public String getType() {
36 | return type;
37 | }
38 |
39 | public void setMake(String make) {
40 | this.make = make;
41 | }
42 |
43 | public void setSeatCount(int seatCount) {
44 | this.seatCount = seatCount;
45 | }
46 |
47 | public void setType(String type) {
48 | this.type = type;
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/java-compiler-testing/src/it/mapstruct/src/test/resources/code/jpms/org/example/CarMapper.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022 - 2025, the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.example;
17 |
18 | import org.mapstruct.Mapper;
19 | import org.mapstruct.Mapping;
20 | import org.mapstruct.factory.Mappers;
21 |
22 | /**
23 | * Mapper for a Car to a Car DTO object.
24 | */
25 | @Mapper
26 | public interface CarMapper {
27 |
28 | CarMapper INSTANCE = Mappers.getMapper(CarMapper.class);
29 |
30 | @Mapping(source = "numberOfSeats", target = "seatCount")
31 | CarDto carToCarDto(Car car);
32 | }
33 |
--------------------------------------------------------------------------------
/java-compiler-testing/src/it/mapstruct/src/test/resources/code/jpms/org/example/CarType.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022 - 2025, the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.example;
17 |
18 | /**
19 | * Basic enum representing types of cars.
20 | */
21 | public enum CarType {
22 | SEDAN,
23 | HATCHBACK,
24 | SUV,
25 | CONVERTABLE,
26 | COUPE,
27 | MINIVAN,
28 | SPORTS,
29 | ATV,
30 | CLOWN,
31 | }
32 |
--------------------------------------------------------------------------------
/java-compiler-testing/src/it/mapstruct/src/test/resources/junit-platform.properties:
--------------------------------------------------------------------------------
1 | junit.jupiter.execution.parallel.enabled=true
2 | junit.jupiter.execution.parallel.mode.classes.default=SAME_THREAD
3 | junit.jupiter.execution.parallel.mode.default=CONCURRENT
4 |
--------------------------------------------------------------------------------
/java-compiler-testing/src/it/micronaut/selector.bsh:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022 - 2025, the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | // Use bsh rather than groovy since groovy does not support arbitrary JVM bytecode versions.
17 | if (Runtime.version().major() < 17) {
18 | System.out.println("Micronaut does not support JVMs before Java 17");
19 | return false;
20 | } else {
21 | return true;
22 | }
23 |
--------------------------------------------------------------------------------
/java-compiler-testing/src/it/micronaut/src/test/java/io/github/ascopes/jct/acceptancetests/micronaut/MicronautConfigurer.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022 - 2025, the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.github.ascopes.jct.acceptancetests.micronaut;
17 |
18 | import io.github.ascopes.jct.compilers.JctCompiler;
19 | import io.github.ascopes.jct.compilers.JctCompilerConfigurer;
20 | import io.micronaut.annotation.processing.AggregatingTypeElementVisitorProcessor;
21 | import io.micronaut.annotation.processing.BeanDefinitionInjectProcessor;
22 | import io.micronaut.annotation.processing.ConfigurationMetadataProcessor;
23 | import io.micronaut.annotation.processing.PackageConfigurationInjectProcessor;
24 | import io.micronaut.annotation.processing.TypeElementVisitorProcessor;
25 |
26 |
27 | /**
28 | * Micronaut annotation processor configurer.
29 | *
30 | * @author Ashley Scopes
31 | */
32 | public class MicronautConfigurer implements JctCompilerConfigurer This type is a placeholder and will be replaced when AssertJ releases changes to
25 | * support assertions on classloaders.
26 | *
27 | * @author Ashley Scopes
28 | * @since 0.0.1
29 | */
30 | public final class ClassLoaderAssert extends AbstractAssert This corresponds to the {@code -proc} flag in the OpenJDK Javac implementation.
22 | *
23 | * @author Ashley Scopes
24 | * @since 0.0.1
25 | */
26 | public enum CompilationMode {
27 |
28 | /**
29 | * Run compilation and run the annotation processors, if configured.
30 | *
31 | * Prior to Java 21, this is the default if no {@code -proc} flag is provided to the compiler.
32 | *
33 | * From Java 21 and onwards, this is equivalent to passing {@code -proc:full} to the compiler.
34 | */
35 | COMPILATION_AND_ANNOTATION_PROCESSING,
36 |
37 | /**
38 | * Run compilation, but skip any annotation processing that may run.
39 | *
40 | * This corresponds to providing {@code -proc:none} in the OpenJDK Javac implementation.
41 | */
42 | COMPILATION_ONLY,
43 |
44 | /**
45 | * Skip compilation, but run any annotation processing that may be enabled.
46 | *
47 | * This corresponds to providing {@code -proc:only} in the OpenJDK Javac implementation.
48 | */
49 | ANNOTATION_PROCESSING_ONLY,
50 | }
51 |
--------------------------------------------------------------------------------
/java-compiler-testing/src/main/java/io/github/ascopes/jct/compilers/DebuggingInfo.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022 - 2025, the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.github.ascopes.jct.compilers;
17 |
18 | import java.util.Collections;
19 | import java.util.EnumSet;
20 | import java.util.Set;
21 |
22 | /**
23 | * An enum representing the various types of debugger info that can be included in compilations.
24 | *
25 | * This corresponds to the {@code -g} flag in the OpenJDK Javac implementation.
26 | *
27 | * Debugging info flags are designed to be combined using the helper methods on this class.
28 | *
29 | * @author Ashley Scopes
30 | * @since 3.0.0
31 | */
32 | public enum DebuggingInfo {
33 |
34 | /**
35 | * Include line numbers.
36 | */
37 | LINES,
38 |
39 | /**
40 | * Include local variable names.
41 | */
42 | VARS,
43 |
44 | /**
45 | * Include source code.
46 | */
47 | SOURCE;
48 |
49 | /**
50 | * Return a set of none of the debugger info flags.
51 | *
52 | * @return a set containing no debugger flags.
53 | */
54 | public static Set This primarily exists to support debugging the JCT library itself.
22 | *
23 | * @author Ashley Scopes
24 | * @since 0.0.1
25 | */
26 | public enum LoggingMode {
27 |
28 | /**
29 | * Enable basic logging.
30 | */
31 | ENABLED,
32 |
33 | /**
34 | * Enable logging and include stacktraces in the logs for each entry.
35 | */
36 | STACKTRACES,
37 |
38 | /**
39 | * Do not log anything.
40 | */
41 | DISABLED,
42 | }
43 |
--------------------------------------------------------------------------------
/java-compiler-testing/src/main/java/io/github/ascopes/jct/filemanagers/config/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022 - 2025, the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | /**
17 | * Reusable components for setting up JSR-199 file managers.
18 | */
19 | package io.github.ascopes.jct.filemanagers.config;
20 |
21 |
--------------------------------------------------------------------------------
/java-compiler-testing/src/main/java/io/github/ascopes/jct/filemanagers/impl/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022 - 2025, the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | /**
17 | * File manager implementation details.
18 | */
19 | package io.github.ascopes.jct.filemanagers.impl;
20 |
21 |
--------------------------------------------------------------------------------
/java-compiler-testing/src/main/java/io/github/ascopes/jct/filemanagers/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022 - 2025, the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | /**
17 | * APIs that integrate with the JSR-199 FileManager APIs.
18 | */
19 | package io.github.ascopes.jct.filemanagers;
20 |
--------------------------------------------------------------------------------
/java-compiler-testing/src/main/java/io/github/ascopes/jct/junit/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022 - 2025, the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | /**
17 | * Integrations with Junit Jupiter APIs.
18 | */
19 | package io.github.ascopes.jct.junit;
20 |
--------------------------------------------------------------------------------
/java-compiler-testing/src/main/java/io/github/ascopes/jct/repr/LocationRepresentation.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022 - 2025, the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.github.ascopes.jct.repr;
17 |
18 | import javax.tools.JavaFileManager.Location;
19 | import org.assertj.core.presentation.Representation;
20 | import org.jspecify.annotations.Nullable;
21 |
22 | /**
23 | * Representation for a {@link Location location}.
24 | *
25 | * @author Ashley Scopes
26 | * @since 0.0.1
27 | */
28 | public final class LocationRepresentation implements Representation {
29 |
30 | private static final LocationRepresentation INSTANCE
31 | = new LocationRepresentation();
32 |
33 | /**
34 | * Get an instance of this location representation.
35 | *
36 | * @return the instance.
37 | */
38 | public static LocationRepresentation getInstance() {
39 | return INSTANCE;
40 | }
41 |
42 | private LocationRepresentation() {
43 | // Nothing to see here, move along now.
44 | }
45 |
46 | @Override
47 | public String toStringOf(@Nullable Object object) {
48 | return object == null ? "null" : ((Location) object).getName();
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/java-compiler-testing/src/main/java/io/github/ascopes/jct/repr/StackTraceRepresentation.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022 - 2025, the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.github.ascopes.jct.repr;
17 |
18 | import java.util.List;
19 | import org.assertj.core.presentation.Representation;
20 | import org.jspecify.annotations.Nullable;
21 |
22 | /**
23 | * Representation of a {@link List list} of {@link StackTraceElement stack trace frames}.
24 | *
25 | * @author Ashley Scopes
26 | * @since 0.0.1
27 | */
28 | public final class StackTraceRepresentation implements Representation {
29 |
30 | private static final StackTraceRepresentation INSTANCE = new StackTraceRepresentation();
31 |
32 | /**
33 | * Get an instance of this stack trace representation.
34 | *
35 | * @return the instance.
36 | */
37 | public static StackTraceRepresentation getInstance() {
38 | return INSTANCE;
39 | }
40 |
41 | private StackTraceRepresentation() {
42 | // Nothing to see here, move along now!
43 | }
44 |
45 | @Override
46 | @SuppressWarnings("unchecked")
47 | public String toStringOf(@Nullable Object object) {
48 | if (object == null) {
49 | return "null";
50 | }
51 |
52 | var trace = (List extends StackTraceElement>) object;
53 | var builder = new StringBuilder("Stacktrace:");
54 | for (var frame : trace) {
55 | builder.append("\n\tat ").append(frame);
56 | }
57 | return builder.toString();
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/java-compiler-testing/src/main/java/io/github/ascopes/jct/repr/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022 - 2025, the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | /**
17 | * Representation facilities for AssertJ integration.
18 | */
19 | package io.github.ascopes.jct.repr;
20 |
--------------------------------------------------------------------------------
/java-compiler-testing/src/main/java/io/github/ascopes/jct/utils/LoomPolyfill.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022 - 2025, the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.github.ascopes.jct.utils;
17 |
18 | /**
19 | * Polyfill to enable supporting using the newer Thread APIs on newer platforms.
20 | *
21 | * This specifically targets the new APIs introduced as part of Project Loom
22 | * in Java 19.
23 | *
24 | * @author Ashley Scopes
25 | * @since 0.0.1
26 | */
27 | public final class LoomPolyfill extends UtilityClass {
28 |
29 | private LoomPolyfill() {
30 | // Static-only class.
31 | }
32 |
33 | /**
34 | * Get the thread ID.
35 | *
36 | * This ensures that the underlying system does not spoof the thread ID on JDK 19 and newer.
37 | *
38 | * @param thread the thread to use.
39 | * @return the thread ID.
40 | */
41 | public static long getThreadId(Thread thread) {
42 | // Note: this test will never get 100% coverage on one JDK, because it totally depends on the
43 | // JDK in use as to which code path runs.
44 | try {
45 | // Where possible, use the newer Loom API to fetch the thread ID.
46 | var method = Thread.class.getDeclaredMethod("threadId");
47 | return (long) method.invoke(thread);
48 | } catch (Exception ex) {
49 | // Fall back to the old API (which is the only method prior to Java 19).
50 | return thread.getId();
51 | }
52 | }
53 |
54 | /**
55 | * Get the current thread.
56 | *
57 | * @return the current thread.
58 | */
59 | public static Thread getCurrentThread() {
60 | return Thread.currentThread();
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/java-compiler-testing/src/main/java/io/github/ascopes/jct/utils/UtilityClass.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022 - 2025, the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.github.ascopes.jct.utils;
17 |
18 | /**
19 | * Abstract base for a static-only class. This base cannot be initialised.
20 | *
21 | * @author Ashley Scopes
22 | * @since 0.0.1
23 | */
24 | public abstract class UtilityClass {
25 |
26 | protected UtilityClass() {
27 | throw new UnsupportedOperationException(
28 | "this is a utility class that cannot be initialised or extended"
29 | );
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/java-compiler-testing/src/main/java/io/github/ascopes/jct/utils/VisibleForTestingOnly.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022 - 2025, the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.github.ascopes.jct.utils;
17 |
18 | import java.lang.annotation.Documented;
19 | import java.lang.annotation.ElementType;
20 | import java.lang.annotation.Retention;
21 | import java.lang.annotation.RetentionPolicy;
22 | import java.lang.annotation.Target;
23 |
24 | /**
25 | * Annotation that marks the annotated method or constructor as only being visible for testing
26 | * purposes.
27 | *
28 | * This means any API should not be using this element directly.
29 | *
30 | * @author Ashley Scopes
31 | * @since 0.0.1
32 | */
33 | @Documented
34 | @Retention(RetentionPolicy.CLASS)
35 | @Target({ElementType.CONSTRUCTOR, ElementType.METHOD})
36 | public @interface VisibleForTestingOnly {
37 | }
38 |
--------------------------------------------------------------------------------
/java-compiler-testing/src/main/java/io/github/ascopes/jct/utils/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022 - 2025, the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | /**
17 | * Internal shared utilities.
18 | *
19 | * These components are part of the internal API and should not be used by external
20 | * modules. As such, they are not covered by the semantic versioning policy and may change without
21 | * notice.
22 | */
23 | package io.github.ascopes.jct.utils;
24 |
--------------------------------------------------------------------------------
/java-compiler-testing/src/main/java/io/github/ascopes/jct/workspaces/impl/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022 - 2025, the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | /**
17 | * Internal workspace implementation details.
18 | */
19 | package io.github.ascopes.jct.workspaces.impl;
20 |
--------------------------------------------------------------------------------
/java-compiler-testing/src/main/java/io/github/ascopes/jct/workspaces/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022 - 2025, the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | /**
17 | * Workspace components to hold complex source code structures within memory.
18 | */
19 | package io.github.ascopes.jct.workspaces;
20 |
--------------------------------------------------------------------------------
/java-compiler-testing/src/main/resources/META-INF/services/java.net.spi.URLStreamHandlerProvider:
--------------------------------------------------------------------------------
1 | # For some reason this is not detected correctly if we use the JPMS mechanism to deal with this
2 | # file. We fall back to the old mechanism instead to avoid this problem.
3 | io.github.ascopes.jct.workspaces.impl.MemoryFileSystemProvider$MemoryFileSystemUrlHandlerProvider
4 |
--------------------------------------------------------------------------------
/java-compiler-testing/src/test/java/io/github/ascopes/jct/assertions/ClassLoaderAssertTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022 - 2025, the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.github.ascopes.jct.assertions;
17 |
18 | import static org.mockito.Mockito.mock;
19 |
20 | import org.junit.jupiter.api.DisplayName;
21 | import org.junit.jupiter.api.Test;
22 |
23 | /**
24 | * {@link ClassLoaderAssert} tests.
25 | *
26 | * @author Ashley Scopes
27 | */
28 | @DisplayName("ClassLoaderAssert tests")
29 | class ClassLoaderAssertTest {
30 |
31 | @DisplayName("Assertions are performed on the classloader")
32 | @Test
33 | void assertionsArePerformedOnTheClassLoader() {
34 | // Given
35 | var classLoader = mock(ClassLoader.class);
36 |
37 | // When
38 | var assertions = new ClassLoaderAssert(classLoader);
39 |
40 | // Then
41 | assertions.isSameAs(classLoader);
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/java-compiler-testing/src/test/java/io/github/ascopes/jct/assertions/JavaFileObjectAssertTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022 - 2025, the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.github.ascopes.jct.assertions;
17 |
18 | import static io.github.ascopes.jct.fixtures.Fixtures.someJavaFileObject;
19 | import static org.assertj.core.api.Assertions.assertThat;
20 |
21 | import org.junit.jupiter.api.DisplayName;
22 | import org.junit.jupiter.api.Test;
23 |
24 | /**
25 | * {@link JavaFileObjectAssert} tests.
26 | *
27 | * @author Ashley Scopes
28 | */
29 | @DisplayName("JavaFileObjectAssert tests")
30 | class JavaFileObjectAssertTest {
31 |
32 | @DisplayName("Assertions are performed on the JavaFileObject")
33 | @Test
34 | void assertionsArePerformedOnTheJavaFileObject() {
35 | // Given
36 | var javaFileObject = someJavaFileObject();
37 |
38 | // When
39 | var assertions = new JavaFileObjectAssert(javaFileObject);
40 |
41 | // Then
42 | assertions
43 | .isSameAs(javaFileObject);
44 | assertThat(assertions)
45 | .isInstanceOf(AbstractJavaFileObjectAssert.class);
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/java-compiler-testing/src/test/java/io/github/ascopes/jct/compilers/DebuggingInfoTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022 - 2025, the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.github.ascopes.jct.compilers;
17 |
18 | import static org.assertj.core.api.Assertions.assertThat;
19 |
20 | import org.junit.jupiter.api.DisplayName;
21 | import org.junit.jupiter.api.Test;
22 |
23 |
24 | /**
25 | * {@link DebuggingInfo} tests.
26 | *
27 | * @author Ashley Scopes
28 | */
29 | class DebuggingInfoTest {
30 |
31 | @DisplayName(".none() returns an empty set")
32 | @Test
33 | void noneReturnsEmptySet() {
34 | // When
35 | var set = DebuggingInfo.none();
36 |
37 | // Then
38 | assertThat(set).isEmpty();
39 | }
40 |
41 |
42 | @DisplayName(".just(DebuggingInfo, DebuggingInfo...) returns a combined set")
43 | @Test
44 | void justReturnsCombinedSet() {
45 | // When
46 | var set = DebuggingInfo.just(DebuggingInfo.LINES, DebuggingInfo.VARS);
47 |
48 | // Then
49 | assertThat(set).containsExactlyInAnyOrder(
50 | DebuggingInfo.LINES,
51 | DebuggingInfo.VARS
52 | );
53 | }
54 |
55 | @DisplayName(".all() returns a set of all members")
56 | @Test
57 | void allReturnsSetOfAllMembers() {
58 | // When
59 | var set = DebuggingInfo.all();
60 |
61 | // Then
62 | assertThat(set).containsExactlyInAnyOrder(DebuggingInfo.values());
63 | }
64 |
65 | }
66 |
--------------------------------------------------------------------------------
/java-compiler-testing/src/test/java/io/github/ascopes/jct/compilers/JctCompilersTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022 - 2025, the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.github.ascopes.jct.compilers;
17 |
18 | import static org.assertj.core.api.Assertions.assertThat;
19 |
20 | import io.github.ascopes.jct.compilers.impl.JavacJctCompilerImpl;
21 | import io.github.ascopes.jct.fixtures.UtilityClassTestTemplate;
22 | import org.junit.jupiter.api.DisplayName;
23 | import org.junit.jupiter.api.Test;
24 | import org.mockito.Mockito;
25 |
26 | /**
27 | * {@link JctCompilers} tests.
28 | *
29 | * @author Ashley Scopes
30 | */
31 | @DisplayName("JctCompilers tests")
32 | class JctCompilersTest implements UtilityClassTestTemplate {
33 |
34 | @Override
35 | public Class> getTypeBeingTested() {
36 | return JctCompilers.class;
37 | }
38 |
39 | @DisplayName(".newPlatformCompiler() creates a JavacJctCompilerImpl instance")
40 | @Test
41 | void newPlatformCompilerReturnsTheExpectedInstance() {
42 | try (var javacJctCompilerImplMock = Mockito.mockConstruction(JavacJctCompilerImpl.class)) {
43 | // When
44 | var compiler = JctCompilers.newPlatformCompiler();
45 |
46 | // Then
47 | assertThat(compiler)
48 | .isInstanceOf(JavacJctCompilerImpl.class);
49 |
50 | assertThat(javacJctCompilerImplMock.constructed())
51 | .singleElement()
52 | // Nested assertion to swap expected/actual args.
53 | .satisfies(constructed -> assertThat(compiler).isSameAs(constructed));
54 | }
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/java-compiler-testing/src/test/java/io/github/ascopes/jct/ex/JctCompilerExceptionTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022 - 2025, the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.github.ascopes.jct.ex;
17 |
18 | import static org.assertj.core.api.Assertions.assertThat;
19 | import static org.mockito.Mockito.mock;
20 |
21 | import org.junit.jupiter.api.DisplayName;
22 | import org.junit.jupiter.api.Test;
23 |
24 | /**
25 | * Tests for {@link JctCompilerException}.
26 | *
27 | * @author Ashley Scopes
28 | */
29 | @DisplayName("JctCompilerException tests")
30 | class JctCompilerExceptionTest {
31 |
32 | @DisplayName("The message is set when no cause is given")
33 | @Test
34 | void messageIsSetWhenNoCauseGiven() {
35 | // Given
36 | var message = "foo bar baz";
37 |
38 | // When
39 | var ex = new JctCompilerException(message);
40 |
41 | // Then
42 | assertThat(ex)
43 | .hasMessage("foo bar baz");
44 | }
45 |
46 | @DisplayName("The message is set when a cause is given")
47 | @Test
48 | void messageIsSetWhenCauseGiven() {
49 | // Given
50 | var message = "qux quxx quxxx";
51 | var cause = mock(Throwable.class);
52 |
53 | // When
54 | var ex = new JctCompilerException(message, cause);
55 |
56 | // Then
57 | assertThat(ex)
58 | .hasMessage("qux quxx quxxx");
59 | }
60 |
61 | @DisplayName("The cause is set when a cause is given")
62 | @Test
63 | void causeIsSetWhenCauseGiven() {
64 | // Given
65 | var message = "do ray me";
66 | var cause = mock(Throwable.class);
67 |
68 | // When
69 | var ex = new JctCompilerException(message, cause);
70 |
71 | // Then
72 | assertThat(ex)
73 | .hasCause(cause);
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/java-compiler-testing/src/test/java/io/github/ascopes/jct/ex/JctIllegalInputExceptionTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022 - 2025, the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.github.ascopes.jct.ex;
17 |
18 | import static org.assertj.core.api.Assertions.assertThat;
19 | import static org.mockito.Mockito.mock;
20 |
21 | import org.junit.jupiter.api.DisplayName;
22 | import org.junit.jupiter.api.Test;
23 |
24 | /**
25 | * Tests for {@link JctIllegalInputException}.
26 | *
27 | * @author Ashley Scopes
28 | */
29 | @DisplayName("JctIllegalInputException tests")
30 | class JctIllegalInputExceptionTest {
31 |
32 | @DisplayName("The message is set when no cause is given")
33 | @Test
34 | void messageIsSetWhenNoCauseGiven() {
35 | // Given
36 | var message = "foo bar baz";
37 |
38 | // When
39 | var ex = new JctIllegalInputException(message);
40 |
41 | // Then
42 | assertThat(ex)
43 | .hasMessage("foo bar baz");
44 | }
45 |
46 | @DisplayName("The message is set when a cause is given")
47 | @Test
48 | void messageIsSetWhenCauseGiven() {
49 | // Given
50 | var message = "qux quxx quxxx";
51 | var cause = mock(Throwable.class);
52 |
53 | // When
54 | var ex = new JctIllegalInputException(message, cause);
55 |
56 | // Then
57 | assertThat(ex)
58 | .hasMessage("qux quxx quxxx");
59 | }
60 |
61 | @DisplayName("The cause is set when a cause is given")
62 | @Test
63 | void causeIsSetWhenCauseGiven() {
64 | // Given
65 | var message = "do ray me";
66 | var cause = mock(Throwable.class);
67 |
68 | // When
69 | var ex = new JctIllegalInputException(message, cause);
70 |
71 | // Then
72 | assertThat(ex)
73 | .hasCause(cause);
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/java-compiler-testing/src/test/java/io/github/ascopes/jct/ex/JctJunitConfigurerExceptionTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022 - 2025, the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.github.ascopes.jct.ex;
17 |
18 | import static org.assertj.core.api.Assertions.assertThat;
19 | import static org.mockito.Mockito.mock;
20 |
21 | import org.junit.jupiter.api.DisplayName;
22 | import org.junit.jupiter.api.Test;
23 |
24 | /**
25 | * {@link JctJunitConfigurerException} tests.
26 | *
27 | * @author Ashley Scopes
28 | */
29 | @DisplayName("JctJunitConfigurerException tests")
30 | class JctJunitConfigurerExceptionTest {
31 |
32 | @DisplayName("The message is set when no cause is given")
33 | @Test
34 | void messageIsSetWhenNoCauseGiven() {
35 | // Given
36 | var message = "foo bar baz";
37 |
38 | // When
39 | var ex = new JctJunitConfigurerException(message);
40 |
41 | // Then
42 | assertThat(ex)
43 | .hasMessage("foo bar baz");
44 | }
45 |
46 | @DisplayName("The message is set when a cause is given")
47 | @Test
48 | void messageIsSetWhenCauseGiven() {
49 | // Given
50 | var message = "qux quxx quxxx";
51 | var cause = mock(Throwable.class);
52 |
53 | // When
54 | var ex = new JctJunitConfigurerException(message, cause);
55 |
56 | // Then
57 | assertThat(ex)
58 | .hasMessage("qux quxx quxxx");
59 | }
60 |
61 | @DisplayName("The cause is set when a cause is given")
62 | @Test
63 | void causeIsSetWhenCauseGiven() {
64 | // Given
65 | var message = "do ray me";
66 | var cause = mock(Throwable.class);
67 |
68 | // When
69 | var ex = new JctJunitConfigurerException(message, cause);
70 |
71 | // Then
72 | assertThat(ex)
73 | .hasCause(cause);
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/java-compiler-testing/src/test/java/io/github/ascopes/jct/ex/JctNotFoundExceptionTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022 - 2025, the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.github.ascopes.jct.ex;
17 |
18 | import static org.assertj.core.api.Assertions.assertThat;
19 |
20 | import org.junit.jupiter.api.DisplayName;
21 | import org.junit.jupiter.api.Test;
22 |
23 | /**
24 | * Tests for {@link JctNotFoundException}.
25 | *
26 | * @author Ashley Scopes
27 | */
28 | @DisplayName("JctNotFoundException tests")
29 | class JctNotFoundExceptionTest {
30 |
31 | @DisplayName("The message is set when no cause is given")
32 | @Test
33 | void messageIsSetWhenNoCauseGiven() {
34 | // Given
35 | var message = "foo bar baz";
36 |
37 | // When
38 | var ex = new JctNotFoundException(message);
39 |
40 | // Then
41 | assertThat(ex)
42 | .hasMessage("foo bar baz");
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/java-compiler-testing/src/test/java/io/github/ascopes/jct/ex/JctNotImplementedTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022 - 2025, the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.github.ascopes.jct.ex;
17 |
18 | import static org.assertj.core.api.Assertions.assertThat;
19 |
20 | import org.junit.jupiter.api.DisplayName;
21 | import org.junit.jupiter.api.Test;
22 |
23 | /**
24 | * Tests for {@link JctNotImplementedException}.
25 | *
26 | * @author Ashley Scopes
27 | */
28 | @DisplayName("JctNotImplementedException tests")
29 | class JctNotImplementedTest {
30 |
31 | @DisplayName("The message is set when no cause is given")
32 | @Test
33 | void messageIsSetWhenNoCauseGiven() {
34 | // Given
35 | var message = "foo bar baz";
36 |
37 | // When
38 | var ex = new JctNotImplementedException(message);
39 |
40 | // Then
41 | assertThat(ex)
42 | .hasMessage("foo bar baz");
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/java-compiler-testing/src/test/java/io/github/ascopes/jct/filemanagers/JctFileManagersTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022 - 2025, the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.github.ascopes.jct.filemanagers;
17 |
18 | import static org.assertj.core.api.Assertions.assertThat;
19 | import static org.mockito.Mockito.mock;
20 |
21 | import io.github.ascopes.jct.compilers.JctCompiler;
22 | import io.github.ascopes.jct.filemanagers.impl.JctFileManagerFactoryImpl;
23 | import io.github.ascopes.jct.fixtures.UtilityClassTestTemplate;
24 | import org.junit.jupiter.api.DisplayName;
25 | import org.junit.jupiter.api.Test;
26 |
27 | /**
28 | * {@link JctFileManagers} tests.
29 | *
30 | * @author Ashley Scopes
31 | */
32 | @DisplayName("JctFileManagers tests")
33 | class JctFileManagersTest implements UtilityClassTestTemplate {
34 |
35 | @Override
36 | public Class> getTypeBeingTested() {
37 | return JctFileManagers.class;
38 | }
39 |
40 | @DisplayName(
41 | ".newJctFileManagerFactory(JctCompiler) returns a new JctFileManagerFactoryImpl instance"
42 | )
43 | @Test
44 | void newJctFileManagerFactoryReturnsNewJctFileManagerFactoryImplInstance() {
45 | // Given
46 | var compiler = mock(JctCompiler.class);
47 |
48 | // When
49 | var fileManagerFactory = JctFileManagers.newJctFileManagerFactory(compiler);
50 |
51 | // Then
52 | assertThat(fileManagerFactory).isInstanceOf(JctFileManagerFactoryImpl.class);
53 | assertThat(((JctFileManagerFactoryImpl) fileManagerFactory).getCompiler()).isSameAs(compiler);
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/java-compiler-testing/src/test/java/io/github/ascopes/jct/filemanagers/config/JctFileManagerConfigurerTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022 - 2025, the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.github.ascopes.jct.filemanagers.config;
17 |
18 | import static org.assertj.core.api.Assertions.assertThat;
19 |
20 | import org.junit.jupiter.api.DisplayName;
21 | import org.junit.jupiter.api.Test;
22 | import org.junit.jupiter.api.extension.ExtendWith;
23 | import org.mockito.Answers;
24 | import org.mockito.Mock;
25 | import org.mockito.junit.jupiter.MockitoExtension;
26 |
27 | /**
28 | * {@link JctFileManagerConfigurer} tests.
29 | *
30 | * @author Ashley Scopes
31 | */
32 | @DisplayName("JctFileManagerConfigurer tests")
33 | @ExtendWith(MockitoExtension.class)
34 | class JctFileManagerConfigurerTest {
35 |
36 | @Mock(answer = Answers.CALLS_REAL_METHODS)
37 | JctFileManagerConfigurer configurer;
38 |
39 | @DisplayName(".isEnabled() defaults to returning true")
40 | @Test
41 | void isEnabledReturnsTrue() {
42 | // Then
43 | assertThat(configurer.isEnabled()).isTrue();
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/java-compiler-testing/src/test/java/io/github/ascopes/jct/integration/AbstractIntegrationTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022 - 2025, the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.github.ascopes.jct.integration;
17 |
18 | import java.nio.file.Files;
19 | import java.nio.file.Path;
20 |
21 | /**
22 | * Abstract base class for integration tests to use.
23 | *
24 | * @author Ashley Scopes
25 | */
26 | public abstract class AbstractIntegrationTest {
27 |
28 | /**
29 | * Get the resources directory for this test. This will be a directory named the full canonical
30 | * class name.
31 | *
32 | * @return the resource directory path.
33 | */
34 | protected Path resourcesDirectory() {
35 | var path = Path.of("src", "test", "resources");
36 |
37 | // Add a suffix, as older Java versions complain if packages exist with the same name as
38 | // classes.
39 | var dirName = getClass().getCanonicalName() + "_resources";
40 |
41 | for (var part : dirName.split("[./]")) {
42 | path = path.resolve(part);
43 | }
44 |
45 | if (!Files.isDirectory(path)) {
46 | throw new IllegalStateException(
47 | "Please ensure the directory " + path + " exists, and try again"
48 | );
49 | }
50 |
51 | return path;
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/java-compiler-testing/src/test/java/io/github/ascopes/jct/integration/compilation/CompilingSpecificClassesIntegrationTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022 - 2025, the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.github.ascopes.jct.integration.compilation;
17 |
18 | import static io.github.ascopes.jct.assertions.JctAssertions.assertThat;
19 |
20 | import io.github.ascopes.jct.compilers.JctCompiler;
21 | import io.github.ascopes.jct.integration.AbstractIntegrationTest;
22 | import io.github.ascopes.jct.junit.JavacCompilerTest;
23 | import io.github.ascopes.jct.workspaces.Workspaces;
24 | import org.junit.jupiter.api.DisplayName;
25 |
26 | /**
27 | * Integration tests that test the compilation of specific classes only.
28 | *
29 | * @author Ashley Scopes
30 | */
31 | @DisplayName("Compiling specific classes integration tests")
32 | class CompilingSpecificClassesIntegrationTest extends AbstractIntegrationTest {
33 |
34 | @DisplayName("Only the classes that I specify get compiled")
35 | @JavacCompilerTest
36 | void onlyTheClassesSpecifiedGetCompiled(JctCompiler compiler) {
37 | try (var workspace = Workspaces.newWorkspace()) {
38 | workspace
39 | .createSourcePathPackage()
40 | .copyContentsFrom(resourcesDirectory());
41 |
42 | var compilation = compiler.compile(workspace, "Fibonacci", "HelloWorld");
43 |
44 | assertThat(compilation)
45 | .isSuccessfulWithoutWarnings()
46 | .classOutputPackages()
47 | .allFilesExist("Fibonacci.class", "HelloWorld.class")
48 | .fileDoesNotExist("Sum.class");
49 | }
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/java-compiler-testing/src/test/java/io/github/ascopes/jct/repr/LocationRepresentationTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022 - 2025, the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.github.ascopes.jct.repr;
17 |
18 | import static io.github.ascopes.jct.fixtures.Fixtures.oneOf;
19 | import static org.assertj.core.api.Assertions.assertThat;
20 |
21 | import javax.tools.StandardLocation;
22 | import org.junit.jupiter.api.DisplayName;
23 | import org.junit.jupiter.api.Test;
24 |
25 | /**
26 | * {@link LocationRepresentation} tests.
27 | *
28 | * @author Ashley Scopes
29 | */
30 | @DisplayName("LocationRepresentation tests")
31 | class LocationRepresentationTest {
32 |
33 | @DisplayName("toStringOf(null) returns \"null\"")
34 | @Test
35 | void toStringOfNullReturnsNull() {
36 | // Given
37 | var repr = LocationRepresentation.getInstance();
38 |
39 | // When
40 | var result = repr.toStringOf(null);
41 |
42 | // Then
43 | assertThat(result).isEqualTo("null");
44 | }
45 |
46 | @DisplayName("toStringOf(Location) returns the location name")
47 | @Test
48 | void toStringOfLocationReturnsName() {
49 | // Given
50 | var repr = LocationRepresentation.getInstance();
51 | var location = oneOf(StandardLocation.values());
52 |
53 | // When
54 | var result = repr.toStringOf(location);
55 |
56 | // Then
57 | assertThat(result).isEqualTo(location.getName());
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/java-compiler-testing/src/test/java/io/github/ascopes/jct/workspaces/ManagedDirectoryTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022 - 2025, the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.github.ascopes.jct.workspaces;
17 |
18 | import static org.assertj.core.api.Assertions.assertThat;
19 |
20 | import org.junit.jupiter.api.DisplayName;
21 | import org.junit.jupiter.api.Test;
22 | import org.junit.jupiter.api.extension.ExtendWith;
23 | import org.mockito.Answers;
24 | import org.mockito.Mock;
25 | import org.mockito.junit.jupiter.MockitoExtension;
26 |
27 | /**
28 | * {@link ManagedDirectory} tests.
29 | *
30 | * @author Ashley Scopes
31 | */
32 | @DisplayName("ManagedDirectory tests")
33 | @ExtendWith(MockitoExtension.class)
34 | class ManagedDirectoryTest {
35 |
36 | @Mock(answer = Answers.CALLS_REAL_METHODS)
37 | ManagedDirectory managedDirectory;
38 |
39 | @DisplayName(".and() returns the object")
40 | @Test
41 | void andReturnsTheObject() {
42 | // Then
43 | assertThat(managedDirectory.and()).isSameAs(managedDirectory);
44 | }
45 |
46 | @DisplayName(".also() returns the object")
47 | @Test
48 | void alsoReturnsTheObject() {
49 | // Then
50 | assertThat(managedDirectory.also()).isSameAs(managedDirectory);
51 | }
52 |
53 | @DisplayName(".then() returns the object")
54 | @Test
55 | void thenReturnsTheObject() {
56 | // Then
57 | assertThat(managedDirectory.then()).isSameAs(managedDirectory);
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/java-compiler-testing/src/test/resources/io/github/ascopes/jct/integration/compilation/BasicLegacyCompilationIntegrationTest_resources/HelloWorld.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022 - 2025, the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.example;
17 |
18 | /**
19 | * A test case that just prints hello world.
20 | */
21 | public class HelloWorld {
22 |
23 | /**
24 | * Main method.
25 | *
26 | * @param args command line arguments.
27 | */
28 | public static void main(String[] args) {
29 | System.out.println("Hello, World");
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/java-compiler-testing/src/test/resources/io/github/ascopes/jct/integration/compilation/BasicModuleCompilationIntegrationTest_resources/com/example/HelloWorld.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022 - 2025, the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.example;
17 |
18 | /**
19 | * A test case that just prints hello world.
20 | */
21 | public class HelloWorld {
22 |
23 | /**
24 | * Main method.
25 | *
26 | * @param args command line arguments.
27 | */
28 | public static void main(String[] args) {
29 | System.out.println("Hello, World");
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/java-compiler-testing/src/test/resources/io/github/ascopes/jct/integration/compilation/BasicModuleCompilationIntegrationTest_resources/module-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022 - 2025, the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | /**
17 | * A JPMS module.
18 | */
19 | module hello.world {
20 | requires java.base;
21 | exports com.example;
22 | }
23 |
--------------------------------------------------------------------------------
/java-compiler-testing/src/test/resources/io/github/ascopes/jct/integration/compilation/BasicMultiModuleCompilationIntegrationTest_resources/greeter/com/example/greeter/Greeter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022 - 2025, the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.example.greeter;
17 |
18 | /**
19 | * A class that can greet me.
20 | */
21 | public class Greeter {
22 |
23 | /**
24 | * Greet me.
25 | *
26 | * @param name my name.
27 | * @return the greeting.
28 | */
29 | public static String greet(String name) {
30 | return "Hello, " + name + "!";
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/java-compiler-testing/src/test/resources/io/github/ascopes/jct/integration/compilation/BasicMultiModuleCompilationIntegrationTest_resources/greeter/module-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022 - 2025, the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | /**
17 | * A JPMS module.
18 | */
19 | module greeter {
20 | exports com.example.greeter;
21 | }
22 |
--------------------------------------------------------------------------------
/java-compiler-testing/src/test/resources/io/github/ascopes/jct/integration/compilation/BasicMultiModuleCompilationIntegrationTest_resources/hello.world.crossmodule/com/example/HelloWorld.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022 - 2025, the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.example;
17 |
18 | /**
19 | * A class that says hello.
20 | */
21 | public class HelloWorld {
22 |
23 | /**
24 | * Main method.
25 | *
26 | * @param args command line arguments.
27 | */
28 | public static void main(String[] args) {
29 | System.out.println("Hello, World");
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/java-compiler-testing/src/test/resources/io/github/ascopes/jct/integration/compilation/BasicMultiModuleCompilationIntegrationTest_resources/hello.world.crossmodule/module-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022 - 2025, the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | /**
17 | * A JPMS module.
18 | */
19 | module hello.world.crossmodule {
20 | requires java.base;
21 | exports com.example;
22 | }
23 |
--------------------------------------------------------------------------------
/java-compiler-testing/src/test/resources/io/github/ascopes/jct/integration/compilation/BasicMultiModuleCompilationIntegrationTest_resources/hello.world.singlemodule/com/example/HelloWorld.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022 - 2025, the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.example;
17 |
18 | /**
19 | * A class that says hello.
20 | */
21 | public class HelloWorld {
22 |
23 | /**
24 | * Main method.
25 | *
26 | * @param args command line arguments.
27 | */
28 | public static void main(String[] args) {
29 | System.out.println("Hello, World");
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/java-compiler-testing/src/test/resources/io/github/ascopes/jct/integration/compilation/BasicMultiModuleCompilationIntegrationTest_resources/hello.world.singlemodule/module-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022 - 2025, the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | /**
17 | * A JPMS module.
18 | */
19 | module hello.world.singlemodule {
20 | requires java.base;
21 | exports com.example;
22 | }
23 |
--------------------------------------------------------------------------------
/java-compiler-testing/src/test/resources/io/github/ascopes/jct/integration/compilation/CompilingSpecificClassesIntegrationTest_resources/Fibonacci.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022 - 2025, the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | import static java.math.BigInteger.ONE;
17 | import static java.math.BigInteger.ZERO;
18 |
19 | import java.math.BigInteger;
20 |
21 | /**
22 | * Command line app to calculate the nth number of the fibonacci sequence.
23 | */
24 | public class Fibonacci {
25 |
26 | /**
27 | * Main method.
28 | *
29 | * @param args command line arguments.
30 | */
31 | public static void main(String[] args) {
32 | if (args.length != 1) {
33 | System.out.println("USAGE: java Fibonacci