java.lang.reflect.UndeclaredThrowableException#printStackTrace ( )源码实例Demo

下面列出了java.lang.reflect.UndeclaredThrowableException#printStackTrace ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: cxf   文件: HeaderClientServerTest.java
@Test
public void testOutHeader() throws Exception {
    URL wsdl = getClass().getResource("/wsdl/soapheader.wsdl");
    assertNotNull(wsdl);

    SOAPHeaderService service = new SOAPHeaderService(wsdl, serviceName);
    assertNotNull(service);
    TestHeader proxy = service.getPort(portName, TestHeader.class);
    try {
        TestHeader2 in = new TestHeader2();
        String val = new String(TestHeader2Response.class.getSimpleName());
        Holder<TestHeader2Response> out = new Holder<>();
        Holder<TestHeader2Response> outHeader = new Holder<>();
        for (int idx = 0; idx < 2; idx++) {
            val += idx;
            in.setRequestType(val);
            proxy.testHeader2(in, out, outHeader);

            assertEquals(val, out.value.getResponseType());
            assertEquals(val, outHeader.value.getResponseType());
        }
    } catch (UndeclaredThrowableException ex) {
        ex.printStackTrace();
        throw (Exception)ex.getCause();
    }
}
 
源代码2 项目: openjdk-systemtest   文件: VMLogger.java
public void writeProxyData(String msg) {
    VMData.writeHeading(logFile, true, msg); 
    try {
        envData.writeData (runtimeBean, osBean, logBean, true);
        classData.writeData (classBean, compBean, runtimeBean, true);
        memoryData.writeData (memBean, memMgrBeans, memPoolBeans, gcBeans, true);
        threadData.writeData (threadBean, 8, true);
    } catch ( UndeclaredThrowableException ue) {
        Message.logOut("UndeclaredThrowableException when trying to access the Platform MBean Server");
        ue.printStackTrace();
        Assert.fail("UndeclaredThrowableException when trying to access the Platform MBean Server");           
    } 
}
 
源代码3 项目: cxf   文件: JSClientServerTest.java
@Test
public void testJSMessageMode() throws Exception {
    QName serviceName = new QName(NS, "SOAPService");
    QName portName = new QName(NS, "SoapPort");

    URL wsdl = getClass().getResource("/wsdl/hello_world.wsdl");
    assertNotNull(wsdl);

    SOAPService service = new SOAPService(wsdl, serviceName);
    assertNotNull(service);

    String response1 = new String("TestGreetMeResponse");
    String response2 = new String("TestSayHiResponse");
    try {
        Greeter greeter = service.getPort(portName, Greeter.class);
        updateAddressPort(greeter, JS_PORT);
        String greeting = greeter.greetMe("TestGreetMeRequest");
        assertNotNull("no response received from service", greeting);
        assertEquals(response1, greeting);

        String reply = greeter.sayHi();
        assertNotNull("no response received from service", reply);
        assertEquals(response2, reply);
    } catch (UndeclaredThrowableException ex) {
        ex.printStackTrace();
        throw (Exception)ex.getCause();
    }
}
 
源代码4 项目: cxf   文件: JSClientServerTest.java
@Test
public void testJSPayloadMode() throws Exception {
    URL wsdl = getClass().getResource("/wsdl/hello_world.wsdl");
    assertNotNull(wsdl);

    QName serviceName = new QName(NS, "SOAPService_Test1");
    QName portName = new QName(NS, "SoapPort_Test1");

    SOAPServiceTest1 service = new SOAPServiceTest1(wsdl, serviceName);
    assertNotNull(service);

    String response1 = new String("TestGreetMeResponse");
    String response2 = new String("TestSayHiResponse");
    try {
        Greeter greeter = service.getPort(portName, Greeter.class);
        updateAddressPort(greeter, JSX_PORT);
        String greeting = greeter.greetMe("TestGreetMeRequest");
        assertNotNull("no response received from service", greeting);
        assertEquals(response1, greeting);

        String reply = greeter.sayHi();
        assertNotNull("no response received from service", reply);
        assertEquals(response2, reply);
    } catch (UndeclaredThrowableException ex) {
        ex.printStackTrace();
        throw (Exception)ex.getCause();
    }
}
 
