Java Code Examples for org.apache.log4j.SimpleLayout

The following are top voted examples for showing how to use org.apache.log4j.SimpleLayout. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: incubator-servicecomb-java-chassis   File: TestMicroservicePaths.java   Source Code and License 6 votes vote down vote up
@Test
public void testPrintPaths() {
  RestOperationMeta staticRes = UnitTestRestUtils.createRestOperationMeta("POST", "/static");
  RestOperationMeta dynamicRes = UnitTestRestUtils.createRestOperationMeta("POST", "/dynamic/{id}");

  MicroservicePaths paths = new MicroservicePaths();
  paths.addResource(staticRes);
  paths.addResource(dynamicRes);

  WriterAppender appender = new WriterAppender();
  Writer writer = new StringWriter();
  appender.setWriter(writer);
  appender.setLayout(new SimpleLayout());
  Logger.getRootLogger().addAppender(appender);

  paths.printPaths();

  String[] lines = writer.toString().split("\n");
  Assert.assertEquals("INFO - Swagger mapped \"{[/static], method=[POST], produces=[application/json]}\" onto null",
      lines[0].trim());
  Assert.assertEquals(
      "INFO - Swagger mapped \"{[/dynamic/{id}], method=[POST], produces=[application/json]}\" onto null",
      lines[1].trim());

  Logger.getRootLogger().removeAppender(appender);
}
 
Example 2
Project: LightSIP   File: DeliverNotifyBefore202Test.java   Source Code and License 6 votes vote down vote up
public Notifier(int port) throws Exception {
    this.port = port;
    Properties properties = new Properties();
    logger.addAppender(new FileAppender(new SimpleLayout(), "notifieroutputlog_" + port
            + ".txt"));

    properties.setProperty("javax.sip.STACK_NAME", "notifier" + port);
    // You need 16 for logging traces. 32 for debug + traces.
    // Your code will limp at 32 but it is best for debugging.
    properties.setProperty("gov.nist.javax.sip.TRACE_LEVEL", "32");
    properties.setProperty("gov.nist.javax.sip.DEBUG_LOG", "notifierdebug_" + port
            + ".txt");
    properties.setProperty("gov.nist.javax.sip.SERVER_LOG", "notifierlog_" + port
            + ".txt");
    if(System.getProperty("enableNIO") != null && System.getProperty("enableNIO").equalsIgnoreCase("true")) {
    	logger.info("\nNIO Enabled\n");
    	properties.setProperty("gov.nist.javax.sip.MESSAGE_PROCESSOR_FACTORY", NioMessageProcessorFactory.class.getName());
    }
    // Create SipStack object
    sipStack = sipFactory.createSipStack(properties);
    logger.info("sipStack = " + sipStack);
    this.createProvider( );
    this.udpProvider.addSipListener(this);
}
 
Example 3
Project: FunnySpider   File: SpiderApp.java   Source Code and License 6 votes vote down vote up
/**
 * 设置日志配置
 * @param level
 * @param fileName
 * @param append
 * @return this
 */
public SpiderApp setLogerConfig(int level,String fileName,boolean append,String configFilename){
	logMap.put("level", level);
	logMap.put("fileName", fileName);
	logMap.put("append",append);
	logMap.put("configFilename",configFilename);
	logger = Logger.getLogger(SpiderApp.class);
	Level logLevel = getLogLevel(level);
	try {
		FileAppender appender = new FileAppender(new SimpleLayout(), fileName,append);
		if(null == configFilename){
			BasicConfigurator.configure();
		}else{
			PropertyConfigurator.configure(configFilename);
		}
		logger.addAppender(appender);
		logger.setLevel(logLevel);
	} catch (IOException e) {
		e.printStackTrace(System.err);
	} 
	return this;
}
 
Example 4
Project: semtool   File: GraphToTreeConverterTest.java   Source Code and License 6 votes vote down vote up
@Test
public void testPrint() throws Exception {

	DirectedGraph<URI, URI> graph = new DirectedSparseGraph<>();
	graph.addVertex( YURI );
	graph.addVertex( YUGO );
	graph.addEdge( YPY, YURI, YUGO, EdgeType.DIRECTED );

	Collection<URI> roots = Arrays.asList( YURI );
	GraphToTreeConverter.Search search = GraphToTreeConverter.Search.DFS;
	Forest<URI, URI> result = GraphToTreeConverter.convert( graph, roots, search );

	Logger log = Logger.getLogger( GraphToTreeConverter.class );
	StringWriter stringy = new StringWriter();
	WriterAppender app = new WriterAppender( new SimpleLayout(), stringy );
	log.setLevel( Level.DEBUG );
	log.addAppender( app );
	GraphToTreeConverter.printForest( result );
	String output = stringy.toString().replaceAll( "\\s", "" );
	assertEquals( "DEBUG-http://semoss.va.gov/database/T44889381-85ce-43e3-893d-6267fd480660/YuriDEBUG-http://semoss.va.gov/database/T44889381-85ce-43e3-893d-6267fd480660/Yugo", output );
}
 
Example 5
Project: minesim   File: SpriteLoaderTests.java   Source Code and License 6 votes vote down vote up
/**
 * Tests that the right logger message is executed if the sprite file is
 * invalid.
 */
@Test
public void testMissingSprite() {
	// Set up of logger retrieval
	ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
	Layout layout = new SimpleLayout();
	Appender appender = new WriterAppender(layout, outputStream);
	LOGGER.addAppender(appender);

	// Valid file name
	String inValidSpriteFile = "Sprite asdfsdfSheet";
	SpriteLoader spriteLoader = new SpriteLoader();

	try {
		// The functions to test
		spriteLoader.loadSpriteSheet(inValidSpriteFile, 32, 32);
		spriteLoader.getSprite(1, 0);

		String logMessage = outputStream.toString();
		assertNotNull(logMessage);
		assertTrue(logMessage.contains("ERROR - You are trying to use a"));
	} finally {
		LOGGER.removeAppender(appender);
	}
}
 
Example 6
Project: minesim   File: SpriteLoaderTests.java   Source Code and License 6 votes vote down vote up
/**
 * Tests that the right logger message is executed if an incorrect position
 * (on the sprite sheet) is entered.
 */
