Gradle build fixes

This commit is contained in:
crschnick 2023-08-26 07:19:41 +00:00
parent 3de789500e
commit b2a6549fb6
13 changed files with 5 additions and 172149 deletions

View file

@ -122,19 +122,6 @@ if (OperatingSystem.current() == OperatingSystem.LINUX) {
jvmRunArgs.addAll("--add-opens", "java.desktop/sun.awt.X11=io.xpipe.app")
}
test {
jvmArgs += jvmRunArgs
systemProperty 'io.xpipe.app.mode', 'background'
systemProperty 'io.xpipe.app.dataDir', "$projectDir/local_test/"
systemProperty 'io.xpipe.app.writeLogs', "false"
systemProperty 'io.xpipe.app.writeSysOut', "true"
systemProperty 'io.xpipe.app.developerMode', "true"
systemProperty 'io.xpipe.app.logLevel', "trace"
systemProperty 'io.xpipe.app.fullVersion', rootProject.fullVersion
//systemProperty "io.xpipe.beacon.port", "21722"
}
def extensionJarDepList = project.allExtensions.stream().map(p -> p.getTasksByName('jar', true)).toList();
jar {

View file

@ -1,11 +0,0 @@
open module io.xpipe.app.test {
requires io.xpipe.app;
requires org.junit.jupiter.api;
requires org.junit.jupiter.params;
requires io.xpipe.core;
requires io.xpipe.api;
requires io.xpipe.extension;
requires static lombok;
exports test;
}

View file

@ -1,18 +0,0 @@
package test;
import io.xpipe.app.core.mode.OperationMode;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
public class DaemonTest {
@BeforeAll
static void setup() throws Exception {
OperationMode.init(new String[0]);
}
@AfterAll
static void teardown() throws Throwable {
OperationMode.BACKGROUND.finalTeardown();
}
}

View file

@ -1,195 +0,0 @@
package test;
import io.xpipe.app.ext.DataSourceProvider;
import io.xpipe.app.ext.DataSourceProviders;
import io.xpipe.core.data.node.ArrayNode;
import io.xpipe.core.data.node.DataStructureNode;
import io.xpipe.core.impl.InMemoryStore;
import io.xpipe.core.source.*;
import lombok.SneakyThrows;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import java.util.function.BiConsumer;
import java.util.function.Supplier;
import static io.xpipe.core.source.DataSourceType.*;
public class DataSourceTest extends DaemonTest {
public static final int READ_LIMIT = Integer.MAX_VALUE;
@BeforeAll
public static void setupStorage() throws Exception {
TestSourcesDatabase.init();
}
@Test
public void testEquality() {
for (var testSource : TestSourcesDatabase.TEST_SOURCES) {
var first = testSource.get();
var second = testSource.get();
Assertions.assertEquals(first, second);
var firstHash = first.hashCode();
var secondHash = second.hashCode();
Assertions.assertEquals(firstHash, secondHash);
var firstString = first.toString();
var secondString = second.toString();
Assertions.assertEquals(firstString, secondString);
}
for (var testStore : TestSourcesDatabase.TEST_STORES) {
var first = testStore.get();
var second = testStore.get();
Assertions.assertEquals(first, second);
var firstHash = first.hashCode();
var secondHash = second.hashCode();
Assertions.assertEquals(firstHash, secondHash);
var firstString = first.toString();
var secondString = second.toString();
Assertions.assertEquals(firstString, secondString);
}
}
@Test
public void testInputOutput() throws Exception {
for (io.xpipe.core.source.DataSource<?> testSource :
TestSourcesDatabase.TEST_SOURCES.stream().map(Supplier::get).toList()) {
var provider = DataSourceProviders.byDataSourceClass(testSource.getClass());
System.out.println(String.format("Doing input output for %s", provider.getId()));
var memoryStore = new InMemoryStore(new byte[0]);
var memorySource = provider.createDefaultSource(memoryStore);
if (!memorySource.getFlow().hasInput() || !memorySource.getFlow().hasOutput()) {
continue;
}
try (DataSourceReadConnection dataSourceReadConnection = testSource.openReadConnection()) {
dataSourceReadConnection.init();
try (DataSourceConnection out = memorySource.openWriteConnection(WriteMode.REPLACE)) {
out.init();
dataSourceReadConnection.forward(out);
}
}
isExactlyEqual(testSource, memorySource);
}
}
@Test
public void testRoundabout() throws Exception {
for (io.xpipe.core.source.DataSource<?> testSource :
TestSourcesDatabase.TEST_SOURCES.stream().map(Supplier::get).toList()) {
var provider = DataSourceProviders.byDataSourceClass(testSource.getClass());
var compatibleProviders = DataSourceProviders.getAll().stream()
.filter(p -> p.getPrimaryType() == provider.getPrimaryType()
&& p.getCategory() == DataSourceProvider.Category.STREAM)
.toList();
for (DataSourceProvider<?> compatibleProvider : compatibleProviders) {
var memoryStore = new InMemoryStore();
var memorySource = compatibleProvider.createDefaultSource(memoryStore);
if (!memorySource.getFlow().hasOutput()) {
continue;
}
System.out.println(
String.format("Doing translation from %s to %s", provider.getId(), compatibleProvider.getId()));
try (DataSourceReadConnection dataSourceReadConnection = testSource.openReadConnection()) {
try (DataSourceConnection out = memorySource.openWriteConnection(WriteMode.REPLACE)) {
dataSourceReadConnection.init();
out.init();
dataSourceReadConnection.forward(out);
}
}
isContentEqual(testSource, memorySource);
}
}
}
@SneakyThrows
private void isExactlyEqual(DataSource<?> first, DataSource<?> second) {
isEqual(
first,
second,
(dataStructureNode, dataStructureNode2) ->
Assertions.assertEquals(dataStructureNode, dataStructureNode2));
}
@SneakyThrows
private void isContentEqual(DataSource<?> first, DataSource<?> second) {
isEqual(first, second, (dataStructureNode, o2) -> {
if (!(dataStructureNode instanceof DataStructureNode)) {
Assertions.assertEquals(dataStructureNode, o2);
return;
}
DataStructureNode dataStructureNode1 = (DataStructureNode) dataStructureNode;
DataStructureNode dataStructureNode2 = (DataStructureNode) o2;
dataStructureNode1.clearMetaAttributes();
dataStructureNode2.clearMetaAttributes();
Assertions.assertEquals(dataStructureNode1, dataStructureNode2);
});
}
@SneakyThrows
private void isEqual(DataSource<?> first, DataSource<?> second, BiConsumer<Object, Object> equalsCheck) {
if (!first.getFlow().hasInput() || !second.getFlow().hasInput()) {
return;
}
var firstProvider = DataSourceProviders.byDataSourceClass(first.getClass());
var secondProvider = DataSourceProviders.byDataSourceClass(second.getClass());
if (first.getType() == TABLE) {
ArrayNode firstNode = null;
try (TableReadConnection tableReadConnection = ((TableDataSource<?>) first).openReadConnection()) {
tableReadConnection.init();
firstNode = tableReadConnection.readRows(READ_LIMIT);
}
ArrayNode secondNode = null;
try (TableReadConnection tableReadConnection = ((TableDataSource<?>) second).openReadConnection()) {
tableReadConnection.init();
secondNode = tableReadConnection.readRows(READ_LIMIT);
}
equalsCheck.accept(firstNode, secondNode);
}
if (first.getType() == STRUCTURE) {
DataStructureNode firstNode = null;
try (StructureReadConnection tableReadConnection = ((StructureDataSource<?>) first).openReadConnection()) {
tableReadConnection.init();
firstNode = tableReadConnection.read();
}
DataStructureNode secondNode = null;
try (StructureReadConnection tableReadConnection = ((StructureDataSource<?>) second).openReadConnection()) {
tableReadConnection.init();
secondNode = tableReadConnection.read();
}
equalsCheck.accept(firstNode, secondNode);
}
if (first.getType() == TEXT) {
String firstNode = null;
try (TextReadConnection tableReadConnection = ((TextDataSource<?>) first).openReadConnection()) {
tableReadConnection.init();
firstNode = tableReadConnection.readAll();
}
String secondNode = null;
try (TextReadConnection tableReadConnection = ((TextDataSource<?>) second).openReadConnection()) {
tableReadConnection.init();
secondNode = tableReadConnection.readAll();
}
equalsCheck.accept(firstNode, secondNode);
}
}
}

View file

@ -1,52 +0,0 @@
package test;
import io.xpipe.app.ext.DataSourceProviders;
import io.xpipe.core.impl.FileStore;
import io.xpipe.core.source.DataSource;
import io.xpipe.core.store.DataStore;
import io.xpipe.core.store.StreamDataStore;
import lombok.SneakyThrows;
import java.util.ArrayList;
import java.util.List;
import java.util.function.Supplier;
public class TestSourcesDatabase {
public static List<Supplier<DataSource<?>>> TEST_SOURCES = new ArrayList<>();
public static List<Supplier<DataStore>> TEST_STORES = new ArrayList<>();
private static StreamDataStore resource(String name) {
return FileStore.local(System.getProperty("user.dir") + "/src/test/resources/" + name);
}
private static void addStore(Supplier<DataStore> source) {
TEST_STORES.add(source);
}
private static void addSource(Supplier<DataSource<?>> source) {
TEST_SOURCES.add(source);
}
@SneakyThrows
private static void addDefault(String name, Supplier<DataStore> store) {
TEST_STORES.add(store);
TEST_SOURCES.add(() -> {
try {
return DataSourceProviders.byName(name).orElseThrow().createDefaultSource(store.get());
} catch (Exception e) {
throw new RuntimeException("Unknown provider " + name);
}
});
}
public static void init() {
addDefault("json", () -> resource("example_2.json"));
addDefault("csv", () -> resource("business-price-indexes-june-2022-quarter-csv.csv"));
addDefault("csv", () -> resource("machine-readable-business-employment-data-mar-2022-quarter.csv"));
addDefault("text", () -> resource("sample-2mb-text-file.txt"));
addDefault("xml-table", () -> resource("table.xml"));
addDefault("xml", () -> resource("books.xml"));
}
}

View file

@ -1,132 +0,0 @@
<?xml version="1.0"?>
<catalog>
<book id="bk101">
<author>Gambardella, Matthew</author>
<title>XML Developer's Guide</title>
<genre>Computer</genre>
<price>44.95</price>
<publish_date>2000-10-01</publish_date>
<description>An in-depth look at creating applications
with XML.
</description>
</book>
<book id="bk102">
<author>Ralls, Kim</author>
<title>Midnight Rain</title>
<genre>Fantasy</genre>
<price>5.95</price>
<publish_date>2000-12-16</publish_date>
<description>A former architect battles corporate zombies,
an evil sorceress, and her own childhood to become queen
of the world.
</description>
</book>
<book id="bk103">
<author>Corets, Eva</author>
<title>Maeve Ascendant</title>
<genre>Fantasy</genre>
<price>5.95</price>
<publish_date>2000-11-17</publish_date>
<description>After the collapse of a nanotechnology
society in England, the young survivors lay the
foundation for a new society.
</description>
</book>
<book id="bk104">
<author>Corets, Eva</author>
<title>Oberon's Legacy</title>
<genre>Fantasy</genre>
<price>5.95</price>
<publish_date>2001-03-10</publish_date>
<description>In post-apocalypse England, the mysterious
agent known only as Oberon helps to create a new life
for the inhabitants of London. Sequel to Maeve
Ascendant.
</description>
</book>
<book id="bk105">
<author>Corets, Eva</author>
<title>The Sundered Grail</title>
<genre>Fantasy</genre>
<price>5.95</price>
<publish_date>2001-09-10</publish_date>
<description>The two daughters of Maeve, half-sisters,
battle one another for control of England. Sequel to
Oberon's Legacy.
</description>
</book>
<book id="bk106">
<author>Randall, Cynthia</author>
<title>Lover Birds</title>
<genre>Romance</genre>
<price>4.95</price>
<publish_date>2000-09-02</publish_date>
<description>When Carla meets Paul at an ornithology
conference, tempers fly as feathers get ruffled.
</description>
</book>
<book id="bk107">
<author>Thurman, Paula</author>
<title>Splish Splash</title>
<genre>Romance</genre>
<price>4.95</price>
<publish_date>2000-11-02</publish_date>
<description>A deep sea diver finds true love twenty
thousand leagues beneath the sea.
</description>
</book>
<book id="bk108">
<author>Knorr, Stefan</author>
<title>Creepy Crawlies</title>
<genre>Horror</genre>
<price>4.95</price>
<publish_date>2000-12-06</publish_date>
<description>An anthology of horror stories about roaches,
centipedes, scorpions and other insects.
</description>
</book>
<book id="bk109">
<author>Kress, Peter</author>
<title>Paradox Lost</title>
<genre>Science Fiction</genre>
<price>6.95</price>
<publish_date>2000-11-02</publish_date>
<description>After an inadvertant trip through a Heisenberg
Uncertainty Device, James Salway discovers the problems
of being quantum.
</description>
</book>
<book id="bk110">
<author>O'Brien, Tim</author>
<title>Microsoft .NET: The Programming Bible</title>
<genre>Computer</genre>
<price>36.95</price>
<publish_date>2000-12-09</publish_date>
<description>Microsoft's .NET initiative is explored in
detail in this deep programmer's reference.
</description>
</book>
<book id="bk111">
<author>O'Brien, Tim</author>
<title>MSXML3: A Comprehensive Guide</title>
<genre>Computer</genre>
<price>36.95</price>
<publish_date>2000-12-01</publish_date>
<description>The Microsoft MSXML3 parser is covered in
detail, with attention to XML DOM interfaces, XSLT processing,
SAX and more.
</description>
</book>
<book id="bk112">
<author>Galos, Mike</author>
<title>Visual Studio 7: A Comprehensive Guide</title>
<genre>Computer</genre>
<price>49.95</price>
<publish_date>2001-04-16</publish_date>
<description>Microsoft Visual Studio 7 is explored in depth,
looking at how Visual Basic, Visual C++, C#, and ASP+ are
integrated into a comprehensive development
environment.
</description>
</book>
</catalog>

View file

@ -1,38 +0,0 @@
{
"quiz": {
"sport": {
"q1": {
"question": "Which one is correct team name in NBA?",
"options": [
"New York Bulls",
"Los Angeles Kings",
"Golden State Warriros",
"Huston Rocket"
],
"answer": "Huston Rocket"
}
},
"maths": {
"q1": {
"question": "5 + 7 = ?",
"options": [
"10",
"11",
"12",
"13"
],
"answer": "12"
},
"q2": {
"question": "12 - 8 = ?",
"options": [
"1",
"2",
"3",
"4"
],
"answer": "4"
}
}
}
}

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -23,6 +23,7 @@ project.ext {
ci = System.getenv('CI') != null
os = org.gradle.internal.os.OperatingSystem.current()
allExtensions = Arrays.stream(file("$rootDir/ext").list())
.filter(s -> file("$rootDir/ext/$s/build.gradle").exists())
.filter(s -> !s.equals('csv') && !s.equals('office') && !s.equals('pdx') && !s.equals('jackson') && !s.equals('collections'))
.map(l -> project(":$l")).toList()
fullVersion = file("$rootDir/private_files.txt").exists()

View file

@ -5,8 +5,10 @@ include 'core'
include 'beacon'
for (def ext : file("ext").list()) {
include "$ext"
project(":$ext").projectDir = file("ext/$ext")
if (file("ext/$ext/build.gradle").exists()) {
include "$ext"
project(":$ext").projectDir = file("ext/$ext")
}
}
include 'app'