[Java Basics3] XML, Unit testing

What‘s the difference between DOM and SAX? DOM creates tree-like representation of the XML document in memory, SAX is event-based. 
What‘s the difference between XSD and DTD? XSD is in XML, DTD is not. XSD is much more comprehensive than DTD
You‘re given an XML file, and you‘re supposed to retrieve the value of a specific element in the file. How do you do that? Open-ended question. See how the candidate uses various types of parsers (DOM, SAX, etc) and see if he explores the usage of XPath.
You‘re supposed to unit test Java class that accesses a database,
in a machine that doesn‘t have database server installed,
and no external connectivity at all. What‘s your approach?
Open-ended
question. See if the answer tackles the problem effectively.
See if he/she suggests mocking as an option
How do you ensure your unit tests have covered all paths /
possibilities?
Use
code coverage tool like Cobertura, Emma, etc
How do you unit-test a private method? -
Use Reflection, set accessible property of that method to true
- Call an accessible method that calls the private method and observe the
effect caused by calling the private method
时间: 2024-10-23 15:36:08

[Java Basics3] XML, Unit testing的相关文章

Java Unit Testing - JUnit & TestNG

转自https://www3.ntu.edu.sg/home/ehchua/programming/java/JavaUnitTesting.html yet another insignificant programming notes...   |   HOME TABLE OF CONTENTS (SHOW) Java Unit Testing -  & TestNG 1.  Introduction to Unit Testing Framework The various type o

10 Unit Testing and Automation Tools and Libraries Java Programmers Should Learn

转自:https://javarevisited.blogspot.com/2018/01/10-unit-testing-and-integration-tools-for-java-programmers.html#ixzz60s1lBt5p 一些很不错的测试框架整理 In last a couple of weeks, I have written some articles about what Java developer should learn in 2019 e.g. progr

Unit Testing a zend-mvc application

Unit Testing a zend-mvc application A solid unit test suite is essential for ongoing development in large projects, especially those with many people involved. Going back and manually testing every individual component of an application after every c

hadoop编程小技巧(8)---Unit Testing (单元测试)

所需环境: Hadoop相关jar包(下载官网发行版即可): 下载junit包(最新为好): 下载mockito包: 下载mrunit包: 下载powermock-mockito包: 相关包截图如下(相关下载参考:http://download.csdn.net/detail/fansy1990/7690977): 应用场景: 在进行Hadoop的一般MR编程时,需要验证我们的业务逻辑,或者说是验证数据流的时候可以使用此环境,这个环境不要求真实的云平台,只是针对算法或者代码逻辑进行验证,方便调试

【收藏用】--切勿转载Java处理XML的三种主流技术及介绍

原帖地址 : http://www.ibm.com/developerworks/cn/xml/dm-1208gub/ XML (eXtensible Markup Language) 意为可扩展标记语言,它已经是软件开发行业中大多数程序员和厂商用以选择作为数据传输的载体.本文作者对于 Java 处理 XML 的几种主流技术进行一些总结和介绍,希望帮助那些有不同需求的开发人员对于 XML 处理技术的作出最优的选择. 最初,XML 语言仅仅是意图用来作为 HTML 语言的替代品而出现的,但是随着该

JAVA解析XML之SAX方式

JAVA解析XML之SAX方式 SAX解析xml步骤 通过SAXParseFactory的静态newInstance()方法获取SAXParserFactory实例factory 通过SAXParserFactory实例的newSAXParser()方法返回SAXParser实例parser 创建一个类继承DefaultHandle,重写方法进行业务处理并创建这个类的实例handle 重写DefaultHandle类的方法 startElement方法用来遍历xml文件的开始标签; endEle

Java操作XML的JAXB工具

在java中操作XML的工作中中,比较方便的工具是JAXB(Java Architecture for XML Binding). 利用这个工具很方便生成XML的tag和Java类的对应关系.参照网上的资料,简单说明一下java操作xml的一些东西. 1.先定义一个XML Schema文件.比如: [html] view plain copy print? <?xml version="1.0" encoding="UTF-8" standalone=&quo

Java获取XML节点总结之读取XML文档节点

dom4j是Java的XML API,用来读写XML文件的.目前有很多场景中使用dom4j来读写xml的.要使用dom4j开发,需要下载导入dom4j相应的jar文件.官网下载:http://www.dom4j.org/dom4j-1.6.1/github下载:http://dom4j.github.io/下载解压之后如图所示: 我们只需要把dom4j-1.6.1.jar文件构建到我们开发项目中就可以了. 下面就以Eclipse创建java项目的构建方法为例说明:声明:本Java项目的开发环境J

java操作xml的一个小例子

最近两天公司事比较多,这两天自己主要跟xml打交道,今天更一下用java操作xml的一个小例子. 原来自己操作xml一直用这个包:xstream-1.4.2.jar.然后用注解的方式,很方便,自己只要定义好bean的层次结构就可以了,第三方包会自动生成和解析xml. 但是今天发现,这个包有两个问题: 一个是比较复杂(我是菜鸟,求别喷,我真的觉得他挺复杂的..).比如说你要想处理既有属性又有值的xml就比较麻烦.(@XStreamConverter注解这种方法报这个错:com.thoughtwor