@Test
public void testNegativeDimensions() {

	// Set up logger retrieval
	ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
	Layout layout = new SimpleLayout();
	Appender appender = new WriterAppender(layout, outputStream);
	LOGGER.addAppender(appender);

	// Valid file name
	String validSpriteFile = "peonSheet";
	SpriteLoader spriteLoader = new SpriteLoader();
	try {
		// The functions to test
		spriteLoader.loadSpriteSheet(validSpriteFile, 32, 32);
		spriteLoader.getSprite(-1, -1);

		String logMessage = outputStream.toString();
		assertNotNull(logMessage);
		assertTrue(logMessage.contains("ERROR - You are requesting a grid position"));
	} finally {
		LOGGER.removeAppender(appender);
	}
}
 
Example 7
Project: minesim   File: SpriteLoaderTests.java   Source Code and License 6 votes vote down vote up
/**
 * Tests that the right logger message is executed if an incorrect position
 * (on the sprite sheet) is entered.
 */
@Test
public void testPositiveDimensions() {

	// Set up logger retrieval
	ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
	Layout layout = new SimpleLayout();
	Appender appender = new WriterAppender(layout, outputStream);
	LOGGER.addAppender(appender);

	// Valid file name
	String validSpriteFile = "peonSheet";
	SpriteLoader spriteLoader = new SpriteLoader();
	try {
		// The functions to test
		spriteLoader.loadSpriteSheet(validSpriteFile, 32, 32);
		spriteLoader.getSprite(6, 6);

		String logMessage = outputStream.toString();
		assertNotNull(logMessage);
		assertTrue(logMessage.contains("ERROR - You are requesting a grid position"));
	} finally {
		LOGGER.removeAppender(appender);
	}
}
 
Example 8
Project: minesim   File: SpriteLoaderTests.java   Source Code and License 6 votes vote down vote up
/**
 * Tests that the right logger message is executed if an invalid specified
 * sprite dimension is entered.
 */
@Test
public void testInvalidSpriteSheetDimensions() {

	// Set up logger retrieval
	ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
	Layout layout = new SimpleLayout();
	Appender appender = new WriterAppender(layout, outputStream);
	LOGGER.addAppender(appender);

	// Valid file name
	String validSpriteFile = "peonSheet";
	SpriteLoader spriteLoader = new SpriteLoader();
	try {
		// The functions to test
		spriteLoader.loadSpriteSheet(validSpriteFile, 13, 13);
		spriteLoader.getSprite(1, 0);

		String logMessage = outputStream.toString();
		assertNotNull(logMessage);
		assertTrue(logMessage.contains("WARN - Your file is not a multiple of"));
	} finally {
		LOGGER.removeAppender(appender);
	}
}
 
Example 9
Project: minesim   File: SpriteLoaderTests.java   Source Code and License 6 votes vote down vote up
/**
 * Tests that no logger message is executed if valid specified sprite
 * dimensions are entered.
 */
@Test
public void testValidSpriteDimensions() {
	// Set up logger retrieval
	ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
	Layout layout = new SimpleLayout();
	Appender appender = new WriterAppender(layout, outputStream);
	LOGGER.addAppender(appender);

	// Valid file name
	String validSpriteFile = "peonSheet";
	SpriteLoader spriteLoader = new SpriteLoader();
	try {
		// The functions to test
		spriteLoader.loadSpriteSheet(validSpriteFile, 32, 32);
		spriteLoader.getSprite(1, 0);

		String logMessage = outputStream.toString();
		assertEquals("", logMessage);// should be empty
	} finally {
		LOGGER.removeAppender(appender);
	}
}
 
Example 10
Project: minesim   File: SpriteLoaderTests.java   Source Code and License 6 votes vote down vote up
/**
 * Tests that the right logger message is executed if a null sprite sheet
 * file name is entered (i.e. does not exist due to trolling, typos)
 */
@Test
public void testNullSpriteSheet() {
	// Set up logger retrieval
	ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
	Layout layout = new SimpleLayout();
	Appender appender = new WriterAppender(layout, outputStream);
	LOGGER.addAppender(appender);

	// Null file name
	String nullSpriteFile = null;
	SpriteLoader spriteLoader = new SpriteLoader();

	try {
		// The function to test
		spriteLoader.loadSpriteSheet(nullSpriteFile, 32, 32);
		assertNull(nullSpriteFile);

		String logMessage = outputStream.toString();
		assertNotNull(logMessage);
		assertTrue(logMessage.contains("ERROR - Could not load file"));

	} finally {
		LOGGER.removeAppender(appender);
	}
}
 
Example 11
Project: minesim   File: SpriteLoaderTests.java   Source Code and License 6 votes vote down vote up
/**
 * Tests that the right logger message is executed if an invalid sprite
 * sheet file name is entered (i.e. does not exist due to trolling, typos)
 */
@Test
public void testInvalidSpriteSheet() {
	// Set up logger retrieval
	ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
	Layout layout = new SimpleLayout();
	Appender appender = new WriterAppender(layout, outputStream);
	LOGGER.addAppender(appender);

	// Invalid file name
	String invalidSpriteFile = "invalid name";
	SpriteLoader spriteLoader = new SpriteLoader();

	try {
		// The function to test
		spriteLoader.loadSpriteSheet(invalidSpriteFile, 32, 32);

		String logMessage = outputStream.toString();
		assertNotNull(logMessage);
		assertTrue(logMessage.contains("ERROR - Could not load file"));
	} finally {
		LOGGER.removeAppender(appender);
	}
}
 
Example 12
Project: minesim   File: SpriteLoaderTests.java   Source Code and License 6 votes vote down vote up
/**
 * Tests that no logger message is executed if a valid sprite sheet is
 * entered
 */
@Test
public void testValidSpriteSheet() {
	// Set up logger retrieval
	ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
	Layout layout = new SimpleLayout();
	Appender appender = new WriterAppender(layout, outputStream);
	LOGGER.addAppender(appender);

	// Valid file name
	String validSpriteFile = "peonSheet";
	SpriteLoader spriteLoader = new SpriteLoader();

	try {
		// The function to test
		spriteLoader.loadSpriteSheet(validSpriteFile, 32, 32);
		assertNotNull(validSpriteFile);
		String logMessage = outputStream.toString();
		assertNotNull(logMessage);
		assertEquals("", logMessage);// should be empty
	} finally {
		LOGGER.removeAppender(appender);
	}
}
 
Example 13
Project: minesim   File: FrameTests.java   Source Code and License 6 votes vote down vote up
/**
 * Tests that no logger message is executed for a valid frame setup.
 */
