Java Code Examples for org.jboss.forge.furnace.proxy.Proxies#enhance()
The following examples show how to use
org.jboss.forge.furnace.proxy.Proxies#enhance() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ProxiesTest.java From furnace with Eclipse Public License 1.0 | 6 votes |
@Test public void testIsInstance() { Bean enhancedObj = Proxies.enhance(Bean.class, new ForgeProxy() { @Override public Object invoke(Object self, Method thisMethod, Method proceed, Object[] args) throws Throwable { return proceed.invoke(self, args); } @Override public Object getDelegate() throws Exception { return null; } @Override public Object getHandler() throws Exception { return this; } }); Assert.assertTrue(Proxies.isInstance(Bean.class, enhancedObj)); }
Example 2
Source File: ClassLoaderAdapterCallbackTest.java From furnace with Eclipse Public License 1.0 | 5 votes |
@Test public void testNestedProxyAdapterCallback() throws Exception { MockService object = Proxies.enhance(MockService.class, handler); ClassLoader loader = ClassLoaderAdapterCallbackTest.class.getClassLoader(); MockService object2 = ClassLoaderAdapterBuilder.callingLoader(loader).delegateLoader(loader) .enhance(object, MockService.class); Assert.assertNotSame(object, object2); }
Example 3
Source File: ReflectionExportedInstance.java From furnace with Eclipse Public License 1.0 | 5 votes |
@Override public T get() { try { T delegate = type.newInstance(); delegate = Proxies.enhance(addon.getClassLoader(), delegate, new ClassLoaderInterceptor( addon.getClassLoader(), delegate)); return delegate; } catch (Exception e) { throw new ContainerException("Could not create instance of [" + type.getName() + "] through reflection.", e); } }
Example 4
Source File: ProxiesTest.java From furnace with Eclipse Public License 1.0 | 5 votes |
@Test public void testUnwrapProxyTypes() { BeanWithSuperClass enhancedObj = Proxies.enhance(BeanWithSuperClass.class, new ForgeProxy() { private final Object bean = new BeanWithSuperClass(); @Override public Object invoke(Object self, Method thisMethod, Method proceed, Object[] args) throws Throwable { return proceed.invoke(self, args); } @Override public Object getDelegate() { return bean; } @Override public Object getHandler() throws Exception { return this; } }); Assert.assertNotEquals(BeanWithSuperClass.class.getName(), enhancedObj.getClass().getName()); Class<?> result = Proxies.unwrapProxyTypes(enhancedObj.getClass()); Assert.assertEquals(BeanWithSuperClass.class, result); }
Example 5
Source File: ProxiesTest.java From furnace with Eclipse Public License 1.0 | 5 votes |
@Test public void testUnwrapProxyClassName() { Bean enhancedObj = Proxies.enhance(Bean.class, new ForgeProxy() { @Override public Object invoke(Object self, Method thisMethod, Method proceed, Object[] args) throws Throwable { return null; } @Override public Object getDelegate() { return null; } @Override public Object getHandler() throws Exception { return this; } }); Assert.assertNotEquals(Bean.class.getName(), enhancedObj.getClass().getName()); String result = Proxies.unwrapProxyClassName(enhancedObj.getClass()); Assert.assertEquals(Bean.class.getName(), result); }
Example 6
Source File: ProxiesTest.java From furnace with Eclipse Public License 1.0 | 5 votes |
@Test public void testAreEquivalent() { Bean enhancedObj = Proxies.enhance(Bean.class, new ForgeProxy() { @Override public Object invoke(Object self, Method thisMethod, Method proceed, Object[] args) throws Throwable { return proceed.invoke(self, args); } @Override public Object getDelegate() { return null; } @Override public Object getHandler() throws Exception { return this; } }); enhancedObj.setAtt("String"); Bean bean2 = new Bean(); bean2.setAtt("String"); Assert.assertTrue(Proxies.areEquivalent(enhancedObj, bean2)); }
Example 7
Source File: ProxiesTest.java From furnace with Eclipse Public License 1.0 | 5 votes |
@Test public void testEqualsAndHashCode() { Bean bean1 = new Bean(); String attributeValue = "String"; bean1.setAtt(attributeValue); Bean enhancedObj = Proxies.enhance(Bean.class, new ClassLoaderInterceptor(Bean.class.getClassLoader(), bean1)); enhancedObj.setAtt(attributeValue); Bean bean2 = new Bean(); bean2.setAtt(attributeValue); Assert.assertTrue(enhancedObj.equals(bean2)); }
Example 8
Source File: ProxiesTest.java From furnace with Eclipse Public License 1.0 | 4 votes |
@Test public void testNestedProxy() throws Exception { Object object = Proxies.enhance(MockType.class, handler); Proxies.enhance(object.getClass(), handler); }
Example 9
Source File: ProxiesTest.java From furnace with Eclipse Public License 1.0 | 4 votes |
@Test(expected = Exception.class) public void testCannotProxyMemberClass() throws Exception { Proxies.enhance(MemberClass.class, handler); }
Example 10
Source File: ProxiesTest.java From furnace with Eclipse Public License 1.0 | 4 votes |
@Test(expected = IllegalArgumentException.class) public void testEnhanceInvalidArguments1() throws Exception { Proxies.enhance(null, handler); }
Example 11
Source File: ProxiesTest.java From furnace with Eclipse Public License 1.0 | 4 votes |
@Test(expected = IllegalArgumentException.class) public void testEnhanceInvalidArguments2() throws Exception { Proxies.enhance(ProxiesTest.class, null); }
Example 12
Source File: ProxiesTest.java From furnace with Eclipse Public License 1.0 | 4 votes |
@Test(expected = IllegalArgumentException.class) public void testEnhanceInvalidArguments3() throws Exception { Proxies.enhance(null, null); }
Example 13
Source File: ProxiesTest.java From furnace with Eclipse Public License 1.0 | 4 votes |
@Test(expected = IllegalArgumentException.class) public void testEnhanceInvalidArguments4() throws Exception { Proxies.enhance(null, null, handler); }
Example 14
Source File: ProxiesTest.java From furnace with Eclipse Public License 1.0 | 4 votes |
@Test(expected = IllegalArgumentException.class) public void testEnhanceInvalidArguments5() throws Exception { Proxies.enhance(getClass().getClassLoader(), null, null); }
Example 15
Source File: ProxiesTest.java From furnace with Eclipse Public License 1.0 | 4 votes |
@Test(expected = IllegalArgumentException.class) public void testEnhanceInvalidArguments6() throws Exception { Proxies.enhance(getClass().getClassLoader(), new ProxiesTest(), null); }
Example 16
Source File: ProxiesTest.java From furnace with Eclipse Public License 1.0 | 4 votes |
@Test(expected = IllegalArgumentException.class) public void testEnhanceInvalidArguments7() throws Exception { Proxies.enhance(null, new ProxiesTest(), handler); }