You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jspwiki.apache.org by ju...@apache.org on 2020/03/16 21:58:01 UTC

[jspwiki] 11/47: JSPWIKI-303: added module with extensions not using the public api

This is an automated email from the ASF dual-hosted git repository.

juanpablo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/jspwiki.git

commit 624b0a7008f2246e01cd57da599e6189528143e1
Author: juanpablo <ju...@apache.org>
AuthorDate: Wed Mar 11 19:04:31 2020 +0100

    JSPWIKI-303: added module with extensions not using the public api
    
    The idea of this module is to have some custom extensions so that they can be used to ensure that backwards compatibility for 3rd party code not using the public api is retained
---
 jspwiki-210-test-adaptees/pom.xml                  | 70 ++++++++++++++++++++++
 .../main/java/com/example/filters/TwoXFilter.java  | 17 ++++++
 .../main/java/com/example/plugins/TwoXPlugin.java  | 37 ++++++++++++
 .../java/com/example/filters/TwoXFilterTest.java   | 33 ++++++++++
 .../java/com/example/plugins/TwoXPluginTest.java   | 33 ++++++++++
 5 files changed, 190 insertions(+)

diff --git a/jspwiki-210-test-adaptees/pom.xml b/jspwiki-210-test-adaptees/pom.xml
new file mode 100644
index 0000000..f8b1a4f
--- /dev/null
+++ b/jspwiki-210-test-adaptees/pom.xml
@@ -0,0 +1,70 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License.  You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied.  See the License for the
+  specific language governing permissions and limitations
+  under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+  <parent>
+    <groupId>org.apache.jspwiki</groupId>
+    <artifactId>jspwiki-builder</artifactId>
+    <version>2.11.0.M7-SNAPSHOT</version>
+  </parent>
+
+  <modelVersion>4.0.0</modelVersion>
+  <artifactId>jspwiki-210-test-adaptees</artifactId>
+  <name>Apache JSPWiki test extensions not using public api</name>
+  
+  <properties>
+    <last-jspwiki-version-without-public-api>2.11.0.M6</last-jspwiki-version-without-public-api>
+  </properties>
+
+  <dependencies>
+    <dependency>
+      <groupId>${project.groupId}</groupId>
+      <artifactId>jspwiki-main</artifactId>
+      <version>${last-jspwiki-version-without-public-api}</version>
+      <scope>provided</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>${project.groupId}</groupId>
+      <artifactId>jspwiki-main</artifactId>
+      <type>test-jar</type>
+      <version>${last-jspwiki-version-without-public-api}</version>
+      <scope>test</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>org.junit.jupiter</groupId>
+      <artifactId>junit-jupiter-api</artifactId>
+      <scope>test</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>org.junit.jupiter</groupId>
+      <artifactId>junit-jupiter-params</artifactId>
+      <scope>test</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>org.junit.jupiter</groupId>
+      <artifactId>junit-jupiter-engine</artifactId>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+</project>
diff --git a/jspwiki-210-test-adaptees/src/main/java/com/example/filters/TwoXFilter.java b/jspwiki-210-test-adaptees/src/main/java/com/example/filters/TwoXFilter.java
new file mode 100644
index 0000000..d73ecf5
--- /dev/null
+++ b/jspwiki-210-test-adaptees/src/main/java/com/example/filters/TwoXFilter.java
@@ -0,0 +1,17 @@
+package com.example.filters;
+
+import org.apache.wiki.WikiContext;
+import org.apache.wiki.api.filters.BasicPageFilter;
+
+
+public class TwoXFilter extends BasicPageFilter {
+
+    /**
+     *  {@inheritDoc}
+     */
+    @Override
+    public String postTranslate( final WikiContext wikiContext, final String htmlContent ) {
+        return "see how I care about yor content - hmmm...";
+    }
+
+}
diff --git a/jspwiki-210-test-adaptees/src/main/java/com/example/plugins/TwoXPlugin.java b/jspwiki-210-test-adaptees/src/main/java/com/example/plugins/TwoXPlugin.java
new file mode 100644
index 0000000..1e19646
--- /dev/null
+++ b/jspwiki-210-test-adaptees/src/main/java/com/example/plugins/TwoXPlugin.java
@@ -0,0 +1,37 @@
+/*
+    Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+ */
+package com.example.plugins;
+
+import org.apache.wiki.api.exceptions.PluginException;
+import org.apache.wiki.api.plugin.WikiPlugin;
+import org.apache.wiki.WikiContext;
+import java.util.Map;
+
+
+/**
+ * Hakuna matata JSPWiki 2.X plugin
+ */
+public class TwoXPlugin implements WikiPlugin {
+	
+    @Override
+	public String execute(WikiContext wikiContext, Map<String, String> params) throws PluginException {
+		return "hakuna matata";
+	}
+
+}
diff --git a/jspwiki-210-test-adaptees/src/test/java/com/example/filters/TwoXFilterTest.java b/jspwiki-210-test-adaptees/src/test/java/com/example/filters/TwoXFilterTest.java
new file mode 100644
index 0000000..ca6cf3a
--- /dev/null
+++ b/jspwiki-210-test-adaptees/src/test/java/com/example/filters/TwoXFilterTest.java
@@ -0,0 +1,33 @@
+/*
+    Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+ */
+package com.example.filters;
+
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+
+
+public class TwoXFilterTest {
+
+    @Test
+    public void testFilter() throws Exception {
+        final TwoXFilter txf = new TwoXFilter();
+        Assertions.assertEquals("see how I care about yor content - hmmm...", txf.postTranslate( null, null ) );
+    }
+
+}
diff --git a/jspwiki-210-test-adaptees/src/test/java/com/example/plugins/TwoXPluginTest.java b/jspwiki-210-test-adaptees/src/test/java/com/example/plugins/TwoXPluginTest.java
new file mode 100644
index 0000000..6d54680
--- /dev/null
+++ b/jspwiki-210-test-adaptees/src/test/java/com/example/plugins/TwoXPluginTest.java
@@ -0,0 +1,33 @@
+/*
+    Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+ */
+package com.example.plugins;
+
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+
+
+public class TwoXPluginTest {
+	
+    @Test
+	public void testPlugin() throws Exception {
+		final TwoXPlugin txp = new TwoXPlugin();
+		Assertions.assertEquals("hakuna matata", txp.execute( null, null ) );
+	}
+
+}