@Test
public void validFrameInitialisation() {
	// Set up of logger retrieval
	ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
	Layout layout = new SimpleLayout();
	Appender appender = new WriterAppender(layout, outputStream);
	LOGGER.addAppender(appender);

	Image mockSprite = mock(Image.class);

	try {
		// The functions to test
		frame = new Frame(mockSprite, 10);
		assertNotNull(frame.getFrame());
		assertTrue(frame.getDuration() == 10);

		String logMessage = outputStream.toString();
		assertNotNull(logMessage);
		assertEquals("", logMessage);
	} finally {
		LOGGER.removeAppender(appender);
	}
}
 
Example 14
Project: minesim   File: FrameTests.java   Source Code and License 6 votes vote down vote up
/**
 * Tests that getters are not null if there is a valid Frame initilisation.
 */
@Test
public void validGetters() {
	// Set up of logger retrieval
	ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
	Layout layout = new SimpleLayout();
	Appender appender = new WriterAppender(layout, outputStream);
	LOGGER.addAppender(appender);

	Image mockSprite = mock(Image.class);

	try {
		// The functions to test
		frame = new Frame(mockSprite, 10);
		assertNotNull(frame.getFrame());
		assertNotNull(frame.getDuration());

		String logMessage = outputStream.toString();
		assertNotNull(logMessage);
		assertEquals("", logMessage);
	} finally {
		LOGGER.removeAppender(appender);
	}
}
 
Example 15
Project: minesim   File: FrameTests.java   Source Code and License 6 votes vote down vote up
/**
 * Tests that the appropriate error message is displayed if the frame image
 * is null.
 */
@Test
public void inValidFrame() {
	// Set up of logger retrieval
	ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
	Layout layout = new SimpleLayout();
	Appender appender = new WriterAppender(layout, outputStream);
	LOGGER.addAppender(appender);

	try {
		// The functions to test
		frame = new Frame(null, 10);
		assertNull(frame.getFrame());

		String logMessage = outputStream.toString();
		assertNotNull(logMessage);
		assertTrue(logMessage.contains("ERROR - You cannot have null frames"));
	} finally {
		LOGGER.removeAppender(appender);
	}
}
 
Example 16
Project: minesim   File: FrameTests.java   Source Code and License 6 votes vote down vote up
/**
 * Tests that the appropriate logger message is executed if the duration is
 * less than or equal to 0.
 */
@Test
public void inValidDuration() {
	// Set up of logger retrieval
	ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
	Layout layout = new SimpleLayout();
	Appender appender = new WriterAppender(layout, outputStream);
	LOGGER.addAppender(appender);

	Image mockSprite = mock(Image.class);

	try {
		// The functions to test
		frame = new Frame(mockSprite, 0);
		assertTrue(frame.getDuration() == 0);

		String logMessage = outputStream.toString();
		assertNotNull(logMessage);
		assertTrue(logMessage.contains("ERROR - You cannot have a duration equal to or less than 0"));
	} finally {
		LOGGER.removeAppender(appender);
	}
}
 
Example 17
Project: minesim   File: FrameTests.java   Source Code and License 6 votes vote down vote up
/**
 * Tests that the appropriate logger message is executed if the duration is
 * set to be less than or equal to 0.
 */
@Test
public void invalidSettersDuration() {
	// Set up of logger retrieval
	ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
	Layout layout = new SimpleLayout();
	Appender appender = new WriterAppender(layout, outputStream);
	LOGGER.addAppender(appender);

	Image mockSprite = mock(Image.class);
	frame = new Frame(mockSprite, 10);

	try {
		// The functions to test
		assertTrue(frame.getDuration() == 10);
		frame.setDuration(-1);
		assertTrue(frame.getDuration() == 10);

		String logMessage = outputStream.toString();
		assertNotNull(logMessage);
		assertTrue(logMessage.contains("ERROR - You cannot have a duration"));
	} finally {
		LOGGER.removeAppender(appender);
	}
}
 
Example 18
Project: minesim   File: FrameTests.java   Source Code and License 6 votes vote down vote up
/**
 * Tests that no logger message is executed if the duration is set to a
 * valid number.
 */
@Test
public void validSettersDuration() {
	// Set up of logger retrieval
	ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
	Layout layout = new SimpleLayout();
	Appender appender = new WriterAppender(layout, outputStream);
	LOGGER.addAppender(appender);

	Image mockSprite = mock(Image.class);
	frame = new Frame(mockSprite, 10);

	try {
		// The functions to test
		assertTrue(frame.getDuration() == 10);
		frame.setDuration(20);
		assertTrue(frame.getDuration() == 20);

		String logMessage = outputStream.toString();
		assertNotNull(logMessage);
		assertEquals("", logMessage);
	} finally {
		LOGGER.removeAppender(appender);
	}
}
 
Example 19
Project: minesim   File: FrameTests.java   Source Code and License 6 votes vote down vote up
/**
 * Tests that the appropriate logger message is executed if the frame is set
 * to null.
 */
@Test
public void invalidSettersFrame() {
	// Set up of logger retrieval
	ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
	Layout layout = new SimpleLayout();
	Appender appender = new WriterAppender(layout, outputStream);
	LOGGER.addAppender(appender);

	Image mockSprite = mock(Image.class);
	frame = new Frame(mockSprite, 10);

	try {
		// The functions to test
		assertEquals(mockSprite, frame.getFrame());
		frame.setFrame(null);
		assertEquals(mockSprite, frame.getFrame());

		String logMessage = outputStream.toString();
		assertNotNull(logMessage);
		assertTrue(logMessage.contains("ERROR - You cannot have null frames"));
	} finally {
		LOGGER.removeAppender(appender);
	}
}
 
Example 20
Project: minesim   File: FrameTests.java   Source Code and License 6 votes vote down vote up
/**
 * Tests that no logger message is executed if the frame is set to a valid
 * image.
 */
@Test
public void validSettersFrame() {
	// Set up of logger retrieval
	ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
	Layout layout = new SimpleLayout();
	Appender appender = new WriterAppender(layout, outputStream);
	LOGGER.addAppender(appender);

	Image mockSprite = mock(Image.class);
	Image mockSprite2 = mock(Image.class);
	frame = new Frame(mockSprite, 10);

	try {
		// The functions to test
		assertEquals(mockSprite, frame.getFrame());
		frame.setFrame(mockSprite2);
		assertEquals(mockSprite2, frame.getFrame());

		String logMessage = outputStream.toString();
		assertNotNull(logMessage);
		assertEquals("", logMessage);
	} finally {
		LOGGER.removeAppender(appender);
	}
}
 
