/* * Copyright 2016, Stuart Douglas, and individual contributors as indicated * by the @authors tag. * * Licensed 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 a.org.fakereplace.integration.weld.clientproxy; import javax.inject.Inject; import a.org.fakereplace.testsuite.shared.ClassReplacer; import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.arquillian.junit.Arquillian; import org.jboss.shrinkwrap.api.Archive; import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.asset.EmptyAsset; import org.jboss.shrinkwrap.api.spec.JavaArchive; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; /** * @author Stuart Douglas */ @RunWith(Arquillian.class) public class ClientProxyReplacementTest { @Deployment public static Archive<?> deploy() { return ShrinkWrap.create(JavaArchive.class, "test.jar" ) .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml") .addPackage(ClientProxyReplacementTest.class.getPackage()); } @Inject private DependentBean dependentBean; @Test public void testClientProxyReplacement() throws InterruptedException { dependentBean.setValue("Hello CDI"); final ClassReplacer replacer = new ClassReplacer(); replacer.queueClassForReplacement(AppScopedBean.class, AppScopedBean1.class); replacer.queueClassForReplacement(DependentBean.class, DependentBean1.class); replacer.replaceQueuedClasses(); Assert.assertEquals("Hello CDI", dependentBean.getValue()); } }