All tests in OSGi mode are executed (as we add new Equinox Hook), they however fail
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/equinox-agentclass-hook/pom.xml Sat Jan 04 21:47:47 2014 +0100
1.3 @@ -0,0 +1,41 @@
1.4 +<?xml version="1.0" encoding="UTF-8"?>
1.5 +<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">
1.6 + <modelVersion>4.0.0</modelVersion>
1.7 + <parent>
1.8 + <groupId>org.netbeans.html</groupId>
1.9 + <artifactId>pom</artifactId>
1.10 + <version>0.7-SNAPSHOT</version>
1.11 + </parent>
1.12 + <artifactId>equinox-agentclass-hook</artifactId>
1.13 + <packaging>bundle</packaging>
1.14 + <build>
1.15 + <plugins>
1.16 + <plugin>
1.17 + <groupId>org.apache.felix</groupId>
1.18 + <artifactId>maven-bundle-plugin</artifactId>
1.19 + <configuration>
1.20 + <instructions>
1.21 + <Fragment-Host>org.eclipse.osgi;bundle-version="[3.8.0,4.0)"</Fragment-Host>
1.22 + <Import-Package></Import-Package>
1.23 + </instructions>
1.24 + </configuration>
1.25 + </plugin>
1.26 + <plugin>
1.27 + <groupId>org.apache.maven.plugins</groupId>
1.28 + <artifactId>maven-compiler-plugin</artifactId>
1.29 + <version>2.3.2</version>
1.30 + <configuration>
1.31 + <source>1.5</source>
1.32 + <target>1.5</target>
1.33 + </configuration>
1.34 + </plugin>
1.35 + </plugins>
1.36 + </build>
1.37 + <dependencies>
1.38 + <dependency>
1.39 + <groupId>org.eclipse</groupId>
1.40 + <artifactId>org.eclipse.osgi</artifactId>
1.41 + <version>3.8.0.v20120529-1548</version>
1.42 + </dependency>
1.43 + </dependencies>
1.44 +</project>
1.45 \ No newline at end of file
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2.2 +++ b/equinox-agentclass-hook/src/main/java/org/netbeans/html/equinox/agentclass/AgentHook.java Sat Jan 04 21:47:47 2014 +0100
2.3 @@ -0,0 +1,162 @@
2.4 +/**
2.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
2.6 + *
2.7 + * Copyright 2013-2013 Oracle and/or its affiliates. All rights reserved.
2.8 + *
2.9 + * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
2.10 + * Other names may be trademarks of their respective owners.
2.11 + *
2.12 + * The contents of this file are subject to the terms of either the GNU
2.13 + * General Public License Version 2 only ("GPL") or the Common
2.14 + * Development and Distribution License("CDDL") (collectively, the
2.15 + * "License"). You may not use this file except in compliance with the
2.16 + * License. You can obtain a copy of the License at
2.17 + * http://www.netbeans.org/cddl-gplv2.html
2.18 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
2.19 + * specific language governing permissions and limitations under the
2.20 + * License. When distributing the software, include this License Header
2.21 + * Notice in each file and include the License file at
2.22 + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
2.23 + * particular file as subject to the "Classpath" exception as provided
2.24 + * by Oracle in the GPL Version 2 section of the License file that
2.25 + * accompanied this code. If applicable, add the following below the
2.26 + * License Header, with the fields enclosed by brackets [] replaced by
2.27 + * your own identifying information:
2.28 + * "Portions Copyrighted [year] [name of copyright owner]"
2.29 + *
2.30 + * Contributor(s):
2.31 + *
2.32 + * The Original Software is NetBeans. The Initial Developer of the Original
2.33 + * Software is Oracle. Portions Copyright 2013-2013 Oracle. All Rights Reserved.
2.34 + *
2.35 + * If you wish your version of this file to be governed by only the CDDL
2.36 + * or only the GPL Version 2, indicate your decision by adding
2.37 + * "[Contributor] elects to include this software in this distribution
2.38 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
2.39 + * single choice of license, a recipient has the option to distribute
2.40 + * your version of this file under either the CDDL, the GPL Version 2 or
2.41 + * to extend the choice of license to its licensees as provided above.
2.42 + * However, if you add GPL Version 2 code and therefore, elected the GPL
2.43 + * Version 2 license, then the option applies only if the new code is
2.44 + * made subject to such option by the copyright holder.
2.45 + */
2.46 +package org.netbeans.html.equinox.agentclass;
2.47 +
2.48 +import java.lang.instrument.IllegalClassFormatException;
2.49 +import java.security.ProtectionDomain;
2.50 +import java.util.ArrayList;
2.51 +
2.52 +import org.eclipse.osgi.baseadaptor.BaseData;
2.53 +import org.eclipse.osgi.baseadaptor.HookConfigurator;
2.54 +import org.eclipse.osgi.baseadaptor.HookRegistry;
2.55 +import org.eclipse.osgi.baseadaptor.bundlefile.BundleEntry;
2.56 +import org.eclipse.osgi.baseadaptor.hooks.ClassLoadingHook;
2.57 +import org.eclipse.osgi.baseadaptor.loader.BaseClassLoader;
2.58 +import org.eclipse.osgi.baseadaptor.loader.ClasspathEntry;
2.59 +import org.eclipse.osgi.baseadaptor.loader.ClasspathManager;
2.60 +import org.eclipse.osgi.framework.adaptor.BundleProtectionDomain;
2.61 +import org.eclipse.osgi.framework.adaptor.BundleWatcher;
2.62 +import org.eclipse.osgi.framework.adaptor.ClassLoaderDelegate;
2.63 +import org.osgi.framework.Bundle;
2.64 +import org.osgi.framework.BundleContext;
2.65 +import org.osgi.framework.wiring.BundleWiring;
2.66 +
2.67 +public class AgentHook implements HookConfigurator, BundleWatcher, ClassLoadingHook {
2.68 + private boolean all;
2.69 +
2.70 + @Override
2.71 + public void addHooks(HookRegistry hookRegistry) {
2.72 + Thread.dumpStack();
2.73 + hookRegistry.addWatcher(this);
2.74 + hookRegistry.addClassLoadingHook(this);
2.75 + }
2.76 +
2.77 + @Override
2.78 + public void watchBundle(Bundle bundle, int type) {
2.79 + if (!all) {
2.80 + BundleContext c = bundle.getBundleContext();
2.81 + if (c != null) {
2.82 + Bundle[] arr = bundle.getBundleContext().getBundles();
2.83 + for (Bundle b : arr) {
2.84 + agentBundle(b);
2.85 + }
2.86 + all = true;
2.87 + }
2.88 + }
2.89 + if (type == BundleWatcher.END_ACTIVATION) {
2.90 + agentBundle(bundle);
2.91 + }
2.92 + }
2.93 +
2.94 + private void agentBundle(Bundle bundle) {
2.95 + String agentClass = (String)bundle.getHeaders().get("Agent-Class");
2.96 + if (agentClass != null) {
2.97 + Class<?> agent;
2.98 + try {
2.99 + agent = bundle.loadClass(agentClass);
2.100 + NbInstrumentation.registerAgent(agent.getClassLoader(), agent.getName());
2.101 + } catch (ClassNotFoundException e) {
2.102 + throw new IllegalStateException(e);
2.103 + }
2.104 + }
2.105 + }
2.106 +
2.107 + @Override
2.108 + public byte[] processClass(String name, byte[] bytes,
2.109 + ClasspathEntry ce, BundleEntry entry,
2.110 + ClasspathManager manager) {
2.111 + final BaseData bd = ce.getBaseData();
2.112 + if (bd == null) {
2.113 + return bytes;
2.114 + }
2.115 + final Bundle b = bd.getBundle();
2.116 + if (b == null) {
2.117 + return bytes;
2.118 + }
2.119 + BundleWiring w = (BundleWiring)b.adapt(BundleWiring.class);
2.120 + if (w == null) {
2.121 + return bytes;
2.122 + }
2.123 + ClassLoader loader = w.getClassLoader();
2.124 + try {
2.125 + return NbInstrumentation.patchByteCode(loader, name, ce.getDomain(), bytes);
2.126 + } catch (IllegalClassFormatException e) {
2.127 + return bytes;
2.128 + }
2.129 + }
2.130 +
2.131 + @Override
2.132 + public boolean addClassPathEntry(ArrayList cpEntries,
2.133 + String cp, ClasspathManager hostmanager, BaseData sourcedata,
2.134 + ProtectionDomain sourcedomain) {
2.135 + // TODO Auto-generated method stub
2.136 + return false;
2.137 + }
2.138 +
2.139 + @Override
2.140 + public String findLibrary(BaseData data, String libName) {
2.141 + // TODO Auto-generated method stub
2.142 + return null;
2.143 + }
2.144 +
2.145 + @Override
2.146 + public ClassLoader getBundleClassLoaderParent() {
2.147 + // TODO Auto-generated method stub
2.148 + return null;
2.149 + }
2.150 +
2.151 + @Override
2.152 + public BaseClassLoader createClassLoader(ClassLoader parent,
2.153 + ClassLoaderDelegate delegate, BundleProtectionDomain domain,
2.154 + BaseData data, String[] bundleclasspath) {
2.155 + // TODO Auto-generated method stub
2.156 + return null;
2.157 + }
2.158 +
2.159 + @Override
2.160 + public void initializedClassLoader(BaseClassLoader baseClassLoader,
2.161 + BaseData data) {
2.162 + // TODO Auto-generated method stub
2.163 +
2.164 + }
2.165 +}
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
3.2 +++ b/equinox-agentclass-hook/src/main/java/org/netbeans/html/equinox/agentclass/NbInstrumentation.java Sat Jan 04 21:47:47 2014 +0100
3.3 @@ -0,0 +1,214 @@
3.4 +/**
3.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3.6 + *
3.7 + * Copyright 2013-2013 Oracle and/or its affiliates. All rights reserved.
3.8 + *
3.9 + * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
3.10 + * Other names may be trademarks of their respective owners.
3.11 + *
3.12 + * The contents of this file are subject to the terms of either the GNU
3.13 + * General Public License Version 2 only ("GPL") or the Common
3.14 + * Development and Distribution License("CDDL") (collectively, the
3.15 + * "License"). You may not use this file except in compliance with the
3.16 + * License. You can obtain a copy of the License at
3.17 + * http://www.netbeans.org/cddl-gplv2.html
3.18 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
3.19 + * specific language governing permissions and limitations under the
3.20 + * License. When distributing the software, include this License Header
3.21 + * Notice in each file and include the License file at
3.22 + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
3.23 + * particular file as subject to the "Classpath" exception as provided
3.24 + * by Oracle in the GPL Version 2 section of the License file that
3.25 + * accompanied this code. If applicable, add the following below the
3.26 + * License Header, with the fields enclosed by brackets [] replaced by
3.27 + * your own identifying information:
3.28 + * "Portions Copyrighted [year] [name of copyright owner]"
3.29 + *
3.30 + * Contributor(s):
3.31 + *
3.32 + * The Original Software is NetBeans. The Initial Developer of the Original
3.33 + * Software is Oracle. Portions Copyright 2013-2013 Oracle. All Rights Reserved.
3.34 + *
3.35 + * If you wish your version of this file to be governed by only the CDDL
3.36 + * or only the GPL Version 2, indicate your decision by adding
3.37 + * "[Contributor] elects to include this software in this distribution
3.38 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
3.39 + * single choice of license, a recipient has the option to distribute
3.40 + * your version of this file under either the CDDL, the GPL Version 2 or
3.41 + * to extend the choice of license to its licensees as provided above.
3.42 + * However, if you add GPL Version 2 code and therefore, elected the GPL
3.43 + * Version 2 license, then the option applies only if the new code is
3.44 + * made subject to such option by the copyright holder.
3.45 + */
3.46 +
3.47 +package org.netbeans.html.equinox.agentclass;
3.48 +
3.49 +import java.lang.instrument.ClassDefinition;
3.50 +import java.lang.instrument.ClassFileTransformer;
3.51 +import java.lang.instrument.IllegalClassFormatException;
3.52 +import java.lang.instrument.Instrumentation;
3.53 +import java.lang.instrument.UnmodifiableClassException;
3.54 +import java.lang.reflect.InvocationTargetException;
3.55 +import java.lang.reflect.Method;
3.56 +import java.security.ProtectionDomain;
3.57 +import java.util.Collection;
3.58 +import java.util.HashSet;
3.59 +import java.util.List;
3.60 +import java.util.Set;
3.61 +import java.util.concurrent.CopyOnWriteArrayList;
3.62 +import java.util.jar.JarFile;
3.63 +import java.util.logging.Level;
3.64 +import java.util.logging.Logger;
3.65 +
3.66 +/**
3.67 + *
3.68 + * @author Jaroslav Tulach <jtulach@netbeans.org>
3.69 + */
3.70 +final class NbInstrumentation implements Instrumentation {
3.71 + private static final Logger LOG = Logger.getLogger(NbInstrumentation.class.getName());
3.72 + private static final Object LOCK = new Object();
3.73 + private static volatile Collection<NbInstrumentation> ACTIVE;
3.74 +
3.75 + private final List<ClassFileTransformer> transformers = new CopyOnWriteArrayList<ClassFileTransformer>();
3.76 + private static final ThreadLocal<Boolean> IN = new ThreadLocal<Boolean>();
3.77 +
3.78 + static NbInstrumentation registerAgent(ClassLoader l, String agentClassName) {
3.79 + try {
3.80 + return registerImpl(agentClassName, l);
3.81 + } catch (Throwable ex) {
3.82 + LOG.log(Level.WARNING, "Cannot register " + agentClassName, ex);
3.83 + return null;
3.84 + }
3.85 + }
3.86 + static void unregisterAgent(NbInstrumentation instr) {
3.87 + synchronized (LOCK) {
3.88 + if (ACTIVE != null) {
3.89 + Collection<NbInstrumentation> clone = new HashSet<NbInstrumentation>();
3.90 + clone.addAll(ACTIVE);
3.91 + clone.remove(instr);
3.92 + ACTIVE = clone;
3.93 + }
3.94 + }
3.95 + }
3.96 + private static NbInstrumentation registerImpl(String agentClassName, ClassLoader l) throws ClassNotFoundException, IllegalArgumentException, NoSuchMethodException, SecurityException, IllegalAccessException, InvocationTargetException {
3.97 + final NbInstrumentation inst = new NbInstrumentation();
3.98 + synchronized (LOCK) {
3.99 + if (ACTIVE == null) {
3.100 + ACTIVE = new HashSet<NbInstrumentation>();
3.101 + } else {
3.102 + Set<NbInstrumentation> s = new HashSet<NbInstrumentation>();
3.103 + s.addAll(ACTIVE);
3.104 + ACTIVE = s;
3.105 + }
3.106 + ACTIVE.add(inst);
3.107 + }
3.108 + Class<?> agentClass = Class.forName(agentClassName, true, l);
3.109 + try {
3.110 + Method m = agentClass.getMethod("agentmain", String.class, Instrumentation.class); // NOI18N
3.111 + m.invoke(null, "", inst);
3.112 + } catch (NoSuchMethodException ex) {
3.113 + Method m = agentClass.getMethod("agentmain", String.class); // NOI18N
3.114 + m.invoke(null, "");
3.115 + }
3.116 + return inst;
3.117 + }
3.118 +
3.119 + public static byte[] patchByteCode(ClassLoader l, String className, ProtectionDomain pd, byte[] arr) throws IllegalClassFormatException {
3.120 + if (ACTIVE == null) {
3.121 + return arr;
3.122 + }
3.123 + if (Boolean.TRUE.equals(IN.get())) {
3.124 + return arr;
3.125 + }
3.126 + try {
3.127 + IN.set(Boolean.TRUE);
3.128 + for (NbInstrumentation inst : ACTIVE) {
3.129 + for (ClassFileTransformer t : inst.transformers) {
3.130 + arr = t.transform(l, className, null, pd, arr);
3.131 + }
3.132 + }
3.133 + } finally {
3.134 + IN.set(null);
3.135 + }
3.136 + return arr;
3.137 + }
3.138 +
3.139 + //
3.140 + // Instrumentation methods
3.141 + //
3.142 +
3.143 + @Override
3.144 + public void addTransformer(ClassFileTransformer transformer, boolean canRetransform) {
3.145 + transformers.add(transformer);
3.146 + }
3.147 +
3.148 + @Override
3.149 + public void addTransformer(ClassFileTransformer transformer) {
3.150 + transformers.add(transformer);
3.151 + }
3.152 +
3.153 + @Override
3.154 + public boolean removeTransformer(ClassFileTransformer transformer) {
3.155 + return transformers.remove(transformer);
3.156 + }
3.157 +
3.158 + @Override
3.159 + public boolean isRetransformClassesSupported() {
3.160 + return false;
3.161 + }
3.162 +
3.163 + @Override
3.164 + public void retransformClasses(Class<?>... classes) throws UnmodifiableClassException {
3.165 + throw new UnmodifiableClassException();
3.166 + }
3.167 +
3.168 + @Override
3.169 + public boolean isRedefineClassesSupported() {
3.170 + return false;
3.171 + }
3.172 +
3.173 + @Override
3.174 + public void redefineClasses(ClassDefinition... definitions) throws ClassNotFoundException, UnmodifiableClassException {
3.175 + throw new UnmodifiableClassException();
3.176 + }
3.177 +
3.178 + @Override
3.179 + public boolean isModifiableClass(Class<?> theClass) {
3.180 + return false;
3.181 + }
3.182 +
3.183 + @Override
3.184 + public Class[] getAllLoadedClasses() {
3.185 + return new Class[0];
3.186 + }
3.187 +
3.188 + @Override
3.189 + public Class[] getInitiatedClasses(ClassLoader loader) {
3.190 + return new Class[0];
3.191 + }
3.192 +
3.193 + @Override
3.194 + public long getObjectSize(Object objectToSize) {
3.195 + return 42;
3.196 + }
3.197 +
3.198 + @Override
3.199 + public void appendToBootstrapClassLoaderSearch(JarFile jarfile) {
3.200 + }
3.201 +
3.202 + @Override
3.203 + public void appendToSystemClassLoaderSearch(JarFile jarfile) {
3.204 + throw new UnsupportedOperationException();
3.205 + }
3.206 +
3.207 + @Override
3.208 + public boolean isNativeMethodPrefixSupported() {
3.209 + return false;
3.210 + }
3.211 +
3.212 + @Override
3.213 + public void setNativeMethodPrefix(ClassFileTransformer transformer, String prefix) {
3.214 + throw new UnsupportedOperationException();
3.215 + }
3.216 +
3.217 +}
4.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
4.2 +++ b/equinox-agentclass-hook/src/main/resources/hookconfigurators.properties Sat Jan 04 21:47:47 2014 +0100
4.3 @@ -0,0 +1,44 @@
4.4 +#
4.5 +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
4.6 +#
4.7 +# Copyright 2013-2013 Oracle and/or its affiliates. All rights reserved.
4.8 +#
4.9 +# Oracle and Java are registered trademarks of Oracle and/or its affiliates.
4.10 +# Other names may be trademarks of their respective owners.
4.11 +#
4.12 +# The contents of this file are subject to the terms of either the GNU
4.13 +# General Public License Version 2 only ("GPL") or the Common
4.14 +# Development and Distribution License("CDDL") (collectively, the
4.15 +# "License"). You may not use this file except in compliance with the
4.16 +# License. You can obtain a copy of the License at
4.17 +# http://www.netbeans.org/cddl-gplv2.html
4.18 +# or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
4.19 +# specific language governing permissions and limitations under the
4.20 +# License. When distributing the software, include this License Header
4.21 +# Notice in each file and include the License file at
4.22 +# nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
4.23 +# particular file as subject to the "Classpath" exception as provided
4.24 +# by Oracle in the GPL Version 2 section of the License file that
4.25 +# accompanied this code. If applicable, add the following below the
4.26 +# License Header, with the fields enclosed by brackets [] replaced by
4.27 +# your own identifying information:
4.28 +# "Portions Copyrighted [year] [name of copyright owner]"
4.29 +#
4.30 +# Contributor(s):
4.31 +#
4.32 +# The Original Software is NetBeans. The Initial Developer of the Original
4.33 +# Software is Oracle. Portions Copyright 2013-2013 Oracle. All Rights Reserved.
4.34 +#
4.35 +# If you wish your version of this file to be governed by only the CDDL
4.36 +# or only the GPL Version 2, indicate your decision by adding
4.37 +# "[Contributor] elects to include this software in this distribution
4.38 +# under the [CDDL or GPL Version 2] license." If you do not indicate a
4.39 +# single choice of license, a recipient has the option to distribute
4.40 +# your version of this file under either the CDDL, the GPL Version 2 or
4.41 +# to extend the choice of license to its licensees as provided above.
4.42 +# However, if you add GPL Version 2 code and therefore, elected the GPL
4.43 +# Version 2 license, then the option applies only if the new code is
4.44 +# made subject to such option by the copyright holder.
4.45 +#
4.46 +
4.47 +hook.configurators=org.netbeans.equinox.agentclass.AgentHook
5.1 --- a/json-tck/src/main/java/net/java/html/json/tests/KnockoutTest.java Sat Jan 04 16:22:11 2014 +0100
5.2 +++ b/json-tck/src/main/java/net/java/html/json/tests/KnockoutTest.java Sat Jan 04 21:47:47 2014 +0100
5.3 @@ -50,6 +50,7 @@
5.4 import net.java.html.json.Models;
5.5 import net.java.html.json.Property;
5.6 import org.apidesign.html.json.tck.KOTest;
5.7 +import org.apidesign.html.json.tck.KnockoutTCK;
5.8
5.9 /**
5.10 *
6.1 --- a/json-tck/src/main/java/net/java/html/json/tests/Utils.java Sat Jan 04 16:22:11 2014 +0100
6.2 +++ b/json-tck/src/main/java/net/java/html/json/tests/Utils.java Sat Jan 04 21:47:47 2014 +0100
6.3 @@ -43,6 +43,7 @@
6.4 package net.java.html.json.tests;
6.5
6.6 import java.net.URI;
6.7 +import java.util.Collections;
6.8 import java.util.Map;
6.9 import java.util.ServiceLoader;
6.10 import net.java.html.BrwsrCtx;
6.11 @@ -52,12 +53,18 @@
6.12 *
6.13 * @author Jaroslav Tulach <jtulach@netbeans.org>
6.14 */
6.15 -final class Utils {
6.16 +public final class Utils {
6.17 + private static KnockoutTCK instantiatedTCK;
6.18 +
6.19 private Utils() {
6.20 }
6.21 +
6.22 + public static void registerTCK(KnockoutTCK tck) {
6.23 + instantiatedTCK = tck;
6.24 + }
6.25
6.26 static BrwsrCtx newContext(Class<?> clazz) {
6.27 - for (KnockoutTCK tck : ServiceLoader.load(KnockoutTCK.class, cl(clazz))) {
6.28 + for (KnockoutTCK tck : tcks(clazz)) {
6.29 BrwsrCtx c = tck.createContext();
6.30 if (c != null) {
6.31 return c;
6.32 @@ -66,7 +73,7 @@
6.33 throw new AssertionError("Can't find appropriate Context in ServiceLoader!");
6.34 }
6.35 static Object createObject(Map<String,Object> values, Class<?> clazz) {
6.36 - for (KnockoutTCK tck : ServiceLoader.load(KnockoutTCK.class, cl(clazz))) {
6.37 + for (KnockoutTCK tck : tcks(clazz)) {
6.38 Object o = tck.createJSON(values);
6.39 if (o != null) {
6.40 return o;
6.41 @@ -77,11 +84,18 @@
6.42 static Object executeScript(Class<?> clazz,
6.43 String script, Object... arguments
6.44 ) throws Exception {
6.45 - for (KnockoutTCK tck : ServiceLoader.load(KnockoutTCK.class, cl(clazz))) {
6.46 + for (KnockoutTCK tck : tcks(clazz)) {
6.47 return tck.executeScript(script, arguments);
6.48 }
6.49 throw new AssertionError("Can't find appropriate Context in ServiceLoader!");
6.50 }
6.51 +
6.52 + private static Iterable<KnockoutTCK> tcks(Class<?> clazz) {
6.53 + if (instantiatedTCK != null) {
6.54 + return Collections.singleton(instantiatedTCK);
6.55 + }
6.56 + return ServiceLoader.load(KnockoutTCK.class, cl(clazz));
6.57 + }
6.58
6.59 static Object exposeHTML(Class<?> clazz, String html) throws Exception {
6.60 String s =
6.61 @@ -98,7 +112,7 @@
6.62
6.63 static String prepareURL(
6.64 Class<?> clazz, String content, String mimeType, String... parameters) {
6.65 - for (KnockoutTCK tck : ServiceLoader.load(KnockoutTCK.class, cl(clazz))) {
6.66 + for (KnockoutTCK tck : tcks(clazz)) {
6.67 URI o = tck.prepareURL(content, mimeType, parameters);
6.68 if (o != null) {
6.69 return o.toString();
6.70 @@ -109,7 +123,7 @@
6.71
6.72 static boolean canFailWebSockets(
6.73 Class<?> clazz) {
6.74 - for (KnockoutTCK tck : ServiceLoader.load(KnockoutTCK.class, cl(clazz))) {
6.75 + for (KnockoutTCK tck : tcks(clazz)) {
6.76 if (tck.canFailWebSocketTest()) {
6.77 return true;
6.78 }
7.1 --- a/json-tck/src/main/java/org/apidesign/html/json/tck/KnockoutTCK.java Sat Jan 04 16:22:11 2014 +0100
7.2 +++ b/json-tck/src/main/java/org/apidesign/html/json/tck/KnockoutTCK.java Sat Jan 04 21:47:47 2014 +0100
7.3 @@ -46,9 +46,10 @@
7.4 import java.util.Map;
7.5 import net.java.html.BrwsrCtx;
7.6 import net.java.html.json.tests.ConvertTypesTest;
7.7 +import net.java.html.json.tests.JSONTest;
7.8 import net.java.html.json.tests.KnockoutTest;
7.9 -import net.java.html.json.tests.JSONTest;
7.10 import net.java.html.json.tests.OperationsTest;
7.11 +import net.java.html.json.tests.Utils;
7.12 import net.java.html.json.tests.WebSocketTest;
7.13 import org.openide.util.lookup.ServiceProvider;
7.14
7.15 @@ -72,6 +73,7 @@
7.16 */
7.17 public abstract class KnockoutTCK {
7.18 protected KnockoutTCK() {
7.19 + Utils.registerTCK(this);
7.20 }
7.21
7.22 /** Implement to create new context for the test.
8.1 --- a/ko-osgi-test/pom.xml Sat Jan 04 16:22:11 2014 +0100
8.2 +++ b/ko-osgi-test/pom.xml Sat Jan 04 21:47:47 2014 +0100
8.3 @@ -126,5 +126,11 @@
8.4 <artifactId>org.eclipse.osgi</artifactId>
8.5 <version>3.8.0.v20120529-1548</version>
8.6 </dependency>
8.7 + <dependency>
8.8 + <groupId>${project.groupId}</groupId>
8.9 + <artifactId>equinox-agentclass-hook</artifactId>
8.10 + <version>${project.version}</version>
8.11 + <scope>test</scope>
8.12 + </dependency>
8.13 </dependencies>
8.14 </project>
8.15 \ No newline at end of file
9.1 --- a/ko-osgi-test/src/test/java/org/netbeans/html/ko/osgi/test/KnockoutEquinoxIT.java Sat Jan 04 16:22:11 2014 +0100
9.2 +++ b/ko-osgi-test/src/test/java/org/netbeans/html/ko/osgi/test/KnockoutEquinoxIT.java Sat Jan 04 21:47:47 2014 +0100
9.3 @@ -127,6 +127,7 @@
9.4 + "javafx.util,"
9.5 + "netscape.javascript"
9.6 );
9.7 + config.put("osgi.hook.configurators.include", "org.netbeans.html.equinox.agentclass.AgentHook");
9.8 framework = ff.newFramework(config);
9.9 framework.init();
9.10 loadClassPathBundles(framework);
9.11 @@ -234,8 +235,7 @@
9.12 ClassLoader l = getClassLoader();
9.13 List<Object> res = new ArrayList<Object>();
9.14 for (int i = 0; i < arr.length; i++) {
9.15 - Class<?> c = Class.forName(arr[i].getName(), true, l);
9.16 - seekKOTests(c, res);
9.17 + seekKOTests(arr[i], res);
9.18 }
9.19 return res.toArray();
9.20 }
10.1 --- a/pom.xml Sat Jan 04 16:22:11 2014 +0100
10.2 +++ b/pom.xml Sat Jan 04 21:47:47 2014 +0100
10.3 @@ -31,6 +31,7 @@
10.4 <module>geo</module>
10.5 <module>ko-ws-tyrus</module>
10.6 <module>ko-osgi-test</module>
10.7 + <module>equinox-agentclass-hook</module>
10.8 </modules>
10.9 <licenses>
10.10 <license>