Example 21
Project: minesim   File: AnimationTests.java   Source Code and License 6 votes vote down vote up
/**
 * Tests that the right logger message is executed if an invalid animation
 * initialisation is written (namely invalid duration is entered)
 */
@Test
public void invalidAnimationInitialisation() {
	// Set up of logger retrieval
	ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
	Layout layout = new SimpleLayout();
	Appender appender = new WriterAppender(layout, outputStream);
	LOGGER.addAppender(appender);

	Image mockSprite = mock(Image.class);
	standingRight.add(mockSprite);

	try {
		// The functions to test
		animation = new Animation(standingRight, 0);

		String logMessage = outputStream.toString();
		assertNotNull(logMessage);
		assertTrue(logMessage.contains("ERROR - You cannot have a duration"));
	} finally {
		LOGGER.removeAppender(appender);
	}
}
 
Example 22
Project: minesim   File: AnimationTests.java   Source Code and License 6 votes vote down vote up
/**
 * Tests that the right logger message is executed if an invalid animation
 * initialisation is written (namely invalid frames entered)
 */
@Test
public void invalidFramesAnimationInitialisation() {
	// Set up of logger retrieval
	ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
	Layout layout = new SimpleLayout();
	Appender appender = new WriterAppender(layout, outputStream);
	LOGGER.addAppender(appender);

	Image mockSprite = mock(Image.class);
	standingRight.add(mockSprite);

	try {
		// The functions to test
		animation = new Animation(null, 10);

		String logMessage = outputStream.toString();
		assertNotNull(logMessage);
		assertTrue(logMessage.contains("ERROR - You cannot have null frames"));
	} finally {
		LOGGER.removeAppender(appender);
	}
}
 
Example 23
Project: minesim   File: AnimationTests.java   Source Code and License 6 votes vote down vote up
/**
 * Tests that the right logger message is executed if stop function is
 * executed incorrectly (namely invalid frames: null)
 */
@Test
public void testInvalidStop() {
	// Set up of logger retrieval
	ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
	Layout layout = new SimpleLayout();
	Appender appender = new WriterAppender(layout, outputStream);
	LOGGER.addAppender(appender);

	Image mockSprite = mock(Image.class);
	standingRight.add(mockSprite);
	animation = new Animation(null, 10);

	try {
		// The functions to test
		assertTrue(animation.getStopped());
		assertTrue(animation.getFrames().size() <= 0);
		animation.stop();

		String logMessage = outputStream.toString();
		assertNotNull(logMessage);
		assertTrue(logMessage.contains("ERROR - You cannot have null frames"));
	} finally {
		LOGGER.removeAppender(appender);
	}
}
 
Example 24
Project: wot_gateways   File: BasicMulticastSocketHandler.java   Source Code and License 6 votes vote down vote up
public BasicMulticastSocketHandler(ChannelManager channelManager,
		int port, InetAddress multicastIP) throws IOException {
	logger.addAppender(new ConsoleAppender(new SimpleLayout()));
	// ALL | DEBUG | INFO | WARN | ERROR | FATAL | OFF:
	logger.setLevel(Level.WARN);

	NetworkInterface interf = NetworkInterface.getByInetAddress(InetAddress.getLocalHost());
	//NetworkInterface interf = NetworkInterface.getByName("eth0");
	
	this.channelManager = channelManager;
	mcastChannel = DatagramChannel.open(StandardProtocolFamily.INET);
	mcastChannel.setOption(StandardSocketOptions.SO_REUSEADDR, true);
	mcastChannel.bind(new InetSocketAddress(port));		
	mcastChannel.setOption(StandardSocketOptions.IP_MULTICAST_IF, interf);
	mcastChannel.join(multicastIP, interf);
	mcastChannel.configureBlocking(false);

	this.localPort = mcastChannel.socket().getLocalPort();
	this.localAddr = multicastIP;

	workerThread = new WorkerThread();
	workerThread.start();
}
 
Example 25
Project: semweb4j   File: RdfSClassGenerator.java   Source Code and License 6 votes vote down vote up
private void generateCode() throws MojoExecutionException, MojoFailureException {
	try {
	    // make sure that directory for log file exists.
	    rdfReactorLogfile.getParentFile().mkdirs();
		
	    // configure logging infrastructure for RDFReactor
	    FileAppender logFileAppender = new FileAppender(new SimpleLayout(), rdfReactorLogfile.getAbsolutePath());
		BasicConfigurator.configure(logFileAppender);

	} catch (IOException ioe) {
		throw new MojoExecutionException("Cannot open log file for writing RDFReactor log messages", ioe);
	}

	getLog().info("Generating code from RDF schema file " + schemaFile + " into dir " + outputDirectory
			+ ". Classes will be in package " + packageName + " and with method prefix " + methodPrefix +". skipBuiltins is " + skipBuiltins + ".");
	getLog().info("RDFReactor's log messages are written to " + rdfReactorLogfile);


	try {
		CodeGenerator.generate(schemaFile.getAbsolutePath(), outputDirectory.getAbsolutePath(), packageName, Reasoning.rdfs, skipBuiltins, methodPrefix);
	} catch (Exception e) {
		e.printStackTrace();
	    throw new MojoFailureException(e, "RDFS processing error", "Could not generate code from the specified RDF schema file.");
	}
}
 
Example 26
Project: carbon-commons   File: LoggingUtilTest.java   Source Code and License 6 votes vote down vote up
@Test(groups = {"org.wso2.carbon.logging.service.util"},
        description = "Tests whether the Appender with the specified name is returned from " +
                "LoggingUtil.getAppenderFromSet method given that the Appender set contains an appender " +
                "without a name.")
public void testGettingAppenderFromAppenderSet() {
    Appender appenderWithoutName = new ConsoleAppender(new SimpleLayout());

    Appender appenderWithName = new ConsoleAppender(new SimpleLayout());
    appenderWithName.setName(APPENDER_NAME);

    Set<Appender> appenderSet = new LinkedHashSet<>();
    appenderSet.add(appenderWithoutName);
    appenderSet.add(appenderWithName);

    Assert.assertEquals(appenderWithName, LoggingUtil.getAppenderFromSet(appenderSet, APPENDER_NAME),
            "Appender with the name " + APPENDER_NAME + " is not returned from getAppenderFromSet method.");
}
 
