public static void main(String as[]) { Hello h = new Hello(); Hello h1 = new Hello(); Hello h2 = new Hello(); Hello h3 = new Hello(); System.runFinalization(); System.gc(); System.out.println("GC1"); h.m1(); h.m2(); Hai hai = new Hai(); hai = null; Hai hai1 = new Hai(); hai1 = hai; System.runFinalization(); System.gc(); /* A a=new A(); a.show(); System.runFinalization(); System.gc(); */ }
@Test() public void singleActorSingleStageTest() throws ExecutionException, InterruptedException { Stage stage1 = createStage(); Hello hello = Actor.getReference(Hello.class, "1"); assertEquals("bla", hello.sayHello("bla").join()); dumpMessages(); }
@Test public void simpleProxy() { Hello hello = new HelloTarget(); assertThat(hello.sayHello("Toby"), is("Hello Toby")); assertThat(hello.sayHi("Toby"), is("Hi Toby")); assertThat(hello.sayThankYou("Toby"), is("Thank You Toby")); }
@Test public void simple() { AnnotationConfigApplicationContext ac = new AnnotationConfigApplicationContext(AppConfig.class); Hello h = ac.getBean(Hello.class); h.sayHello(); assertThat(h.getHello(), is("Hello Toby")); }
@Test public void upperProxy() { Hello hello = new HelloUppercase(new HelloTarget()); assertThat(hello.sayHello("Toby"), is("HELLO TOBY")); assertThat(hello.sayHi("Toby"), is("HI TOBY")); assertThat(hello.sayThankYou("Toby"), is("THANK YOU TOBY")); }
public void testInvoke() throws Exception { MockInterceptor mi = new MockInterceptor("Hello"); Aspect aspect = new AspectImpl(mi); AopProxy aopProxy = new AopProxy(Hello.class, new Aspect[] {aspect}); Hello hello = (Hello) aopProxy.create(); assertEquals("1", "Hello", hello.greeting()); }
public static void main(String args[]) { try { // create and initialize the ORB ORB orb = ORB.init(args, null); System.out.println("ORB initialised\n"); // get the root naming context org.omg.CORBA.Object objRef = orb.resolve_initial_references("NameService"); // Use NamingContextExt instead of NamingContext, // part of the Interoperable naming Service. NamingContextExt ncRef = NamingContextExtHelper.narrow(objRef); // resolve the Object Reference in Naming String name = "Hello1"; helloImpl = HelloHelper.narrow(ncRef.resolve_str(name)); System.out.println("Obtained a handle on server object: " + helloImpl); System.out.println(helloImpl.sayHello()); helloImpl.shutdown(); } catch (Exception e) { System.out.println("ERROR : " + e); e.printStackTrace(System.out); } } // end main
@Bean public Hello hello() { Hello hello = new Hello(); hello.setName("String"); hello.setPrinter(new StringPrinter()); return hello; }
public static void main(String[] args) { Hello objHello = new Hello(); String s = objHello.greet(); System.out.println(s); Hello objHello2 = new Hello("Kay"); s = objHello2.greet(); System.out.println(s); }
public static void test(B b) { b.test(); Test2 t = null; // +1 Ce for this package t.test(); // +0 Ce for this package Hello h = null; // +1 Ce for this package h.test(); // +0 Ce for this package System.out.println("Hello" + "a"); // +3 Ce for this package // System, PrintWriter, String.toString }
public void testThrowable() throws Exception { MockInterceptor mi = new MockInterceptor(); mi.setThrowable(new NullPointerException()); Hello hello = (Hello) mi.createProxy(Hello.class); try { hello.greeting(); fail("1"); } catch (NullPointerException ignore) { } }
@Test public void testEjb() throws Exception { Hello helloBean = (Hello) initialContext.lookup( "runasmdbejb-ejb3/Hello!org.jboss.as.test.integration.ejb.security.runas.ejb2mdb.Hello"); String hellomsg = helloBean.sayHello(); log.trace(hellomsg); Assert.assertEquals("Hello Fred! Howdy Fred! GoodBye user1", hellomsg); }
public static void main(String[] args) { System.out.println(Hello.greetingMessage()); int[] array = {5, 4, 3, 2, 1}; System.out.println(Hello.arrayToString("Array", array)); array = Hello.bubbleSort(array); System.out.println(Hello.arrayToString("Sorted Array", array)); }
public static void main(String as[]) { Hello h = new Hello(); int a = 100; System.out.println(a); h.m1(a); System.out.println(a); Hai hai = new Hai(); System.out.println(hai.x); h.m2(hai); System.out.println(hai.x); }
@Test public void dynamicProxy() { Hello proxiedHello = (Hello) Proxy.newProxyInstance( getClass().getClassLoader(), new Class[] {Hello.class}, new UppercaseHandler(new HelloTarget())); assertThat(proxiedHello.sayHello("Toby"), is("HELLO TOBY")); assertThat(proxiedHello.sayHi("Toby"), is("HI TOBY")); assertThat(proxiedHello.sayThankYou("Toby"), is("THANK YOU TOBY")); }
public static void main(String[] args) { try { ApplicationContext ctx = new ClassPathXmlApplicationContext("jlcindia19.xml"); logger.info("Inside main method Started Info"); System.out.println("---Spring container is now Ready---"); Hello hello = (Hello) ctx.getBean("hello"); hello.show(); int s = 19; logger.info("Inside main method Finished :" + s); } catch (BeansException e) { logger.error("Inside main method Started"); e.printStackTrace(); } }
public static void main(String[] args) { /*// without IOC A aobj = new A(); aobj.setA(99); aobj.setMsg("Hello Guys"); B bobj = new B(88, "Hai Guys"); Hello hello = new Hello(bobj); hello.setAobj(aobj); // hello.show(); */ ApplicationContext ctx = new ClassPathXmlApplicationContext("ApplicationContext.xml"); System.out.println("Spring container is Ready"); System.out.println("------------"); Hello h = (Hello) ctx.getBean("hello"); h.show(); }
/** * Tests server-side access to EPR extensions specified in WSDL * * @throws Exception */ public void testEprOnServerSide() throws Exception { HelloService service = new HelloService(); Hello hello = service.getHelloPort(); W3CEndpointReference serverEpr = hello.getW3CEPR(); // printEPR(serverEpr); WSEndpointReference wsepr = new WSEndpointReference(serverEpr); assertTrue(wsepr.getEPRExtensions().size() == 2); WSEndpointReference.EPRExtension idExtn = wsepr.getEPRExtension(new QName("http://example.com/addressingidentity", "Identity")); assertTrue( idExtn != null && idExtn .getQName() .equals(new QName("http://example.com/addressingidentity", "Identity"))); }
public static void main(String... args) throws Exception { String providerUrl = DEFAULT_PROVIDER_URL; if (args.length != 0) { providerUrl = args[0]; } String jndiName = "HelloSFSB/remote"; Properties props = new Properties(); props.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory"); props.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces"); props.put(Context.PROVIDER_URL, providerUrl); InitialContext context = new InitialContext(props); Hello hello = (Hello) context.lookup(jndiName); hello.hello(); hello.destroy(); }
/** * Tests unauthenticated call followed by the authentication and second call to the same instance. * * @throws Exception */ @Test public void testAuthenticationCache() throws Exception { try { hello.sayHello(); fail("Access to sayHello() should be denied if not authenticated."); } catch (EJBAccessException e) { // OK } SecurityClient securityClient = SecurityClientFactory.getSecurityClient(); securityClient.setSimple("jduke", "theduke"); try { securityClient.login(); assertEquals(HelloBean.HELLO_WORLD, hello.sayHello()); } finally { securityClient.logout(); } }
@Override @TransactionAttribute public Hello sayHello(String username, String ip) { Hello hello = fromUsername(username); /* Address address = addressDao.fromIP(ip); if (address == null) { address = new Address(); address.setIp4(ip); geoLocator.locate(address); address = addressDao.save(address); } Collection<Address> addresses = null; hello.setAddresses(addresses = new ArrayList<Address>()); addresses = hello.getAddresses(); assert(addresses != null); address = new Address(); address.setIp4(ip); geoLocator.locate(address); if (!addresses.contains(addresses)) { addresses.add(address); hello.setAddresses(addresses); } */ Address address = new Address(); address.setIp4(ip); geoLocator.locate(address); if (hello == null) { hello = new Hello(); hello.setUsername(username); } else { hello.bumpCounter(); } // hello.addAddress(address); hello = save(hello); return hello; }
/** * Tests secured EJB call for unauthenticated user. * * @throws Exception */ @Test public void testNotAuthn() throws Exception { try { hello.sayHello(); fail("Access to sayHello() should be denied if not authenticated."); } catch (EJBAccessException e) { // OK } }
@Test public void handlingValidationExceptionCausedByNullParameter() { try { hello.say(null); fail(); } catch (ValidationException cause) { assertEquals(NullPointerException.class, cause.getCause().getClass()); } }
@Test public void handlingValidationExceptionCausedByInvalidParameter() { try { hello.say("Nurse"); fail(); } catch (ValidationException cause) { assertEquals(IllegalArgumentException.class, cause.getCause().getClass()); } }
/** * Test secured EJB call for authenticated and authorized user. * * @throws Exception */ @Test public void testAuthz() throws Exception { SecurityClient securityClient = SecurityClientFactory.getSecurityClient(); securityClient.setSimple("jduke", "theduke"); try { securityClient.login(); assertEquals(HelloBean.HELLO_WORLD, hello.sayHello()); } finally { securityClient.logout(); } }
public static void main(String[] args) { Hello h = new Hello(); /*int p=1; int q=2; int r=3; int s=4; h.m1(); h.m1(p,q); h.m1(p,q,r); h.m1(p,q,r,s); */ byte a = 1; byte b = 2; byte c = 3; byte d = 4; h.m1(); h.m1(a, b); h.m1(a, b, c); h.m1(a, b, c, d); }
public static void main(String args[]) { /* * Create and install a security manager */ if (System.getSecurityManager() == null) { System.setSecurityManager(new SecurityManager()); } try { Registry registry = LocateRegistry.getRegistry(2002); Hello obj = (Hello) registry.lookup("Hello"); String message = obj.sayHello(); System.out.println(message); } catch (Exception e) { System.out.println("HelloClient exception: " + e.getMessage()); e.printStackTrace(); } }
@Override public Response handleHelloRequest(Hello message) { int xid = message.getXid(); messagesMapping.put(xid, message); try { int dpid = message.getDpid(); InstanceLocationSpecifier key = getInstanceLocationSpecifier(dpid); ConnectionInstance value = (new ConnectionInstance.Builder()) .setDpid(dpid) .setVersion(message.getVersion()) .setCapabilities(message.getCapabilities()) .build(); instancesMapping.put(key, value); IProcessingGraph processingGraph = ApplicationAggregator.getInstance().getProcessingGraph(key); List<JsonBlock> blocks = null; List<JsonConnector> connectors = null; if (processingGraph != null) { blocks = translateBlocks(processingGraph.getBlocks()); connectors = translateConnectors(processingGraph.getConnectors()); } SetProcessingGraphRequest processMessage = new SetProcessingGraphRequest(0, dpid, null, blocks, connectors); sendMessage(key, processMessage, null); return okResponse(); } catch (Exception e) { LOG.warning("Error occured while handling Hello message" + e.toString()); e.printStackTrace(); return internalErrorResponse(); } }
/** * Test secured EJB call for authenticated but not authorized authorized user. * * @throws Exception */ @Test @Ignore("JBPAPP-8989") public void testNotAuthz() throws Exception { SecurityClient securityClient = SecurityClientFactory.getSecurityClient(); securityClient.setSimple("JohnDoe", "jdoe"); try { securityClient.login(); hello.sayHello(); fail("Access to sayHello() should be denied for JohnDoe."); } catch (EJBAccessException e) { // OK - expected } finally { securityClient.logout(); } }
public static void main(String[] args) { Hello h = new Hello(); h.hello(); h.hello("dave"); }