源代码5 项目: openjdk-systemtest   文件: ClassProfiler.java
private void getStatsViaProxy() {
	RuntimeMXBean runtimeBean = null;
	OperatingSystemMXBean osBean = null;
	LoggingMXBean logBean = null;
	ClassLoadingMXBean classBean = null;
	CompilationMXBean compBean = null;

	// Get the proxies for the runtime, os, log and class MXBeans
	try {
		runtimeBean = ManagementFactory.newPlatformMXBeanProxy(this.mbs, ManagementFactory.RUNTIME_MXBEAN_NAME,
				RuntimeMXBean.class);

		osBean = ManagementFactory.newPlatformMXBeanProxy(this.mbs, ManagementFactory.OPERATING_SYSTEM_MXBEAN_NAME,
				OperatingSystemMXBean.class);

		logBean = ManagementFactory.newPlatformMXBeanProxy(this.mbs, LogManager.LOGGING_MXBEAN_NAME,
				LoggingMXBean.class);

		classBean = ManagementFactory.newPlatformMXBeanProxy(this.mbs, ManagementFactory.CLASS_LOADING_MXBEAN_NAME,
				ClassLoadingMXBean.class);

		// Check the compiler is being used and get the compilation MXBean
		Map<String, String> props = runtimeBean.getSystemProperties();
		String sys_comp = props.get("java.compiler");

		if ((sys_comp != null) && (!(sys_comp.equals("")))) {
			compBean = ManagementFactory.newPlatformMXBeanProxy(this.mbs, ManagementFactory.COMPILATION_MXBEAN_NAME,
					CompilationMXBean.class);
		}
	} catch (IOException ioe) {
		Message.logOut("A communication problem occurred when accessing the MBeanServerConnection");
		ioe.printStackTrace();
		Assert.fail("A communication problem occurred when accessing the MBeanServerConnection");
	}

	try {
		Message.logOut("Starting to write data");
		// Record the environment data in the log
		this.envData.writeData(runtimeBean, osBean, logBean, false);

		// Record the number of class loaded over time in a csv and record
		// the class data in the log every 10 seconds
		int secondsCnt = 0;
		int writesCnt = 0;
		while (writesCnt < 30) {
			// Write out the threadData every 10 seconds
			if (secondsCnt == 10) {
				System.out.print(".");
				this.classData.writeData(classBean, compBean, runtimeBean, true);
				secondsCnt = 0;
				writesCnt++;
			}
			this.recordClassStats(runtimeBean, classBean);
			Thread.sleep(1000);
			secondsCnt++;
		}
	} catch (InterruptedException ie) {
		Message.logOut("The sleeping profiler was interrupted");
		ie.printStackTrace();
		Assert.fail("The sleeping profiler was interrupted");
	} catch (UndeclaredThrowableException ue) {
		Throwable cause = ue.getCause();
		Class<ConnectException> connectExcept = ConnectException.class;
		Class<UnmarshalException> unmarshalExcept = UnmarshalException.class;

		if (connectExcept.isInstance(cause) || unmarshalExcept.isInstance(cause)) {
			
			// If the exception was caused by a Connect or Unmarshal
			// Exception, assume the monitored JVM has finished. 
			this.closeCSVFile();
			Message.logOut("Exiting as JVM we are connected to has finished");
			Assert.fail("Exiting as JVM we are connected to has finished");
		} else {
			Message.logOut(ue.getMessage());
			ue.printStackTrace();
			Assert.fail(ue.getMessage());
		}
	} finally {
		this.closeCSVFile();
	}
}
 