Example 27
Project: spork   File: TestAutoLocalMode.java   Source Code and License 6 votes vote down vote up
@Before
public void setUp() throws Exception{
    pigServer = new PigServer(ExecType.MAPREDUCE, cluster.getProperties());
    pigServer.getPigContext().getExecutionEngine().setProperty(PigConfiguration.PIG_OPT_FETCH, "false");
    pigServer.getPigContext().getExecutionEngine().setProperty(PigConfiguration.PIG_AUTO_LOCAL_ENABLED, String.valueOf("true"));
    pigServer.getPigContext().getExecutionEngine().setProperty(PigConfiguration.PIG_AUTO_LOCAL_INPUT_MAXBYTES, "200");

    Logger logger = Logger.getLogger(JobControlCompiler.class);
    logger.removeAllAppenders();
    logger.setLevel(Level.INFO);
    SimpleLayout layout = new SimpleLayout();
    logFile = File.createTempFile("log", "");
    FileAppender appender = new FileAppender(layout, logFile.toString(), false, false, 0);
    logger.addAppender(appender);

    miniFileName = createInputFile("miniFile", 10).getAbsolutePath();
    smallFileName = createInputFile("smallFile", 100).getAbsolutePath();
    bigFileName = createInputFile("bigFile", 1000).getAbsolutePath();
}
 
Example 28
Project: andes   File: LogMonitor.java   Source Code and License 6 votes vote down vote up
/**
 * Create a new LogMonitor on the specified file if the file does not exist
 * or the value is null then a new Log4j appender will be added and
 * monitoring set up on that appender.
 *
 * NOTE: for the appender to receive any value the RootLogger will need to
 * have the level correctly configured.ng
 *
 * @param file the file to monitor
 *
 * @throws IOException if there is a problem creating a temporary file
 */
public LogMonitor(File file) throws IOException
{
    if (file != null && file.exists())
    {
        _logfile = file;
    }
    else
    {
        // This is mostly for running the test outside of the ant setup
        _logfile = File.createTempFile("LogMonitor", ".log");
        _appender = new FileAppender(new SimpleLayout(),
                                                 _logfile.getAbsolutePath());
        _appender.setFile(_logfile.getAbsolutePath());
        _appender.setImmediateFlush(true);
        Logger.getRootLogger().addAppender(_appender);
    }
}
 
Example 29
Project: jcabi-log   File: VerboseProcessTest.java   Source Code and License 6 votes vote down vote up
/**
 * VerboseProcess.stdoutQuietly() should log stderr messages.
 * @throws Exception If something goes wrong
 */
@Test
public void stdoutQuietlyLogsErrors() throws Exception {
    final StringWriter writer = new StringWriter();
    org.apache.log4j.Logger.getRootLogger().addAppender(
        new WriterAppender(new SimpleLayout(), writer)
    );
    final ProcessBuilder builder;
    final String message = "hello dear friend";
    if (SystemUtils.IS_OS_WINDOWS) {
        builder = new ProcessBuilder("cmd", "/c", "echo", message, "1>&2");
    } else {
        builder = new ProcessBuilder(
            "cat", String.format("/non-existing-file-%s ", message)
        );
    }
    final VerboseProcess process = new VerboseProcess(
        builder, Level.OFF, Level.WARNING
    );
    process.stdoutQuietly();
    MatcherAssert.assertThat(
        writer.toString(),
        Matchers.containsString(message)
    );
}
 
Example 30
Project: lightmare   File: Configure.java   Source Code and License 6 votes vote down vote up
public static void configure() {

        Logger logger = Logger.getRootLogger();
        Appender appender = logger.getAppender("CA");
        logger.removeAppender(appender);

        logger.info("Curr " + System.getProperty("user.dir"));
        logger.info("This is info should print to console");
        logger.debug("This is debug should print to console");

        SimpleLayout layout = new SimpleLayout();
        ConsoleAppender console = new ConsoleAppender(layout);

        logger.addAppender(console);
        logger.warn("This is warning should print to file and console");

        logger.setLevel(Level.INFO);
    }
 
Example 31
Project: jcabi-aspects   File: LoggableTest.java   Source Code and License 6 votes vote down vote up
/**
 * Loggable can log byte array results.
 */
@Test
public void logsByteArray() {
    final StringWriter writer = new StringWriter();
    org.apache.log4j.Logger.getRootLogger().addAppender(
        new WriterAppender(new SimpleLayout(), writer)
    );
    final byte[] result = new LoggableTest.Foo().logsByteArray();
    MatcherAssert.assertThat(
        writer.toString(),
        Matchers.not(
            Matchers.containsString(
                ClassCastException.class.getSimpleName()
            )
        )
    );
    final Collection<String> bytes = new LinkedList<String>();
    for (final byte part : result) {
        bytes.add(Byte.toString(part));
    }
    MatcherAssert.assertThat(
        writer.toString(),
        Matchers.stringContainsInOrder(bytes)
    );
}
 
Example 32
Project: jcabi-aspects   File: LoggableTest.java   Source Code and License 6 votes vote down vote up
/**
 * Loggable can log short array results.
 */
@Test
public void logsShortArray() {
    final StringWriter writer = new StringWriter();
    org.apache.log4j.Logger.getRootLogger().addAppender(
        new WriterAppender(new SimpleLayout(), writer)
    );
    final short[] result = new LoggableTest.Foo().logsShortArray();
    MatcherAssert.assertThat(
        writer.toString(),
        Matchers.not(
            Matchers.containsString(
                ClassCastException.class.getSimpleName()
            )
        )
    );
    final Collection<String> shorts = new LinkedList<String>();
    for (final short part : result) {
        shorts.add(Short.toString(part));
    }
    MatcherAssert.assertThat(
        writer.toString(),
        Matchers.stringContainsInOrder(shorts)
    );
}
 
Example 33
Project: SigFW   File: AbstractSctpBase.java   Source Code and License 5 votes vote down vote up
public void init() {
    try {
        Properties tckProperties = new Properties();

        InputStream inStreamLog4j = AbstractSctpBase.class.getResourceAsStream("/log4j.properties");

        System.out.println("Input Stream = " + inStreamLog4j);

        Properties propertiesLog4j = new Properties();
        try {
            propertiesLog4j.load(inStreamLog4j);
            PropertyConfigurator.configure(propertiesLog4j);
        } catch (IOException e) {
            e.printStackTrace();
            BasicConfigurator.configure();
        }

        logger.debug("log4j configured");

        String lf = System.getProperties().getProperty(LOG_FILE_NAME);
        if (lf != null) {
            logFileName = lf;
        }

        // If already created a print writer then just use it.
        try {
            logger.addAppender(new FileAppender(new SimpleLayout(), logFileName));
        } catch (FileNotFoundException fnfe) {

        }
    } catch (Exception ex) {
        ex.printStackTrace();
        throw new RuntimeException(ex);
    }

}
 
Example 34
Project: LightSIP   File: Shootme.java   Source Code and License 5 votes vote down vote up
public static void main(String args[]) throws Exception {
    Shootme shootme = new Shootme(new ProtocolObjects("shootme", true,"udp",""));
    logger.addAppender(new ConsoleAppender(new SimpleLayout()));
    shootme.createProvider();
    shootme.sipProvider.addSipListener(shootme);

}
 
Example 35
Project: LightSIP   File: Shootist.java   Source Code and License 5 votes vote down vote up
public static void main(String args[]) throws Exception {
    ProtocolObjects  protocolObjects = new ProtocolObjects ("shootist",true,"udp","");
    logger.addAppender(new ConsoleAppender(new SimpleLayout()));
    Shootist shootist = new Shootist(protocolObjects);
    shootist.createProvider();
    shootist.sipProvider.addSipListener(shootist);
    shootist.sendInvite();

}
 
Example 36
Project: LightSIP   File: Shootme.java   Source Code and License 5 votes vote down vote up
public static void main(String args[])throws Exception  {
    logger.addAppender(new ConsoleAppender(new SimpleLayout()));
    ProtocolObjects.init("shootme");
    Shootme shootme = new Shootme();
    shootme.createProvider();
    shootme.sipProvider.addSipListener(shootme);
}
 
Example 37
Project: LightSIP   File: Shootist.java   Source Code and License 5 votes vote down vote up
public static void main(String args[]) throws Exception {

        logger.addAppender(new ConsoleAppender(new SimpleLayout()));
        ProtocolObjects.init("shootist");
        Shootist shootist = new Shootist();
        shootist.createSipProvider();
        shootist.sipProvider.addSipListener(shootist);
        shootist.sendInvite();

    }
 
Example 38
Project: LightSIP   File: Shootme.java   Source Code and License 5 votes vote down vote up
public static void main(String args[]) throws Exception {
    int myPort = new Integer(args[0]).intValue();

    logger.addAppender(new ConsoleAppender(new SimpleLayout()));
    ProtocolObjects.init("shootme_"+myPort,true);
    Shootme shootme = new Shootme(myPort);
    shootme.createProvider();
    shootme.sipProvider.addSipListener(shootme);
}
 
Example 39
Project: LightSIP   File: Shootist.java   Source Code and License 5 votes vote down vote up
public static void main(String args[]) throws Exception {
    logger.addAppender(new ConsoleAppender(new SimpleLayout()));
    ProtocolObjects.init("shootist",true);
    Shootist shootist = new Shootist();
    shootist.createSipProvider();
    shootist.sipProvider.addSipListener(shootist);
    shootist.sendInvite();

}
 
Example 40
Project: LightSIP   File: Proxy.java   Source Code and License 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    logger.addAppender(new ConsoleAppender(new SimpleLayout()));
    ProtocolObjects.init("proxy",false);
    Proxy proxy = new Proxy();
    proxy.createSipProvider();
    proxy.sipProvider.addSipListener(proxy);


}
 
Example 41
Project: LightSIP   File: Shootme.java   Source Code and License 5 votes vote down vote up
public static void main(String args[]) throws Exception {
    logger.addAppender( new ConsoleAppender(new SimpleLayout()));
    ProtocolObjects.init("shootme", true);
    Shootme shootme = new Shootme();
    shootme.createSipProvider().addSipListener(shootme);

}
 
Example 42
Project: LightSIP   File: Shootist.java   Source Code and License 5 votes vote down vote up
public static void main(String args[]) {
    try {
        ProtocolObjects.init("shootist", true);
        logger.addAppender(new ConsoleAppender(new SimpleLayout()));
        Shootist shootist = new Shootist(10);
        shootist.createSipProvider();
        shootist.provider.addSipListener(shootist);
        shootist.sendInvite();
    } catch (Exception ex) {
        ex.printStackTrace();
    }

}
 
Example 43
Project: LightSIP   File: DeliverNotifyBefore202Test.java   Source Code and License 5 votes vote down vote up
public Subscriber(int notifierPort, int port) throws Exception {
    this.notifierPort = notifierPort;
    this.port = port;
    logger.addAppender(new FileAppender(new SimpleLayout(), "subscriberoutputlog_" + port
            + ".txt"));
    
    Properties properties = new Properties();

    properties.setProperty("javax.sip.STACK_NAME", "subscriber" + port);
    // You need 16 for logging traces. 32 for debug + traces.
    // Your code will limp at 32 but it is best for debugging.
    properties.setProperty("gov.nist.javax.sip.TRACE_LEVEL", "32");
    properties.setProperty("gov.nist.javax.sip.DEBUG_LOG", "subscriberdebug_" + port
            + ".txt");
    properties.setProperty("gov.nist.javax.sip.SERVER_LOG", "subscriberlog_" + port
            + ".txt");
    if(System.getProperty("enableNIO") != null && System.getProperty("enableNIO").equalsIgnoreCase("true")) {
    	logger.info("\nNIO Enabled\n");
    	properties.setProperty("gov.nist.javax.sip.MESSAGE_PROCESSOR_FACTORY", NioMessageProcessorFactory.class.getName());
    }
    // Create SipStack object
    sipStack = sipFactory.createSipStack(properties);
    logger.info("sipStack = " + sipStack);
    this.createProvider( );
    this.udpProvider.addSipListener(this);
    
}
 
Example 44
Project: LightSIP   File: Shootme.java   Source Code and License 5 votes vote down vote up
public static void main(String args[]) throws Exception {
    logger.addAppender(new ConsoleAppender(new SimpleLayout()));
    ProtocolObjects protocolObjects = new ProtocolObjects("shootme",
            "gov.nist", "udp", true,false, false);

    Shootme shootme = new Shootme(protocolObjects);
    shootme.createSipProvider().addSipListener(shootme);

}
 
Example 45
Project: LightSIP   File: Shootme.java   Source Code and License 5 votes vote down vote up
public static void main(String args[]) throws Exception {
    logger.addAppender( new ConsoleAppender(new SimpleLayout()));
    ProtocolObjects protocolObjects = new ProtocolObjects("shootme", "gov.nist","udp",true,false, false);

    Shootme shootme = new Shootme(protocolObjects);
    shootme.createSipProvider().addSipListener(shootme);

}
 
