All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jdom2.test.cases.TestSlimJDOMFactoryNoText Maven / Gradle / Ivy

Go to download

A complete, Java-based solution for accessing, manipulating, and outputting XML data

The newest version!
package org.jdom2.test.cases;

import static org.junit.Assert.*;
import org.junit.Test;

import org.jdom2.JDOMFactory;
import org.jdom2.SlimJDOMFactory;
import org.jdom2.Text;

@SuppressWarnings("javadoc")
public class TestSlimJDOMFactoryNoText extends AbstractTestJDOMFactory {

	/**
	 * @param located
	 */
	public TestSlimJDOMFactoryNoText() {
		super(false);
	}

	@Override
	protected JDOMFactory buildFactory() {
		return new SlimJDOMFactory(false);
	}

	@Test
	public void testCaching() {
		SlimJDOMFactory fac = new SlimJDOMFactory(false);
		Text ta = fac.text("hi");
		String hi = ta.getText();
		// we expect the StringBin to compact a string value... should no longer
		// be the intern value.
		assertTrue("hi" == hi);
		assertTrue("hi" == hi.intern());
		
		Text tb = fac.text("hi");
		assertTrue("hi" == tb.getText());
		assertTrue(hi == tb.getText());
		
		fac.clearCache();
		
		Text tc = fac.text("hi");
		assertTrue("hi" == tc.getText());
		assertTrue(hi == tc.getText());
		
		assertTrue(hi.equals(tc.getText()));
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy