Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/mac.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
strategy:
matrix:
java: [ '8', '11', '17', '21' ]
os: [ macos-10.15 ]
os: [ macos-13 ]

steps:
- uses: actions/checkout@v2
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
/target/
*.orig
*/nb-configuration.xml
*/dependency-reduced-pom.xml
*/nbactions.xml
/html4j-maven-plugin/src/test/resources/org/netbeans/html/mojo/gradle*/build/*
/html4j-maven-plugin/src/test/resources/org/netbeans/html/mojo/gradle*/.gradle/*
Expand Down
37 changes: 23 additions & 14 deletions boot-agent-test/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
</parent>
<artifactId>boot-agent-test</artifactId>
<packaging>jar</packaging>
<name>Dynamic Boot Test</name>
<name>Agent Boot Test</name>
<properties>
<skipTests>${skipJavaFXTests}</skipTests>
</properties>
Expand All @@ -48,6 +48,23 @@
<skip>true</skip>
</configuration>
</plugin>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>properties</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.2.5</version>
<configuration>
<argLine>-javaagent:${org.netbeans.html:net.java.html.boot:jar}</argLine>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
Expand All @@ -70,27 +87,19 @@
<scope>test</scope>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.netbeans.api</groupId>
<artifactId>org-openide-util-lookup</artifactId>
<scope>test</scope>
<type>jar</type>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>net.java.html.boot.fx</artifactId>
<artifactId>net.java.html.boot.script</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-web</artifactId>
<scope>test</scope>
<groupId>org.graalvm.js</groupId>
<artifactId>js</artifactId>
</dependency>
<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm</artifactId>
<scope>test</scope>
<groupId>org.graalvm.js</groupId>
<artifactId>js-scriptengine</artifactId>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/**
* 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 org.netbeans.html.bootagent;

import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
import net.java.html.boot.script.Scripts;
import static org.testng.AssertJUnit.assertNotNull;
import org.testng.annotations.Factory;

/**
*
* @author Jaroslav Tulach
*/
public class AgentBootstrapTest {
public AgentBootstrapTest() {
}

@Factory
public static Object[] compatibilityTests() throws Exception {
var presenter = Scripts.newPresenter().build();
assertNotNull("Presenter has been initialized", presenter);

var res = new ArrayList<Object>();

Class[] arr = new Class[] { JavaScriptBodyTst.class };
for (Class c : arr) {
for (Method m : c.getDeclaredMethods()) {
if ((m.getModifiers() & Modifier.PUBLIC) != 0) {
res.add(new KOFx(presenter, m));
}
}
}
return res.toArray();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,15 @@
*/
package org.netbeans.html.bootagent;

import java.util.Arrays;
import net.java.html.js.JavaScriptBody;
import net.java.html.js.JavaScriptResource;

/**
*
* @author Jaroslav Tulach
*/
@JavaScriptResource("empty.js")
public class JavaScriptBodyTst {

public JavaScriptBodyTst() {
Expand All @@ -33,7 +36,56 @@ public void assert42() {
int v = mul(7, 6);
assert v == 42 : "Really 42: " + v;
}

public void assertEmptySymbolDefined() {
assert Boolean.TRUE.equals(eval("empty")) : "empty.js should defined empty global symbol";
}
public void assertEmpty2SymbolDefined() {
MultiResource.loadIt();
assert Boolean.TRUE.equals(eval("empty2")) : "empty.js should defined empty global symbol";
}
public void assertEmpty3SymbolDefined() {
MultiResource.loadIt();
assert Boolean.TRUE.equals(eval("empty3")) : "empty.js should defined empty global symbol";
}

public void assertJavaScriptBodyAnnotationPresentInRuntime() throws Exception {
var mul = JavaScriptBodyTst.class.getDeclaredMethod("mul", int.class, int.class);
var ann = mul.getAnnotation(JavaScriptBody.class);
assert ann != null : "JavaScriptBody annotation must be found in runtime";
assert ann.args().length == 2 : "Two arguments";
assert "x".equals(ann.args()[0]) : "First argument: " + Arrays.toString(ann.args());
assert "y".equals(ann.args()[1]) : "Second argument: " + Arrays.toString(ann.args());
assert "return x * y;".equals(ann.body()) : "Body argument: " + ann.body();
}

private static void assertResource(JavaScriptResource ann, String file) {
assert ann != null : "JavaScriptResource annotation must be found in runtime";
assert file.equals(ann.value()) : "Expecting " + file + " but got " + ann.value();
}

public void assertJavaScriptResourceAnnotationPresentInRuntime() throws Exception {
var ann = JavaScriptBodyTst.class.getAnnotation(JavaScriptResource.class);
assertResource(ann, "empty.js");
}

public void assertJavaScriptResourceGroupAnnotationPresentInRuntime() throws Exception {
var ann = MultiResource.class.getAnnotation(JavaScriptResource.Group.class);
assert ann != null : "JavaScriptResource.Group annotation must be found in runtime";
assert ann.value().length == 2 : "Two empty*.js resources, was: " + Arrays.toString(ann.value());
}

@JavaScriptBody(args = { "x", "y" }, body = "return x * y;")
private static native int mul(int x, int y);

@JavaScriptBody(args = { "code" }, body = "return eval(code);")
private static native Object eval(String code);

@JavaScriptResource("empty_2.js")
@JavaScriptResource("empty_3.js")
static final class MultiResource {
@JavaScriptBody(args = {}, body = "")
static void loadIt() {
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import javafx.application.Platform;
import org.netbeans.html.boot.spi.Fn;
import org.testng.IHookCallBack;
import org.testng.IHookable;
Expand Down Expand Up @@ -51,8 +50,7 @@ public String getTestName() {
@Test
public synchronized void executeTest() throws Exception {
if (result == null) {
Platform.runLater(this);
wait();
run();
}
if (result instanceof Exception) {
throw (Exception)result;
Expand All @@ -77,7 +75,7 @@ public synchronized void run() {
Throwable r = ex.getTargetException();
if (r instanceof InterruptedException) {
notify = false;
Platform.runLater(this);
run();
return;
}
result = r;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*

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.

*/
this.empty = true;
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*

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.

*/
this.empty2 = true;
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*

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.

*/
this.empty3 = true;
6 changes: 6 additions & 0 deletions boot-fx/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@
<artifactId>net.java.html.boot</artifactId>
<version>${project.version}</version>
<type>jar</type>
<exclusions>
<exclusion>
<groupId>org.ow2.asm</groupId>
<artifactId>asm</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.testng</groupId>
Expand Down
6 changes: 6 additions & 0 deletions boot-script/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,12 @@
<artifactId>net.java.html.boot</artifactId>
<version>${project.version}</version>
<type>jar</type>
<exclusions>
<exclusion>
<groupId>org.ow2.asm</groupId>
<artifactId>asm</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.testng</groupId>
Expand Down
30 changes: 28 additions & 2 deletions boot/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,41 @@
</instructions>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.6.0</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<relocations>
<relocation>
<pattern>org.objectweb.asm</pattern>
<shadedPattern>org.netbeans.html.boot.asm5</shadedPattern>
</relocation>
</relocations>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm</artifactId>
<type>jar</type>
<scope>provided</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.testng</groupId>
Expand Down
6 changes: 3 additions & 3 deletions boot/src/main/java/net/java/html/boot/BrowserBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,9 @@ private BrowserBuilder(Object[] context) {
* {@link Contexts#newBuilder(java.lang.Object...) created}
* and can influence the selection
* of available technologies
* (like {@link org.netbeans.html.json.spi.Technology},
* {@link org.netbeans.html.json.spi.Transfer} or
* {@link org.netbeans.html.json.spi.WSTransfer}) by name.
* (like {@code org.netbeans.html.json.spi.Technology},
* {@code org.netbeans.html.json.spi.Transfer} or
* {@code org.netbeans.html.json.spi.WSTransfer}) by name.
*
* @param context any instances that should be available to the builder -
* implementation dependant
Expand Down
Loading
Loading