Example 46
Project: LightSIP   File: Shootme.java   Source Code and License 5 votes vote down vote up
public static void main(String args[]) throws Exception {
    logger.addAppender( new ConsoleAppender(new SimpleLayout()));
    ProtocolObjects protocolObjects = new ProtocolObjects("shootme", "gov.nist","udp",true,false, false);

    Shootme shootme = new Shootme(protocolObjects);
    shootme.createSipProvider().addSipListener(shootme);

}
 
Example 47
Project: LightSIP   File: Shootme.java   Source Code and License 5 votes vote down vote up
public static void main(String args[]) throws Exception {
    logger.addAppender( new ConsoleAppender(new SimpleLayout()));
    ProtocolObjects protocolObjects = new ProtocolObjects("shootme", "gov.nist","udp",true,false, false);

    Shootme shootme = new Shootme(protocolObjects);
    shootme.createSipProvider().addSipListener(shootme);

}
 
Example 48
Project: LightSIP   File: Shootme.java   Source Code and License 5 votes vote down vote up
public static void main(String args[]) throws Exception {
    logger.addAppender( new ConsoleAppender(new SimpleLayout()));
    ProtocolObjects protocolObjects = new ProtocolObjects("shootme", "gov.nist","udp",true,false, false);

    Shootme shootme = new Shootme(protocolObjects);
    shootme.createSipProvider().addSipListener(shootme);

}
 
Example 49
Project: LightSIP   File: Shootme.java   Source Code and License 5 votes vote down vote up
public static void main(String args[]) throws Exception {
    logger.addAppender( new ConsoleAppender(new SimpleLayout()));
    ProtocolObjects protocolObjects = new ProtocolObjects("shootme", "gov.nist","udp",true,false, false);

    Shootme shootme = new Shootme(protocolObjects);
    shootme.createSipProvider().addSipListener(shootme);

}
 
Example 50
Project: LightSIP   File: Shootme.java   Source Code and License 5 votes vote down vote up
public static void main(String args[]) throws Exception {
    logger.addAppender( new ConsoleAppender(new SimpleLayout()));
    ProtocolObjects protocolObjects = new ProtocolObjects("shootme", "gov.nist","udp",true,false, false);

    Shootme shootme = new Shootme(protocolObjects);
    shootme.createSipProvider().addSipListener(shootme);

}
 
Example 51
Project: LightSIP   File: Shootme.java   Source Code and License 5 votes vote down vote up
public static void main(String args[]) throws Exception {
    logger.addAppender( new ConsoleAppender(new SimpleLayout()));
    ProtocolObjects protocolObjects = new ProtocolObjects("shootme", "gov.nist","udp",true,false, false);

    Shootme shootme = new Shootme(protocolObjects);
    shootme.createSipProvider().addSipListener(shootme);

}
 
Example 52
Project: LightSIP   File: Shootme.java   Source Code and License 5 votes vote down vote up
public static void main(String args[]) throws Exception {
    logger.addAppender( new ConsoleAppender(new SimpleLayout()));
    ProtocolObjects protocolObjects = new ProtocolObjects("shootme", "gov.nist","udp",true,false, false);

    Shootme shootme = new Shootme(protocolObjects);
    shootme.createSipProvider().addSipListener(shootme);

}
 
Example 53
Project: LightSIP   File: Shootme.java   Source Code and License 5 votes vote down vote up
public static void main(String args[]) throws Exception {
    logger.addAppender( new ConsoleAppender(new SimpleLayout()));
    ProtocolObjects protocolObjects = new ProtocolObjects("shootme", "gov.nist","udp",true,false, false);

    Shootme shootme = new Shootme(protocolObjects);
    shootme.createSipProvider().addSipListener(shootme);

}
 
Example 54
Project: SigPloit   File: SriSMLowLevelServer.java   Source Code and License 5 votes vote down vote up
public void init() {
    try {


        InputStream inStreamLog4j = SriSMLowLevelServer.class.getResourceAsStream("log4j.properties");

        System.out.println("Input Stream = " + inStreamLog4j);

        Properties propertiesLog4j = new Properties();
        try {
            propertiesLog4j.load(inStreamLog4j);
            PropertyConfigurator.configure(propertiesLog4j);
        } catch (IOException e) {
            e.printStackTrace();
            BasicConfigurator.configure();
        }

        logger.debug("log4j configured");

        String lf = System.getProperties().getProperty(LOG_FILE_NAME);
        if (lf != null) {
            logFileName = lf;
        }

        // If already created a print writer then just use it.
        try {
            logger.addAppender(new FileAppender(new SimpleLayout(), logFileName));
        } catch (FileNotFoundException fnfe) {

        }
    } catch (Exception ex) {
        ex.printStackTrace();
        throw new RuntimeException(ex);
    }

}
 
Example 55
Project: SigPloit   File: SRIGPRSLowLevel.java   Source Code and License 5 votes vote down vote up
public void init() {
    try {


        InputStream inStreamLog4j = SRIGPRSLowLevel.class.getResourceAsStream("log4j.properties");

        System.out.println("Input Stream = " + inStreamLog4j);

        Properties propertiesLog4j = new Properties();
        try {
            propertiesLog4j.load(inStreamLog4j);
            PropertyConfigurator.configure(propertiesLog4j);
        } catch (IOException e) {
            e.printStackTrace();
            BasicConfigurator.configure();
        }

        logger.debug("log4j configured");

        String lf = System.getProperties().getProperty(LOG_FILE_NAME);
        if (lf != null) {
            logFileName = lf;
        }

        // If already created a print writer then just use it.
        try {
            logger.addAppender(new FileAppender(new SimpleLayout(), logFileName));
        } catch (FileNotFoundException fnfe) {

        }
    } catch (Exception ex) {
        ex.printStackTrace();
        throw new RuntimeException(ex);
    }

}
 
Example 56
Project: SigPloit   File: UlLowLevel.java   Source Code and License 5 votes vote down vote up
public void init() {
    try {
        Properties tckProperties = new Properties();

        InputStream inStreamLog4j = UlLowLevel.class.getResourceAsStream("log4j.properties");

        System.out.println("Input Stream = " + inStreamLog4j);

        Properties propertiesLog4j = new Properties();
        try {
            propertiesLog4j.load(inStreamLog4j);
            PropertyConfigurator.configure(propertiesLog4j);
        } catch (IOException e) {
            e.printStackTrace();
            BasicConfigurator.configure();
        }

        logger.debug("log4j configured");

        String lf = System.getProperties().getProperty(LOG_FILE_NAME);
        if (lf != null) {
            logFileName = lf;
        }

        // If already created a print writer then just use it.
        try {
            logger.addAppender(new FileAppender(new SimpleLayout(), logFileName));
        } catch (FileNotFoundException fnfe) {

        }
    } catch (Exception ex) {
        ex.printStackTrace();
        throw new RuntimeException(ex);
    }

}
 
