ko-felix-test/src/main/java/org/netbeans/html/ko/felix/test/KnockoutFelixTCKImpl.java
changeset 886 88d62267a0b5
parent 838 bdc3d696dd4a
child 934 bbbdf003a99b
     1.1 --- a/ko-felix-test/src/main/java/org/netbeans/html/ko/felix/test/KnockoutFelixTCKImpl.java	Tue Aug 26 18:13:30 2014 +0200
     1.2 +++ b/ko-felix-test/src/main/java/org/netbeans/html/ko/felix/test/KnockoutFelixTCKImpl.java	Thu Dec 04 09:21:55 2014 +0100
     1.3 @@ -46,6 +46,7 @@
     1.4  import java.io.IOException;
     1.5  import java.io.InputStreamReader;
     1.6  import java.lang.reflect.Constructor;
     1.7 +import java.lang.reflect.InvocationTargetException;
     1.8  import java.lang.reflect.Method;
     1.9  import java.net.URI;
    1.10  import java.net.URISyntaxException;
    1.11 @@ -140,16 +141,9 @@
    1.12      @Override
    1.13      public BrwsrCtx createContext() {
    1.14          try {
    1.15 -            Class<?> fxCls = loadOSGiClass(
    1.16 -                "org.netbeans.html.ko4j.FXContext",
    1.17 -                FrameworkUtil.getBundle(KnockoutFelixTCKImpl.class).getBundleContext()
    1.18 -            );
    1.19 -            final Constructor<?> cnstr = fxCls.getConstructor(Fn.Presenter.class);
    1.20 -            cnstr.setAccessible(true);
    1.21 -            Object fx = cnstr.newInstance(browserContext);
    1.22              Contexts.Builder cb = Contexts.newBuilder().
    1.23 -                register(Technology.class, (Technology)fx, 10).
    1.24 -                register(Transfer.class, (Transfer)fx, 10).
    1.25 +                register(Technology.class, (Technology)osgiInstance("KOTech"), 10).
    1.26 +                register(Transfer.class, (Transfer)osgiInstance("KOTransfer"), 10).
    1.27                  register(Executor.class, (Executor)browserContext, 10);
    1.28  //        if (fx.areWebSocketsSupported()) {
    1.29  //            cb.register(WSTransfer.class, fx, 10);
    1.30 @@ -160,6 +154,17 @@
    1.31          }
    1.32      }
    1.33  
    1.34 +    private Object osgiInstance(String simpleName) throws IllegalAccessException, SecurityException, IllegalArgumentException, Exception, NoSuchMethodException, InstantiationException, InvocationTargetException {
    1.35 +        Class<?> fxCls = loadOSGiClass(
    1.36 +                "org.netbeans.html.ko4j." + simpleName,
    1.37 +                FrameworkUtil.getBundle(KnockoutFelixTCKImpl.class).getBundleContext()
    1.38 +        );
    1.39 +        final Constructor<?> cnstr = fxCls.getDeclaredConstructor();
    1.40 +        cnstr.setAccessible(true);
    1.41 +        Object fx = cnstr.newInstance();
    1.42 +        return fx;
    1.43 +    }
    1.44 +
    1.45      @Override
    1.46      public Object createJSON(Map<String, Object> values) {
    1.47          JSONObject json = new JSONObject();