@Test public void testProxying() { // this is not a bullet proof proxy detection, but it should prove whether or not proxying is // correctly // inserted into the chain of events. String javaAssistMarker = "$$_javassist"; String aLaunchURI = "http://nasa.dataincubator.org/launch/SATURNSA1"; Launch aLaunch = mManager.find(Launch.class, aLaunchURI); LaunchUsingProxy aProxySupportingLaunch = mManager.find(LaunchUsingProxy.class, aLaunchURI); // this object is proxied LaunchSite aOrigSite = aProxySupportingLaunch.getLaunchSite(); // this should be a proxy class... // the easy way to check this is via the class name to see if its a javassist created class. // this means the proxy was correctly created in RdfGenerator // and the proxy *works* if the results of the gets and sets are what is expected. assertTrue(aOrigSite.getClass().getName().indexOf(javaAssistMarker) != -1); // and the non-proxying version should not return a proxy object assertTrue(aLaunch.getLaunchSite().getClass().getName().indexOf(javaAssistMarker) == -1); // and the proxied object should be equal to a non proxied version of the same thing assertEquals(aOrigSite, aLaunch.getLaunchSite()); // we want to make sure that get/set operations work via a proxied object fine, that we don't // get anything cached // or stale proxied objects returned accidentally LaunchSite aNewSite = new LaunchSite(); aNewSite.setLabel(Arrays.asList("new launch site")); assertFalse(aOrigSite.equals(aNewSite)); assertEquals(aProxySupportingLaunch.getLaunchSite(), aOrigSite); aProxySupportingLaunch.setLaunchSite(aNewSite); assertEquals(aProxySupportingLaunch.getLaunchSite(), aNewSite); }