List of usage examples for org.apache.hadoop.conf Configuration size
public int size()
From source file:org.apache.oozie.util.TestParameterVerifier.java
License:Apache License
public void testVerifyParametersNull() throws Exception { try {/*w w w . j av a 2 s . c om*/ ParameterVerifier.verifyParameters(null, XmlUtils.parseXml("<root xmlns=\"uri:oozie:workflow:0.4\"></root>")); fail(); } catch (IllegalArgumentException ex) { assertEquals("conf cannot be null", ex.getMessage()); } Configuration conf = new Configuration(false); conf.set("A", "a"); ParameterVerifier.verifyParameters(conf, null); assertEquals(1, conf.size()); assertEquals("a", conf.get("A")); try { ParameterVerifier.verifyParameters(null, null); } catch (IllegalArgumentException ex) { assertEquals("conf cannot be null", ex.getMessage()); } }
From source file:org.apache.oozie.util.TestParameterVerifier.java
License:Apache License
public void testVerifyParametersEmpty() throws Exception { Configuration conf = new Configuration(false); conf.set("A", "a"); ParameterVerifier.verifyParameters(conf, XmlUtils.parseXml("<root xmlns=\"uri:oozie:workflow:0.4\"></root>")); assertEquals(1, conf.size()); assertEquals("a", conf.get("A")); ParameterVerifier.verifyParameters(conf, XmlUtils.parseXml("<root xmlns=\"uri:oozie:workflow:0.4\">" + "<parameters></parameters></root>")); assertEquals(1, conf.size());//from w ww. j av a 2s . c om assertEquals("a", conf.get("A")); }
From source file:org.apache.oozie.util.TestParameterVerifier.java
License:Apache License
public void testVerifyParametersMissing() throws Exception { Configuration conf = new Configuration(false); String str = "<root xmlns=\"uri:oozie:workflow:0.4\"><parameters>" + "<property><name>hello</name></property>" + "</parameters></root>"; try {//from w w w .j a va 2 s.c om ParameterVerifier.verifyParameters(conf, XmlUtils.parseXml(str)); fail(); } catch (ParameterVerifierException ex) { assertEquals(ErrorCode.E0738, ex.getErrorCode()); assertTrue(ex.getMessage().endsWith("hello")); assertTrue(ex.getMessage().contains("1")); assertEquals(0, conf.size()); } conf = new Configuration(false); str = "<root xmlns=\"uri:oozie:workflow:0.4\"><parameters>" + "<property><name>hello</name><value>world</value></property>" + "</parameters></root>"; ParameterVerifier.verifyParameters(conf, XmlUtils.parseXml(str)); assertEquals(1, conf.size()); assertEquals("world", conf.get("hello")); conf = new Configuration(false); str = "<root xmlns=\"uri:oozie:workflow:0.4\"><parameters>" + "<property><name>hello</name></property>" + "<property><name>foo</name><value>bar</value></property>" + "<property><name>meh</name></property>" + "</parameters></root>"; try { ParameterVerifier.verifyParameters(conf, XmlUtils.parseXml(str)); fail(); } catch (ParameterVerifierException ex) { assertEquals(ErrorCode.E0738, ex.getErrorCode()); assertTrue(ex.getMessage().endsWith("hello, meh")); assertFalse(ex.getMessage().contains("foo")); assertTrue(ex.getMessage().contains("2")); assertEquals(1, conf.size()); assertEquals("bar", conf.get("foo")); } }
From source file:org.apache.oozie.util.TestParameterVerifier.java
License:Apache License
public void testVerifyParametersDefined() throws Exception { Configuration conf = new Configuration(false); conf.set("hello", "planet"); String str = "<root xmlns=\"uri:oozie:workflow:0.4\"><parameters>" + "<property><name>hello</name></property>" + "</parameters></root>"; ParameterVerifier.verifyParameters(conf, XmlUtils.parseXml(str)); assertEquals(1, conf.size()); assertEquals("planet", conf.get("hello")); str = "<root xmlns=\"uri:oozie:workflow:0.4\"><parameters>" + "<property><name>hello</name><value>world</value></property>" + "</parameters></root>"; ParameterVerifier.verifyParameters(conf, XmlUtils.parseXml(str)); assertEquals(1, conf.size());/* w ww . j a v a2 s .c om*/ assertEquals("planet", conf.get("hello")); }
From source file:org.apache.tez.common.TestTezUtils.java
License:Apache License
@Test(timeout = 2000) public void testByteStringToAndFromConf() throws IOException { Configuration conf = getConf(); Assert.assertEquals(conf.size(), 6); ByteString bsConf = TezUtils.createByteStringFromConf(conf); conf.clear();//from w w w. j a va 2s . co m Assert.assertEquals(conf.size(), 0); conf = TezUtils.createConfFromByteString(bsConf); Assert.assertEquals(conf.size(), 6); checkConf(conf); }
From source file:org.apache.tez.common.TestTezUtils.java
License:Apache License
@Test(timeout = 2000) public void testPayloadToAndFromConf() throws IOException { Configuration conf = getConf(); Assert.assertEquals(conf.size(), 6); UserPayload bConf = TezUtils.createUserPayloadFromConf(conf); conf.clear();//from ww w .ja va 2s .c o m Assert.assertEquals(conf.size(), 0); conf = TezUtils.createConfFromUserPayload(bConf); Assert.assertEquals(conf.size(), 6); checkConf(conf); }
From source file:test.SomeMainClass.java
License:Apache License
public static void main(String[] args) throws Exception { Configuration cfg = new Configuration(); cfg.size(); System.out.println("*** New Config is ***" + dumpConfiguration(cfg).toString()); System.getProperties().put("org.springframework.data.hadoop.jar.cfg", cfg); System.getProperties().put("org.springframework.data.hadoop.jar.args", args); System.setProperty("org.springframework.data.jar.exit.pre", "true"); try {//from w ww . j a v a 2 s.c o m System.exit(1); } catch (Throwable th) { System.getProperties().put("org.springframework.data.jar.exit.exception", th); } }
From source file:test.SomeOtherMainClass.java
License:Apache License
public static void main(String[] args) throws Exception { Configuration cfg = new Configuration(); cfg.size(); System.getProperties().put("org.springframework.data.hadoop.jar.other.args", args); System.getProperties().put("org.springframework.data.hadoop.jar.other.cfg", cfg); }