Skip to content

Commit

Permalink
#3187 Fix line separators
Browse files Browse the repository at this point in the history
  • Loading branch information
Henry Kuijpers committed Dec 15, 2023
1 parent f5cb0c2 commit a03ced9
Showing 1 changed file with 79 additions and 85 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import static org.junit.jupiter.params.provider.Arguments.arguments;

public class DialogProviderAnnotationProcessorTest {
private static final String EOL = System.lineSeparator();
private static final Processor UNDER_TEST = new DialogProviderAnnotationProcessor();
@Test
void testConfiguration() {
Expand All @@ -34,13 +35,6 @@ void testConfiguration() {
);
}

@Test
void whenTheComputedFileAlreadyExistsAnExceptionIsThrownHoweverThatShouldBeIgnored() {
for (int i = 0; i < 2; i++) {
final Compilation compilation = compile("Example1", "package a; @com.adobe.acs.commons.mcp.form.DialogProvider public class Example1 {public String getResourceType(){return \"Something else\";}}");
}
}

@Test
void whenResourceTypeIsNotSuppliedTheAnnotationProcessorWillNotProduceAnAdditionalSourceFileForThatClass() {
final Compilation compilation = compile("ExampleFaulty", "package a; @com.adobe.acs.commons.mcp.form.DialogProvider public class ExampleFaulty {public String getResult(){return \"Something else\";}}");
Expand Down Expand Up @@ -71,84 +65,84 @@ private static Compilation compile(@NotNull String name, @NotNull String source)

private static Stream<Arguments> annotationProviderProducesAdditionalSourceFile() {
return Stream.of(
arguments("Example1", "package a; @com.adobe.acs.commons.mcp.form.DialogProvider public class Example1 {public String getResourceType(){return \"my.type\";}}", "package a.impl;\n" +
"\n" +
"import javax.annotation.Generated;\n" +
"import org.osgi.annotation.versioning.ConsumerType;\n" +
"import org.osgi.framework.BundleContext;\n" +
"import org.osgi.service.component.annotations.*;\n" +
"\n" +
"@Generated(\"Created by the ACS Commons DialogProviderAnnotationProcessor\")\n" +
"@ConsumerType\n" +
"@Component(service = com.adobe.acs.commons.mcp.form.DialogResourceProvider.class, immediate = true)\n" +
"public class Example1_dialogResourceProvider implements com.adobe.acs.commons.mcp.form.DialogResourceProvider {\n" +
"\n" +
" @Override\n" +
" public Class getTargetClass() {\n" +
" return a.Example1.class;\n" +
" }\n" +
" @Activate\n" +
" public void activate(BundleContext context) throws InstantiationException, IllegalAccessException, ReflectiveOperationException {\n" +
" this.doActivate(context);\n" +
" }\n" +
"\n" +
" @Deactivate\n" +
" public void deactivate(BundleContext context) {\n" +
" this.doDeactivate();\n" +
" }\n" +
"}\n"),
arguments("Example2", "package a; @com.adobe.acs.commons.mcp.form.DialogProvider public class Example2 {public String resourceType=\"my.type\";}", "package a.impl;\n" +
"\n" +
"import javax.annotation.Generated;\n" +
"import org.osgi.annotation.versioning.ConsumerType;\n" +
"import org.osgi.framework.BundleContext;\n" +
"import org.osgi.service.component.annotations.*;\n" +
"\n" +
"@Generated(\"Created by the ACS Commons DialogProviderAnnotationProcessor\")\n" +
"@ConsumerType\n" +
"@Component(service = com.adobe.acs.commons.mcp.form.DialogResourceProvider.class, immediate = true)\n" +
"public class Example2_dialogResourceProvider implements com.adobe.acs.commons.mcp.form.DialogResourceProvider {\n" +
"\n" +
" @Override\n" +
" public Class getTargetClass() {\n" +
" return a.Example2.class;\n" +
" }\n" +
" @Activate\n" +
" public void activate(BundleContext context) throws InstantiationException, IllegalAccessException, ReflectiveOperationException {\n" +
" this.doActivate(context);\n" +
" }\n" +
"\n" +
" @Deactivate\n" +
" public void deactivate(BundleContext context) {\n" +
" this.doDeactivate();\n" +
" }\n" +
"}\n"),
arguments("Example3", "package a; @org.apache.sling.models.annotations.Model(adaptables=org.apache.sling.api.resource.Resource.class, resourceType=\"my.type\") @com.adobe.acs.commons.mcp.form.DialogProvider public class Example3 {}", "package a.impl;\n" +
"\n" +
"import javax.annotation.Generated;\n" +
"import org.osgi.annotation.versioning.ConsumerType;\n" +
"import org.osgi.framework.BundleContext;\n" +
"import org.osgi.service.component.annotations.*;\n" +
"\n" +
"@Generated(\"Created by the ACS Commons DialogProviderAnnotationProcessor\")\n" +
"@ConsumerType\n" +
"@Component(service = com.adobe.acs.commons.mcp.form.DialogResourceProvider.class, immediate = true)\n" +
"public class Example3_dialogResourceProvider implements com.adobe.acs.commons.mcp.form.DialogResourceProvider {\n" +
"\n" +
" @Override\n" +
" public Class getTargetClass() {\n" +
" return a.Example3.class;\n" +
" }\n" +
" @Activate\n" +
" public void activate(BundleContext context) throws InstantiationException, IllegalAccessException, ReflectiveOperationException {\n" +
" this.doActivate(context);\n" +
" }\n" +
"\n" +
" @Deactivate\n" +
" public void deactivate(BundleContext context) {\n" +
" this.doDeactivate();\n" +
" }\n" +
"}\n")
arguments("Example1", "package a; @com.adobe.acs.commons.mcp.form.DialogProvider public class Example1 {public String getResourceType(){return \"my.type\";}}", "package a.impl;" + EOL +
EOL +
"import javax.annotation.Generated;" + EOL +
"import org.osgi.annotation.versioning.ConsumerType;" + EOL +
"import org.osgi.framework.BundleContext;" + EOL +
"import org.osgi.service.component.annotations.*;" + EOL +
EOL +
"@Generated(\"Created by the ACS Commons DialogProviderAnnotationProcessor\")" + EOL +
"@ConsumerType" + EOL +
"@Component(service = com.adobe.acs.commons.mcp.form.DialogResourceProvider.class, immediate = true)" + EOL +
"public class Example1_dialogResourceProvider implements com.adobe.acs.commons.mcp.form.DialogResourceProvider {" + EOL +
EOL +
" @Override" + EOL +
" public Class getTargetClass() {" + EOL +
" return a.Example1.class;" + EOL +
" }" + EOL +
" @Activate" + EOL +
" public void activate(BundleContext context) throws InstantiationException, IllegalAccessException, ReflectiveOperationException {" + EOL +
" this.doActivate(context);" + EOL +
" }" + EOL +
EOL +
" @Deactivate" + EOL +
" public void deactivate(BundleContext context) {" + EOL +
" this.doDeactivate();" + EOL +
" }" + EOL +
"}" + EOL),
arguments("Example2", "package a; @com.adobe.acs.commons.mcp.form.DialogProvider public class Example2 {public String resourceType=\"my.type\";}", "package a.impl;" + EOL +
EOL +
"import javax.annotation.Generated;" + EOL +
"import org.osgi.annotation.versioning.ConsumerType;" + EOL +
"import org.osgi.framework.BundleContext;" + EOL +
"import org.osgi.service.component.annotations.*;" + EOL +
EOL +
"@Generated(\"Created by the ACS Commons DialogProviderAnnotationProcessor\")" + EOL +
"@ConsumerType" + EOL +
"@Component(service = com.adobe.acs.commons.mcp.form.DialogResourceProvider.class, immediate = true)" + EOL +
"public class Example2_dialogResourceProvider implements com.adobe.acs.commons.mcp.form.DialogResourceProvider {" + EOL +
EOL +
" @Override" + EOL +
" public Class getTargetClass() {" + EOL +
" return a.Example2.class;" + EOL +
" }" + EOL +
" @Activate" + EOL +
" public void activate(BundleContext context) throws InstantiationException, IllegalAccessException, ReflectiveOperationException {" + EOL +
" this.doActivate(context);" + EOL +
" }" + EOL +
EOL +
" @Deactivate" + EOL +
" public void deactivate(BundleContext context) {" + EOL +
" this.doDeactivate();" + EOL +
" }" + EOL +
"}" + EOL),
arguments("Example3", "package a; @org.apache.sling.models.annotations.Model(adaptables=org.apache.sling.api.resource.Resource.class, resourceType=\"my.type\") @com.adobe.acs.commons.mcp.form.DialogProvider public class Example3 {}", "package a.impl;" + EOL +
EOL +
"import javax.annotation.Generated;" + EOL +
"import org.osgi.annotation.versioning.ConsumerType;" + EOL +
"import org.osgi.framework.BundleContext;" + EOL +
"import org.osgi.service.component.annotations.*;" + EOL +
EOL +
"@Generated(\"Created by the ACS Commons DialogProviderAnnotationProcessor\")" + EOL +
"@ConsumerType" + EOL +
"@Component(service = com.adobe.acs.commons.mcp.form.DialogResourceProvider.class, immediate = true)" + EOL +
"public class Example3_dialogResourceProvider implements com.adobe.acs.commons.mcp.form.DialogResourceProvider {" + EOL +
EOL +
" @Override" + EOL +
" public Class getTargetClass() {" + EOL +
" return a.Example3.class;" + EOL +
" }" + EOL +
" @Activate" + EOL +
" public void activate(BundleContext context) throws InstantiationException, IllegalAccessException, ReflectiveOperationException {" + EOL +
" this.doActivate(context);" + EOL +
" }" + EOL +
EOL +
" @Deactivate" + EOL +
" public void deactivate(BundleContext context) {" + EOL +
" this.doDeactivate();" + EOL +
" }" + EOL +
"}" + EOL)
);
}
}

0 comments on commit a03ced9

Please sign in to comment.