源代码6 项目: openjdk-systemtest   文件: ThreadProfiler.java
private void getStatsViaProxy() {
	RuntimeMXBean runtimeBean = null;
	OperatingSystemMXBean osBean = null;
	LoggingMXBean logBean = null;
	ThreadMXBean threadBean = null;
	int stackDepth = 8;

	// Get the runtime, os, log and thread MXBeans
	try {
		runtimeBean = ManagementFactory.newPlatformMXBeanProxy(this.mbs, 
				ManagementFactory.RUNTIME_MXBEAN_NAME, RuntimeMXBean.class);
		osBean = ManagementFactory.newPlatformMXBeanProxy(this.mbs, 
				ManagementFactory.OPERATING_SYSTEM_MXBEAN_NAME, OperatingSystemMXBean.class);
		logBean = ManagementFactory.newPlatformMXBeanProxy(this.mbs, 
				LogManager.LOGGING_MXBEAN_NAME, LoggingMXBean.class);
		threadBean = ManagementFactory.newPlatformMXBeanProxy(this.mbs, 
				ManagementFactory.THREAD_MXBEAN_NAME, ThreadMXBean.class);
	} catch (IOException ioe) {
		Message.logOut("A communication problem occurred when accessing the MBeanServerConnection");
		ioe.printStackTrace();
		Assert.fail("A communication problem occurred when accessing the MBeanServerConnection");
	}

	try {
		Message.logOut("Starting to write data");
		this.envData.writeData(runtimeBean, osBean, logBean, false);
		int secondsCnt = 0;
		int writesCnt = 0;
		while (writesCnt < 30) {
			// Write out the threadData 10 seconds
			if (secondsCnt == 10) {
				System.out.print(".");
				this.threadData.writeData(threadBean, stackDepth, true);
				secondsCnt = 0;
				writesCnt++;
			}
			this.recordThreadStats(runtimeBean, threadBean);
			Thread.sleep(1000);
			secondsCnt++;
		}
	} catch (InterruptedException ie) {
		Message.logOut("The sleeping profiler was interrupted");
		ie.printStackTrace();
		Assert.fail("The sleeping profiler was interrupted");
	} catch (UndeclaredThrowableException ue) {
		// If the exception was caused by a Connect or Unmarshal Exception
		// assume the monitored JVM has finished.
		Throwable cause = ue.getCause();
		Class<ConnectException> connectExcept = ConnectException.class;
		Class<UnmarshalException> unmarshalExcept = UnmarshalException.class;

		if (connectExcept.isInstance(cause) || unmarshalExcept.isInstance(cause)) {
			this.closeCSVFile();
			Message.logOut("Exiting as JVM we are connected to has finished");
			Assert.fail("Exiting as JVM we are connected to has finished");
		} else {
			Message.logOut(ue.getMessage());
			ue.printStackTrace();
			Assert.fail(ue.getMessage());
		}
	} finally {
		this.closeCSVFile();
	}
}
 
源代码7 项目: openjdk-systemtest   文件: MemoryNotifier.java
private void initNotifier() {
	try {	
		this.memoryBean = ManagementFactory.newPlatformMXBeanProxy(
				this.mbs, ManagementFactory.MEMORY_MXBEAN_NAME,
				MemoryMXBean.class);
	} catch (IOException ioe) {
		Message.logOut("A communication problem occurred when accessing the MBeanServerConnection");
		ioe.printStackTrace();
		Assert.fail("A communication problem occurred when accessing the MBeanServerConnection");
	}

	// Define the emitter, listener and add the listener
	this.emitter = (NotificationEmitter) this.memoryBean;
	this.listener = new MemoryListener(logFile, this.mbs, this);
	this.emitter.addNotificationListener(this.listener, null, null);

	try {
		for (int writesCnt = 0; writesCnt < 120; ++writesCnt) {
			Thread.sleep(1000); 
			// Use the isVerbose call to ping the proxy to ensure it still exists
			this.memoryBean.isVerbose();
		}
		Message.logOut("MemoryNotifier is Done.");
	} catch (InterruptedException ie) {
		Message.logOut("The sleeping profiler was interrupted");
		ie.printStackTrace();
		Assert.fail("The sleeping profiler was interrupted");
	} catch (UndeclaredThrowableException ue) {
		// If the exception was caused by a Connect or Unmarshal Exception, assume the 
		// monitored JVM has finished.
		Throwable cause = ue.getCause();
		Class<ConnectException>     connectExcept = ConnectException.class;
		Class<UnmarshalException>     unmarshalExcept = UnmarshalException.class;

		if (connectExcept.isInstance(cause) || unmarshalExcept.isInstance(cause)) {
			Assert.fail("Problem connecting to the JVM to be monitored");
		} else { 
			ue.printStackTrace();
			Assert.fail(ue.getMessage());
		}
	}
}