-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from breadrock1/improve/add-example
Improve: Added example
- Loading branch information
Showing
8 changed files
with
233 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
**Full Changelog**: https://github.com/breadrock1/Adblock-coffee/compare/adblock-coffee-1.0.3...adblock-coffee-1.0.4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<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/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>com.example.simple</groupId> | ||
<artifactId>simple</artifactId> | ||
<version>1.0.1</version> | ||
<name>simple</name> | ||
|
||
<properties> | ||
<maven.compiler.target>${maven.compiler.source}</maven.compiler.target> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<start-class>com.example.simple.App</start-class> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
<version>4.11</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.example.adblock</groupId> | ||
<artifactId>adblock-coffee</artifactId> | ||
<version>1.0.3</version> | ||
<scope>system</scope> | ||
<systemPath>${project.basedir}/lib/adblock-coffee-1.0.3.jar</systemPath> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<pluginManagement> | ||
<plugins> | ||
<plugin> | ||
<artifactId>maven-clean-plugin</artifactId> | ||
<version>3.1.0</version> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-jar-plugin</artifactId> | ||
<configuration> | ||
<archive> | ||
<manifest> | ||
<addClasspath>true</addClasspath> | ||
<classpathPrefix>libs/</classpathPrefix> | ||
<mainClass> | ||
com.example.simple.App | ||
</mainClass> | ||
</manifest> | ||
</archive> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-surefire-plugin</artifactId> | ||
<version>2.17</version> | ||
<configuration> | ||
<argLine>-Djava.library.path=${project.basedir}/target/lib/</argLine> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</pluginManagement> | ||
</build> | ||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package com.example.simple; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import com.example.adblock.AdvtBlocker; | ||
|
||
/** | ||
* Simple example! | ||
*/ | ||
public class App { | ||
public static void main(String[] args) { | ||
List<String> rules = new ArrayList<>(List.of( | ||
"-advertisement-icon.", | ||
"-advertisement-management/", | ||
"-advertisement.", | ||
"-advertisement/script." | ||
)); | ||
|
||
AdvtBlocker blocker = AdvtBlocker.createInstance(rules); | ||
boolean result = blocker.checkUrls( | ||
"http://example.com/-advertisement-icon.", | ||
"http://example.com/helloworld", | ||
"image" | ||
); | ||
|
||
System.out.println(result); | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
examples/simple/src/test/java/com/example/simple/AppTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package com.example.simple; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import static org.junit.Assert.assertTrue; | ||
|
||
import org.junit.Test; | ||
|
||
import com.example.adblock.AdvtBlocker; | ||
|
||
/** | ||
* Simple test of using library | ||
*/ | ||
public class AppTest { | ||
/** | ||
* Rigorous Test :-) | ||
*/ | ||
@Test | ||
public void mainTest() { | ||
List<String> rules = new ArrayList<>(List.of( | ||
"-advertisement-icon.", | ||
"-advertisement-management/", | ||
"-advertisement.", | ||
"-advertisement/script." | ||
)); | ||
|
||
AdvtBlocker blocker = AdvtBlocker.createInstance(rules); | ||
boolean result = blocker.checkUrls( | ||
"http://example.com/-advertisement-icon.", | ||
"http://example.com/helloworld", | ||
"image" | ||
); | ||
|
||
assertTrue(result); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters