<commit_before>/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package org.ocelotds;

import com.sun.enterprise.security.ee.auth.login.ProgrammaticLogin;
import java.io.File;
import java.io.FileFilter;
import java.util.Random;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.asset.FileAsset;
import org.jboss.shrinkwrap.api.container.ClassContainer;
import org.jboss.shrinkwrap.api.container.ResourceContainer;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.junit.Before;
import org.ocelotds.security.CallService;
import org.ocelotds.security.CallServiceInterceptor;

/**
 *
 * @author hhfrancois
 */
public abstract class ArquillianTestCase {
	/**
	 * Build ocelot-web.jar
	 *
	 * @return
	 */
	public static JavaArchive createOcelotWebJar() {
		File bean = new File("src/main/resources/META-INF/beans.xml");
		File core = new File("src/main/resources/ocelot-core.js");
		JavaArchive javaArchive = ShrinkWrap.create(JavaArchive.class, String.format("ocelot-web-%s.jar", new Random().nextInt(10)))
				  .addClass(OcelotServices.class)
				  .addPackages(true, "org.ocelotds.configuration")
				  .addPackages(true, "org.ocelotds.core")
				  .addPackages(true, "org.ocelotds.encoders")
				  .addPackages(true, "org.ocelotds.exceptions")
				  .addPackages(true, "org.ocelotds.marshallers")
				  .addPackages(true, "org.ocelotds.resolvers")
				  .addClasses(CallService.class, CallServiceInterceptor.class)
				  .addPackages(true, "org.ocelotds.web")
				  .addAsManifestResource(new FileAsset(bean), "beans.xml")
				  .addAsResource(new FileAsset(core), "ocelot-core.js");
		addJSAndProvider("target/classes", javaArchive, javaArchive);
		return javaArchive;
	}

	@Before
	public void init(){
		ProgrammaticLogin login = new ProgrammaticLogin();
		login.login("hhf", "hhf".toCharArray());
	}
	
	/**
	 * Add srv_xxxx.js and srv_xxxx.ServiceProvider.class
	 *
	 * @param root
	 * @param resourceContainer
	 * @param classContainer
	 */
	public static void addJSAndProvider(final String root, ResourceContainer resourceContainer, ClassContainer classContainer) {
		File classes = new File(root);<commit_msg>add class in package test arquillian<commit_after>/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package org.ocelotds;

import com.sun.enterprise.security.ee.auth.login.ProgrammaticLogin;
import java.io.File;
import java.io.FileFilter;
import java.util.Random;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.asset.FileAsset;
import org.jboss.shrinkwrap.api.container.ClassContainer;
import org.jboss.shrinkwrap.api.container.ResourceContainer;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.junit.Before;

/**
 *
 * @author hhfrancois
 */
public abstract class ArquillianTestCase {
	/**
	 * Build ocelot-web.jar
	 *
	 * @return
	 */
	public static JavaArchive createOcelotWebJar() {
		File bean = new File("src/main/resources/META-INF/beans.xml");
		File core = new File("src/main/resources/ocelot-core.js");
		JavaArchive javaArchive = ShrinkWrap.create(JavaArchive.class, String.format("ocelot-web-%s.jar", new Random().nextInt(10)))
				  .addClass(OcelotServices.class)
				  .addPackages(true, "org.ocelotds.configuration")
				  .addPackages(true, "org.ocelotds.core")
				  .addPackages(true, "org.ocelotds.encoders")
				  .addPackages(true, "org.ocelotds.exceptions")
				  .addPackages(true, "org.ocelotds.marshallers")
				  .addPackages(true, "org.ocelotds.resolvers")
				  .addPackages(true, "org.ocelotds.security")
				  .addPackages(true, "org.ocelotds.web")
				  .addAsManifestResource(new FileAsset(bean), "beans.xml")
				  .addAsResource(new FileAsset(core), "ocelot-core.js");
		addJSAndProvider("target/classes", javaArchive, javaArchive);
		return javaArchive;
	}

	@Before
	public void init(){
		ProgrammaticLogin login = new ProgrammaticLogin();
		login.login("hhf", "hhf".toCharArray());
	}
	
	/**
	 * Add srv_xxxx.js and srv_xxxx.ServiceProvider.class
	 *
	 * @param root
	 * @param resourceContainer
	 * @param classContainer
	 */
	public static void addJSAndProvider(final String root, ResourceContainer resourceContainer, ClassContainer classContainer) {
		File classes = new File(root);
{'fraction_non_alphanumeric': 0.12718039302274234, 'fraction_numerical': 0.0026495915213071318, 'mean_word_length': 4.41866028708134, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5450124', 'n_tokens_mistral': 1671, 'n_tokens_neox': 1488, 'n_words': 300}