Example 57
Project: cyberduck   File: SystemLogAppenderTest.java   Source Code and License 5 votes vote down vote up
@Test
public void testAppend() throws Exception {
    final SystemLogAppender a = new SystemLogAppender();
    a.setLayout(new SimpleLayout());
    a.append(new LoggingEvent("f", Logger.getLogger(SystemLogAppender.class),
            Level.ERROR, "Test", new RuntimeException()));
}
 
Example 58
Project: hadoop   File: TestYARNRunner.java   Source Code and License 5 votes vote down vote up
@Test(timeout=20000)
public void testWarnCommandOpts() throws Exception {
  Logger logger = Logger.getLogger(YARNRunner.class);
  
  ByteArrayOutputStream bout = new ByteArrayOutputStream();
  Layout layout = new SimpleLayout();
  Appender appender = new WriterAppender(layout, bout);
  logger.addAppender(appender);
  
  JobConf jobConf = new JobConf();
  
  jobConf.set(MRJobConfig.MR_AM_ADMIN_COMMAND_OPTS, "-Djava.net.preferIPv4Stack=true -Djava.library.path=foo");
  jobConf.set(MRJobConfig.MR_AM_COMMAND_OPTS, "-Xmx1024m -Djava.library.path=bar");
  
  YARNRunner yarnRunner = new YARNRunner(jobConf);
  
  @SuppressWarnings("unused")
  ApplicationSubmissionContext submissionContext =
      buildSubmitContext(yarnRunner, jobConf);
 
  String logMsg = bout.toString();
  assertTrue(logMsg.contains("WARN - Usage of -Djava.library.path in " + 
  		"yarn.app.mapreduce.am.admin-command-opts can cause programs to no " +
      "longer function if hadoop native libraries are used. These values " + 
  		"should be set as part of the LD_LIBRARY_PATH in the app master JVM " +
      "env using yarn.app.mapreduce.am.admin.user.env config settings."));
  assertTrue(logMsg.contains("WARN - Usage of -Djava.library.path in " + 
      "yarn.app.mapreduce.am.command-opts can cause programs to no longer " +
      "function if hadoop native libraries are used. These values should " +
      "be set as part of the LD_LIBRARY_PATH in the app master JVM env " +
      "using yarn.app.mapreduce.am.env config settings."));
}
 
Example 59
Project: aliyun-oss-hadoop-fs   File: TestYARNRunner.java   Source Code and License 5 votes vote down vote up
@Test(timeout=20000)
public void testWarnCommandOpts() throws Exception {
  Logger logger = Logger.getLogger(YARNRunner.class);
  
  ByteArrayOutputStream bout = new ByteArrayOutputStream();
  Layout layout = new SimpleLayout();
  Appender appender = new WriterAppender(layout, bout);
  logger.addAppender(appender);
  
  JobConf jobConf = new JobConf();
  
  jobConf.set(MRJobConfig.MR_AM_ADMIN_COMMAND_OPTS, "-Djava.net.preferIPv4Stack=true -Djava.library.path=foo");
  jobConf.set(MRJobConfig.MR_AM_COMMAND_OPTS, "-Xmx1024m -Djava.library.path=bar");
  
  YARNRunner yarnRunner = new YARNRunner(jobConf);
  
  @SuppressWarnings("unused")
  ApplicationSubmissionContext submissionContext =
      buildSubmitContext(yarnRunner, jobConf);
 
  String logMsg = bout.toString();
  assertTrue(logMsg.contains("WARN - Usage of -Djava.library.path in " + 
  		"yarn.app.mapreduce.am.admin-command-opts can cause programs to no " +
      "longer function if hadoop native libraries are used. These values " + 
  		"should be set as part of the LD_LIBRARY_PATH in the app master JVM " +
      "env using yarn.app.mapreduce.am.admin.user.env config settings."));
  assertTrue(logMsg.contains("WARN - Usage of -Djava.library.path in " + 
      "yarn.app.mapreduce.am.command-opts can cause programs to no longer " +
      "function if hadoop native libraries are used. These values should " +
      "be set as part of the LD_LIBRARY_PATH in the app master JVM env " +
      "using yarn.app.mapreduce.am.env config settings."));
}
 
Example 60
Project: big-c   File: TestYARNRunner.java   Source Code and License 5 votes vote down vote up
@Test(timeout=20000)
public void testWarnCommandOpts() throws Exception {
  Logger logger = Logger.getLogger(YARNRunner.class);
  
  ByteArrayOutputStream bout = new ByteArrayOutputStream();
  Layout layout = new SimpleLayout();
  Appender appender = new WriterAppender(layout, bout);
  logger.addAppender(appender);
  
  JobConf jobConf = new JobConf();
  
  jobConf.set(MRJobConfig.MR_AM_ADMIN_COMMAND_OPTS, "-Djava.net.preferIPv4Stack=true -Djava.library.path=foo");
  jobConf.set(MRJobConfig.MR_AM_COMMAND_OPTS, "-Xmx1024m -Djava.library.path=bar");
  
  YARNRunner yarnRunner = new YARNRunner(jobConf);
  
  @SuppressWarnings("unused")
  ApplicationSubmissionContext submissionContext =
      buildSubmitContext(yarnRunner, jobConf);
 
  String logMsg = bout.toString();
  assertTrue(logMsg.contains("WARN - Usage of -Djava.library.path in " + 
  		"yarn.app.mapreduce.am.admin-command-opts can cause programs to no " +
      "longer function if hadoop native libraries are used. These values " + 
  		"should be set as part of the LD_LIBRARY_PATH in the app master JVM " +
      "env using yarn.app.mapreduce.am.admin.user.env config settings."));
  assertTrue(logMsg.contains("WARN - Usage of -Djava.library.path in " + 
      "yarn.app.mapreduce.am.command-opts can cause programs to no longer " +
      "function if hadoop native libraries are used. These values should " +
      "be set as part of the LD_LIBRARY_PATH in the app master JVM env " +
      "using yarn.app.mapreduce.am.env config settings."));
}